Hi,
I've some base in LUA but i had never overwrite a basic Gmod function.
So here's my problem,
I have 3 ulx group "admin", "admin+" and "superadmin"
admin and superadmin are considered like Admin with the IsAdmin function but not the admin+
So there is a way to add the admin+ group inside the "allowed group" in IsAdmin? I think that i can overwrite the function but i prefer to see the basic function to know how it work exactly, is there away to see it ?
Sorry for my english, have a nice day
[QUOTE=Sachha;48356104]Hi,
I've some base in LUA but i had never overwrite a basic Gmod function.
So here's my problem,
I have 3 ulx group "admin", "admin+" and "superadmin"
admin and superadmin are considered like Admin with the IsAdmin function but not the admin+
So there is a way to add the admin+ group inside the "allowed group" in IsAdmin? I think that i can overwrite the function but i prefer to see the basic function to know how it work exactly, is there away to see it ?
Sorry for my english, have a nice day[/QUOTE]
Just use ply:GetUserGroup()
That will return the player ulx rank, So you can check it on there
[DEL]ply:IsUserGroup("admin+")[/DEL]
ninja'd
you should never try and overwrite a base gmod func.
[code]
function IsAdmin(ply)
if ply:GetUserGroup("admin") or ply:GetUserGroup("superadmin") then
return true
end
return false
end
[/code]
not a detour but it will do what you said
use: [code]
IsAdmin(player entity)
[/code]
[QUOTE=tyguy;48357273][code]
function IsAdmin(ply)
if ply:GetUserGroup("admin") or ply:GetUserGroup("superadmin") then
return true
end
return false
end
[/code]
not a detour but it will do what you said
use: [code]
IsAdmin(player entity)
[/code][/QUOTE]
You should also backup the function before overwriting it ;)
[QUOTE=whitestar;48357577]You should also backup the function before overwriting it ;)[/QUOTE]
He's not overwriting it unless you have already made a function named IsAdmin.
[QUOTE=whitestar;48357577]You should also backup the function before overwriting it ;)[/QUOTE]
i'm not saving the Player.IsAdmin registry table function, i'm making a _G function
[QUOTE=tyguy;48357273][code]
function IsAdmin(ply)
if ply:GetUserGroup("admin") or ply:GetUserGroup("superadmin") then
return true
end
return false
end
[/code]
not a detour but it will do what you said
use: [code]
IsAdmin(player entity)
[/code][/QUOTE]
Why don't you do this?
[lua]
function IsAdmin(ply)
return ply:GetUserGroup("admin") or ply:GetUserGroup("superadmin")
end
[/lua]
[QUOTE=James xX;48357737]Why don't you do this?
[lua]
function IsAdmin(ply)
return ply:GetUserGroup("admin") or ply:GetUserGroup("superadmin")
end
[/lua][/QUOTE]
but how does that work? don't we need to check both of them
[QUOTE=tyguy;48357751]but how does that work? don't we need to check both of them[/QUOTE]
It's exactly the same as your code except without the useless if statements.
[QUOTE=James xX;48357737]Why don't you do this?
[lua]
function IsAdmin(ply)
return ply:GetUserGroup("admin") or ply:GetUserGroup("superadmin")
end
[/lua][/QUOTE]
This, but IsUserGroup instead, and with the admin+ group.
[QUOTE=James xX;48357768]It's exactly the same as your code except without the useless if statements.[/QUOTE]
oh
Okey, i found it alone finaly (I think, if i've done an error tell me :p) but thanks for your help
For people who want to know how :
=> garrysmod/lua/includes/extensions/player_auth.lua
[lua]function meta:IsAdmin()
if self:IsSuperAdmin() then return true end
if self:IsUserGroup("admin") then return true end
if self:IsUserGroup("thegroupthatyouwanttoadd") then return true end
return false
end
[/lua]
I don't know if it's "good" to do that ^^'
Its not good. you should use the functions given above, and if you use the plymeta, you should copy the function before editing it.
Of course it's not good. That's what I meant -.-
[code]
local meta = FindMetaTable("Player")
IsAdminCopy = meta.IsAdmin
function meta:IsAdmin(self)
return self:IsUserGroup("admin") or self:IsUserGroup("superadmin")
end
[/code]
[code]
player:IsAdmin()
[/code]
[QUOTE=tyguy;48366507][code]
local meta = FindMetaTable("Player")
IsAdminCopy = meta.IsAdmin
function meta:IsAdmin(self)
return self:IsUserGroup("admin") or self:IsUserGroup("superadmin")
end
[/code]
[code]
player:IsAdmin()
[/code][/QUOTE]
isn't that [I]exactly[/I] how the GMod function works?
[QUOTE=TylerB;48370691]isn't that [I]exactly[/I] how the GMod function works?[/QUOTE]
Yes, but he put that as an example on how he could modify it.
Sorry, you need to Log In to post a reply to this thread.