• Mayor's Aid Class (DarkRP)
    2 replies, posted
Hey guys! I would like to know if it's possible to make it so a class is used only when there is a mayor. For example, if a Mayor is elected, the police now have the ability to be a "Mayor's Aid" class. If there is no mayor it relays back an error message saying "There is no Mayor" I already made a post about this on the DarkRP forums but the reply I got wasn't helpful. On the DarkRP forums someone told me to add this custom check to the class. [CODE][I]customCheck = function(ply) return team.GetPlayers(TEAM_MAYOR) > 0 end[/I][/CODE] But it returns this Lua error when I press F4 [CODE] [ERROR] addons/darkrpmodification-master/lua/darkrp_customthings/jobs.lua:287: attempt to compare number with table 1. customCheck - addons/darkrpmodification-master/lua/darkrp_customthings/jobs.lua:287 2. canGetJob - gamemodes/darkrp/gamemode/modules/f4menu/cl_menuitem.lua:95 3. Refresh - gamemodes/darkrp/gamemode/modules/f4menu/cl_menuitem.lua:137 4. Refresh - gamemodes/darkrp/gamemode/modules/f4menu/cl_jobstab.lua:208 5. Refresh - gamemodes/darkrp/gamemode/modules/f4menu/cl_jobstab.lua:338 6. Refresh - gamemodes/darkrp/gamemode/modules/f4menu/cl_frame.lua:133 7. Show - gamemodes/darkrp/gamemode/modules/f4menu/cl_frame.lua:138 8. openF4Menu - gamemodes/darkrp/gamemode/modules/f4menu/cl_init.lua:8 9. Call - gamemodes/darkrp/gamemode/modules/f4menu/cl_init.lua:24 10. unknown - gamemodes/darkrp/gamemode/modules/base/cl_gamemode_functions.lua:46 [/CODE] Here is the job that is in my jobs.lua file: [CODE]TEAM_AID = DarkRP.createJob("Mayor's Aid", { color = Color(150, 20, 20, 255), model = "models/player/barney.mdl", description = [[You are to protect the Mayot at all costs!.]], weapons = {"arrest_stick", "unarrest_stick", "weapon_real_cs_mp5a5", "taser", "stunstick", "weapon_real_cs_desert_eagle", "door_ram", "weaponchecker"}, command = "maid", max = 1, salary = 60, admin = 1, vote = false, NeedToChangeFrom = TEAM_POLICE, hasLicense = false, customCheck = function(ply) return team.GetPlayers(TEAM_MAYOR) > 0 end }) [/CODE] If anyone can help me that would be great! Thanks!
Put a # in front of team.GetPlayers
[QUOTE=code_gs;45856730]Put a # in front of team.GetPlayers[/QUOTE] It works! Thanks!
Sorry, you need to Log In to post a reply to this thread.