• Need help with this script.
    0 replies, posted
I was looking on the Gmod wiki about NWint's and PData's and decided to try to make a very basic rank system with it. After a little more research I came up with this. Everything works on it other than when you reconnect to the server, it removes your rank. So I was wondering if anyone could help me, or tell my why it doesn't save, and their are no errors in console. All help will be appreciated. shared.lua: [LUA]local meta = FindMetaTable( "Player" ) function meta:IsVIP() if ( self:GetNWInt( "Rank" ) == 1 ) then return true else return false end end function meta:SaveVIP() self:SetPData( "Rank", self:GetRank() ) end function meta:GiveVIP() self:SetNWInt( "Rank", 1 ) self:SaveVIP() end function meta:TakeVIP() self:SetNWInt( "Rank", 0 ) self:SaveVIP() end function meta:GetRank() return self:GetNWInt("Rank") end[/LUA] And the init.lua; [LUA]function setrankspawn(ply) if ply:GetPData("Rank") == nil then ply:SetNWInt("Rank", 0) ply:SetPData("Rank", 0) print("Created data for "..ply:Nick()) else ply:SetNWInt("Rank", ply:GetPData("Rank")) print("Loaded data for "..ply:Nick()) end end hook.Add("PlayerInitialSpawn", "loadvip", setrankspawn) function dissave(ply) ply:SaveVIP() print("Saving for "..ply:Nick()..".") end hook.Add("PlayerDisconnected", "savingdude", dissave) function rankup(ply) ply:GiveVIP() ply:SendLua("GAMEMODE:AddNotify(\"You're now vip!\", NOTIFY_GENERIC, 5)") end concommand.Add("rankup", rankup) function checkrank(ply) if !ply:IsVIP() then ply:SendLua("GAMEMODE:AddNotify(\"You're not vip.\", NOTIFY_GENERIC, 5)") else ply:SendLua("GAMEMODE:AddNotify(\"You're vip\", NOTIFY_GENERIC, 5)") end end concommand.Add("Rank", checkrank)[/LUA]
Sorry, you need to Log In to post a reply to this thread.