• Clientside vs. Serverside IsAdmin()
    3 replies, posted
A system I'm working on is experiencing some issues. It seems that serverside, admin ranks are being returned correctly, but they are not on the clientside. Here's some example serverside debug info; [IMG]http://puu.sh/pZGdy/17c3071778.png[/IMG] GetUserGroup(), IsAdmin(), IsSuperAdmin() and some custom functions are all returning correctly serverside. However, clientside scripts using IsAdmin() and IsSuperAdmin() are messed up because the client for some reason does not know if it is an admin or not, but it DOES know what usergroup it is, which confuses me. Here's some clientside debug code I wrote: [CODE]concommand.Add("amiadmin", function(ply) print(ply:IsAdmin(), ply:IsSuperAdmin()) end) concommand.Add("ismygroup", function(ply,cmd,args) print(ply:IsUserGroup(args[1])) end)[/CODE] The first command, ran at the same time as the serverside code that said I was an admin AND superadmin, returns false and false. The second command, when ran with the name of my admin group, returns true, and it returns false if the argument does not match my usergroup. Here are my relevant serverside overrides: [CODE]function meta:IsAdmin(ply) if self:IsSuperAdmin() then return true elseif self:QUInheritance() == "admin" then return true else return false end end function meta:IsSuperAdmin(ply) if self:QUInheritance() == "superadmin" then return true else return false end end function meta:IsUserGroup(name) if not self:IsValid() then return false end return self:GetUserGroup() == name end function meta:GetUserGroup(ply) return sql.QueryValue("SELECT rankid FROM "..DB.Player.Table.." WHERE SteamID = '"..self:SteamID().."'") end [/CODE] What am I missing? I need the client to be able to know if it's an admin or superadmin.
Wait, so if you're overriding IsAdmin and IsSuperAdmin serverside then maybe the problem is that you never overwrote them clientside?
You should be putting the meta functions in a shared file. That GetUserGroup function is not going to work clientside.
Thank you both. Sounds like I have to go back to day 1 of lua training when I learned about server and client environments, lol. I put all the meta stuff into a shared file, and everything works as it should!
Sorry, you need to Log In to post a reply to this thread.