Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lua/autorun/server/permapropmysql.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

require('mysqloo')

local HOST = "localhost"
local USER = "user"
local PASS = ""
local DATABASE = ""
local PORT = 3306

if !mysqloo then MsgN("[PermaProps] -> Failed to load mysqloo module.\n\tPlease recheck your version to make sure it's installed correctly.\n\tAlso check to see if you have the right version.") return end

Perma.MySQL = mysqloo.connect(HOST, USER, PASS, DATABASE, PORT)
Perma.MySQL.onConnected = function()
Perma.MySQLConnected = true

MsgN("[PermaProps] Successfully to connect to database.")
init()
end
Perma.MySQL.onConnectionFailed = function(db, err)
Perma.MySQLConnected = false
MsgN("[PermaProps] Failed to connect to database -> " .. err)
end
Perma.MySQL:connect()
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

Perma = Perma or {} -- Init table

TOOL.Category = "SaveProps"
TOOL.Category = "Props Tool"
TOOL.Name = "PermaProps"
TOOL.Command = nil
TOOL.ConfigName = ""
Expand All @@ -31,32 +31,7 @@ if CLIENT then
language.Add("Tool.permaprops.0", "LeftClick: Add RightClick: Remove Reload: Update")
end

if SERVER then
require('mysqloo')

local HOST = "localhost"
local USER = "user"
local PASS = ""
local DATABASE = ""
local PORT = 3306

if !mysqloo then MsgN("[PermaProps] -> Failed to load mysqloo module.\n\tPlease recheck your version to make sure it's installed correctly.\n\tAlso check to see if you have the right version.") return end

Perma.MySQL = mysqloo.connect(HOST, USER, PASS, DATABASE, PORT)
Perma.MySQL.onConnected = function()
Perma.MySQLConnected = true

MsgN("[PermaProps] Successfully to connect to database.")
init()
end
Perma.MySQL.onConnectionFailed = function(db, err)
Perma.MySQLConnected = false
MsgN("[PermaProps] Failed to connect to database -> " .. err)
end
Perma.MySQL:connect()


end

function init()

Expand Down Expand Up @@ -171,7 +146,7 @@ local function PPGetEntTable( ent )
content.Angle = ent:GetAngles()
content.Model = ent:GetModel()
content.Skin = ent:GetSkin()
content.Mins, content.Maxs = ent:GetCollisionBounds()
--content.Mins, content.Maxs = ent:GetCollisionBounds()
content.ColGroup = ent:GetCollisionGroup()
content.Name = ent:GetName()
content.ModelScale = ent:GetModelScale()
Expand Down Expand Up @@ -213,7 +188,7 @@ local function PPEntityFromTable( data, id )
ent:SetAngles( data.Angle or Angle(0, 0, 0) )
ent:SetModel( data.Model or "models/error.mdl" )
ent:SetSkin( data.Skin or 0 )
ent:SetCollisionBounds( ( data.Mins or 0 ), ( data.Maxs or 0 ) )
--ent:SetCollisionBounds( ( data.Mins or 0 ), ( data.Maxs or 0 ) )
ent:SetCollisionGroup( data.ColGroup or 0 )
ent:SetName( data.Name or "" )
ent:SetModelScale( data.ModelScale or 1 )
Expand Down Expand Up @@ -384,8 +359,6 @@ function TOOL:LeftClick(trace)

if CLIENT then return end

if not trace.Entity:IsValid() or not self:GetOwner():IsAdmin() then return end

local ent = trace.Entity
local ply = self:GetOwner()

Expand Down Expand Up @@ -425,8 +398,6 @@ function TOOL:RightClick(trace)

if CLIENT then return end

if (not trace.Entity:IsValid()) then return end

local ent = trace.Entity
local ply = self:GetOwner()

Expand Down
Loading