• What the problem of this lua error??
    14 replies, posted
The error on console : [ERROR] gamemodes/darkrp/gamemode/server/main.lua:25: attempt to call method 'IsUserGroup' (a nil value) 1. Isowner - gamemodes/darkrp/gamemode/server/main.lua:25 2. unknown - gamemodes/darkrp/gamemode/server/admincc.lua:353 3. unknown - lua/includes/modules/concommand.lua:69 The line from main.lua : [CODE]function Isowner(ply) return ply:IsUserGroup("owner") end[/CODE] The function from admincc.lua : [CODE] local function ccSetMoney(ply, cmd, args) if not tonumber(args[2]) then ply:PrintMessage(HUD_PRINTCONSOLE, "Invalid arguments") return end if !Isowner(ply) then ply:PrintMessage(2, DarkRP.getPhrase("need_sadmin", "rp_setmoney")) return end local amount = math.floor(tonumber(args[2])) if args[3] then amount = args[3] == "-" and math.Max(0, ply:getDarkRPVar("money") - amount) or ply:getDarkRPVar("money") + amount end local target = GAMEMODE:FindPlayer(args[1]) if target then local nick = "" DB.StoreMoney(target, amount) target:SetDarkRPVar("money", amount) if ply:EntIndex() == 0 then print("Set " .. target:Nick() .. "'s money to: " .. GAMEMODE.Config.currency .. amount) nick = "Console" else ply:PrintMessage(2, "Set " .. target:Nick() .. "'s money to: " .. GAMEMODE.Config.currency .. amount) nick = ply:Nick() end target:PrintMessage(2, nick .. " set your money to: " .. GAMEMODE.Config.currency .. amount) if ply:EntIndex() == 0 then DB.Log("Console set "..target:SteamName().."'s money to "..GAMEMODE.Config.currency..amount, nil, Color(30, 30, 30)) else DB.Log(ply:Nick().." ("..ply:SteamID()..") set "..target:SteamName().."'s money to "..GAMEMODE.Config.currency..amount, nil, Color(30, 30, 30)) end else if ply:EntIndex() == 0 then print("Could not find player: " .. args[1]) else ply:PrintMessage(2, "Could not find player: " .. args[1]) end return end end [/CODE] I realy dont understand what the problem here. When I do the command from Rcon its doesnt working sometimes I dont have access to VIP jobs in my darkrp server...
So this may happen when ply is not a player. Try to put print(ply:GetClass()) efore this function to figure out what class is it, then if it "player" try call here FindMetaTable("Player") table, and see what is in here.
It's ply:GetUserGroup() not IsUserGroup()
[QUOTE=LUModder;45582407]It's ply:GetUserGroup() not IsUserGroup()[/QUOTE] [url]http://wiki.garrysmod.com/page/Player/IsUserGroup[/url]
[QUOTE=Joeyl10;45582711][url]http://wiki.garrysmod.com/page/Player/IsUserGroup[/url][/QUOTE] Whatever, he could still try [code] function IsOwner(ply) return ply:GetUserGroup() == "owner" end [/code]
IsUserGroup works perfectly, can't be that.
When you use the command via RCON, ply == NULL. Here's how I "Test" for rcon: [code]// // Cancel Timed Event // concommand.Add( "cancel", function( ply, cmd, args ) if ( ply != NULL && !ply:IsSuperAdmin( ) ) then Log( ply, language.GetPhrase( "cancel_timedevent_log", language.__default ) ); return; end hook.Call( "CancelTimedEvent", GAMEMODE, ply, args[ 1 ] ); end );[/code] If you want the command to work for RCON, then you must disregard sending ply:Notify/notifications. Use print/MsgC/Msg/MsgN if RCON, or notify the player if not rcon.
In sometimes I dont have access to Isadmin or Isowner or ISuperAdmin Of to custom jobs in darkrp I got this job its only for vip or admins : [CODE]TEAM_Rapist = AddExtraTeam("Rapist", { color = Color(0, 0, 0, 0), model = {"models/player/Group01/Male_09.mdl"}, description = [[If you want rape peoples!]], weapons = {"weapon_mad_fists","weapon_rape", "swep_pickpocketvip"}, command = "rapist", max = 2, salary = 20, admin = 0, vote = false, hasLicense = false, customCheck = function(ply) return CLIENT or ply:IsUserGroup("supporter") or ply:IsUserGroup("supervisor") or ply:IsUserGroup("owner") or ply:IsUserGroup("moderator") or ply:IsUserGroup("superadmin") or ply:IsUserGroup("admin") or ply:IsUserGroup("trusted_admin") or ply:IsUserGroup("helper") end, CustomCheckFailMsg = "You need to be an Supporter/VIP to become a Rapist" })[/CODE] Sometimes the access broken to supporter group and I need to restart the server. When supporter try to be this job it say : "You need to be an Supporter/VIP to become a Rapist" And after I need to restart the server and after its work fine. I want to find the problem of this bug.. I realy dont understand why its happen. Example : When I got this bug when I am on owner job I dont have access to rp_setmoney (configured on the files to be only able to owner group) and after I restart the map I got the access to the command.
ULX has issues with groups sometimes I hear. Also, I'd recommend getting the group once, then comparing it instead of checking for each group.... [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/tracking_players/player_group.lua.html[/url] Example: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gamemode_logic/give_weapons_based_on_group.lua.html[/url] So you could have VIP_GROUPS as a table somewhere, and you could write a meta function META_PLAYER:IsVIP( ) and check once... I'd also recommend caching similar to this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/donators_manager/sh_manage_donators.lua.html[/url]
[QUOTE=Acecool;45583877]ULX has issues with groups sometimes I hear. Also, I'd recommend getting the group once, then comparing it instead of checking for each group.... [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/tracking_players/player_group.lua.html[/url] Example: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gamemode_logic/give_weapons_based_on_group.lua.html[/url] So you could have VIP_GROUPS as a table somewhere, and you could write a meta function META_PLAYER:IsVIP( ) and check once... I'd also recommend caching similar to this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/donators_manager/sh_manage_donators.lua.html[/url][/QUOTE] This is my funcs : [CODE] function IsVIP(ply) return ply:IsUserGroup("owner") or ply:IsUserGroup("superadmin") or ply:IsUserGroup("trusted_admin") or ply:IsUserGroup("admin") or ply:IsUserGroup("moderator") or ply:IsUserGroup("supporter") end function IsHelper(ply) return ply:IsUserGroup("helper") end function IsModerator(ply) return ply:IsUserGroup("owner") or ply:IsUserGroup("superadmin") or ply:IsUserGroup("moderator") or ply:IsUserGroup("admin") or ply:IsUserGroup("trusted_admin") end function IsAdmin(ply) return ply:IsUserGroup("owner") or ply:IsUserGroup("superadmin") or ply:IsUserGroup("admin") or ply:IsUserGroup("trusted_admin") end function IsSuperAdmin(ply) return ply:IsUserGroup("owner") or ply:IsUserGroup("superadmin") end function Isowner(ply) return ply:IsUserGroup("owner") end [/CODE]
This is honestly how I would have done it with a table of all ranks etc, and then use meta functions instead of what you're currently doing. [code]local Groups = {}; Groups["owner"] = { Vip = true, Mod = true, Admin = true, SA = true, Owner = true }; Groups["superadmin"] = { Vip = true, Mod = true, Admin = true, SA = true }; Groups["trusted_admin"] = { Vip = true, Mod = true, Admin = true }; Groups["admin"] = { Vip = true, Mod = true, Admin = true }; Groups["moderator"] = { Vip = true, Mod = true }; Groups["supporer"] = { Vip = true }; Groups["helper"] = { Helper = true }; local meta = FindMetaTable("Player"); function meta:IsVIP() local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Vip) then return true; end return false; end function meta:IsHelper() local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Helper) then return true; end return false; end function meta:IsMod() local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Mod) then return true; end return false; end local isadmin = meta.IsAdmin function meta:IsAdmin() if (self:isadmin()) then return true; end local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Admin) then return true; end return false; end local issa = meta.IsSuperAdmin function meta:IsAdmin() if (self:issa()) then return true; end local group = self:GetUserGroup(); if (Groups[group] && Groups[group].SA) then return true; end return false; end function meta:IsOwner() local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Owner) then return true; end return false; end [/code] EDIT: Stupid FP parsing. Anyways, I hope I overrode those functions right, I've never actually done it :P
[QUOTE=crazyscouter;45584823]This is honestly how I would have done it with a table of all ranks etc, and then use meta functions instead of what you're currently doing. [code]local Groups = {}; Groups["owner"] = { Vip = true, Mod = true, Admin = true, SA = true, Owner = true }; Groups["superadmin"] = { Vip = true, Mod = true, Admin = true, SA = true }; Groups["trusted_admin"] = { Vip = true, Mod = true, Admin = true }; Groups["admin"] = { Vip = true, Mod = true, Admin = true }; Groups["moderator"] = { Vip = true, Mod = true }; Groups["supporer"] = { Vip = true }; Groups["helper"] = { Helper = true }; local meta = FindMetaTable("Player"); function meta:IsVIP() local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Vip) then return true; end return false; end function meta:IsHelper() local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Helper) then return true; end return false; end function meta:IsMod() local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Mod) then return true; end return false; end local isadmin = meta.IsAdmin function meta:IsAdmin() if (self:isadmin()) then return true; end local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Admin) then return true; end return false; end local issa = meta.IsSuperAdmin function meta:IsAdmin() if (self:issa()) then return true; end local group = self:GetUserGroup(); if (Groups[group] && Groups[group].SA) then return true; end return false; end function meta:IsOwner() local group = self:GetUserGroup(); if (Groups[group] && Groups[group].Owner) then return true; end return false; end [/code] EDIT: Stupid FP parsing. Anyways, I hope I overrode those functions right, I've never actually done it :P[/QUOTE] Did you check those tables?
What?
[QUOTE=crazyscouter;45599884]What?[/QUOTE] Have you checked this tables?
ULX groups are case sensitive (sometimes, dont ask why it just is :P) Try making sure your string "owner" matches up case for case with your usergroup.
Sorry, you need to Log In to post a reply to this thread.