Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require( "mysql" )
- local pl = FindMetaTable( "Player" )
- local db, error = mysql.connect("74.86.13.144", "thesocia_antid2", "*********", "thesocia_zombie")
- function pl:GetInfo()
- local Content = mysql.query(db, "SELECT * FROM Players WHERE id = '"..self:SteamID().."'")
- local id = Content[1][1] --First column
- local xp = Content[1][2] --Second column
- local rank = Content[1][3] --etc
- local money = Content[1][4]
- local hp = Content[1][5]
- local kills = Content[1][6]
- local priv = Content[1][7]
- self:SetNWString("id", id)
- self:SetNWInt ("xp", xp)
- self:SetNWInt ("rank", rank)
- self:SetNWInt ("money", money)
- self:SetNWInt ("hp", hp)
- self:SetNWInt ("kills", kills)
- self:SetNWInt ("priv", priv)
- end
- function pl:Save()
- local id = self:GetNWString ("id")
- local xp = self:GetNWInt ("xp")
- local rank = self:GetNWInt ("rank")
- local money = self:GetNWInt ("money")
- local hp = self:GetNWInt ("hp")
- local kills = self:GetNWInt ("kills")
- local priv = self:GetNWInt ("priv")
- mysql.query(db, "UPDATE Players SET xp = "..xp..", rank = "..rank..", money = "..money..", hp = "..hp..", kills = "..kills..", priv = "..priv.." WHERE id = '"..id.."'")
- self:ChatPrint("Player Saved")
- end
- function pl:NewPly()
- local ID = self:SteamID()
- mysql.query(db, "INSERT INTO Players (`id`, `xp`, `rank`, `money`, `hp`, `kills`, `priv`)VALUES ('"..ID.."', '0', '0', '0', '100', '0', '0')");
- print("Player Inserted");
- end
- function pl:Exists()
- local ID = self:SteamID()
- --[[
- result, isok, error = mysql.query(db, "SELECT id, xp, rank, hp, kills, priv FROM Players WHERE id = '"..steamID.."'")
- if (result) then
- self:GetInfo()
- else
- self:NewPly()
- end
- --]]
- local result = mysql.query(db, "SELECT * FROM Players WHERE id = '"..ID.."'")
- if(result and result[1]) then
- self:GetInfo()
- self:ChatPrint("Character Loaded")
- else
- self:NewPly()
- end
- end
- function InitSpawn(ply)
- //local ID = self:SteamID()
- //self:SetNWString("SteamID", ID) --Why?
- //timer.Create("SaveInfo", 10, 0, function() self:Save( ) end)
- ply:Exists()
- //end)
- end
- hook.Add( "PlayerAuthed", "PlayerAuthorize", InitSpawn )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement