• VIP Jobs
    10 replies, posted
I tried adding VIP Jobs and they seem to not be working I'm not sure what to do.. -- People often copy jobs. When they do, the GM table does not exist anymore. -- This line makes the job code work both inside and outside of gamemode files. -- You should not copy this line into your code. local GAMEMODE = GAMEMODE or GM /*-------------------------------------------------------- Default teams. Please do not edit this file. Please use the darkrpmod addon instead. --------------------------------------------------------*/ --------------------------------------------------------*/ TEAM_CITIZEN = AddExtraTeam("Citizen", Color(20, 150, 20, 255), { "models/player/Group01/Female_01.mdl", "models/player/Group01/Female_02.mdl", "models/player/Group01/Female_03.mdl", "models/player/Group01/Female_04.mdl", "models/player/Group01/Female_06.mdl", "models/player/Group01/Female_07.mdl", "models/player/group01/male_01.mdl", "models/player/Group01/Male_02.mdl", "models/player/Group01/male_03.mdl", "models/player/Group01/Male_04.mdl", "models/player/Group01/Male_05.mdl", "models/player/Group01/Male_06.mdl", "models/player/Group01/Male_07.mdl", "models/player/Group01/Male_08.mdl", "models/player/Group01/Male_09.mdl"}, [[The Citizen is the most basic level of society you can hold besides being a hobo. You have no specific role in city life.]], {}, "citizen", 0, 45, 0, false, false) TEAM_POLICE = AddExtraTeam("Civil Protection", Color(25, 25, 170, 255), "models/player/police.mdl", [[The protector of every citizen that lives in the city . You have the power to arrest criminals and protect innocents. Hit them with your arrest baton to put them in jail Bash them with a stunstick and they might learn better than to disobey the law. The Battering Ram can break down the door of a criminal with a warrant for his/her arrest. The Battering Ram can also unfreeze frozen props(if enabled). Type /wanted <name> to alert the public to this criminal OR go to tab and warrant someone by clicking the warrant button]], {"arrest_stick", "unarrest_stick", "m9k_m92beretta", "stunstick", "door_ram", "weaponchecker"}, "cp", 4, 65, 0, true, true) TEAM_GANG = AddExtraTeam("Gangster", Color(75, 75, 75, 255), { "models/player/Group03/Female_01.mdl", "models/player/Group03/Female_02.mdl", "models/player/Group03/Female_03.mdl", "models/player/Group03/Female_04.mdl", "models/player/Group03/Female_06.mdl", "models/player/Group03/Female_07.mdl", "models/player/group03/male_01.mdl", "models/player/Group03/Male_02.mdl", "models/player/Group03/male_03.mdl", "models/player/Group03/Male_04.mdl", "models/player/Group03/Male_05.mdl", "models/player/Group03/Male_06.mdl", "models/player/Group03/Male_07.mdl", "models/player/Group03/Male_08.mdl", "models/player/Group03/Male_09.mdl"}, [[The lowest person of crime. A gangster generally works for the Mobboss who runs the crime family. The Mobboss sets your agenda and you follow it or you might be punished.]], {}, "gangster", 3, 45, 0, false, false) TEAM_GANGLEADER = AddExtraTeam("Gangster Leader", Color(25, 25, 25, 255), "models/player/gman_high.mdl", [[The Mobboss is the boss of the criminals in the city. With his power he coordinates the gangsters and forms an efficent crime organization. He has the ability to break into houses by using a lockpick. The Mobboss also can unarrest you.]], {"lockpick", "unarrest_stick"}, "gangleader", 1, 60, 0, false, false, TEAM_GANG) TEAM_LGUN = AddExtraTeam("Light Gun Dealer", Color(255, 140, 0, 255), "models/player/monk.mdl", [[A gun dealer is the only person who can sell guns to other people.]], {}, "lgundealer", 2, 45, 0, false, false) TEAM_HGUN = AddExtraTeam("Heavy Gun Dealer", Color(255, 140, 0, 255), "models/player/monk.mdl", [[A gun dealer is the only person who can sell guns to other people.]], {}, "hgundealer", 2, 85, 0, false, false, TEAM_LGUN) TEAM_MEDIC = AddExtraTeam("Medic", Color(47, 79, 79, 255), "models/player/kleiner.mdl", [[With your medical knowledge, you heal players to proper health. Without a medic, people can not be healed. Left click with the Medical Kit to heal other players. Right click with the Medical Kit to heal yourself.]], {"med_kit"}, "medic", 3, 45, 0, false, false) TEAM_CHIEF = AddExtraTeam("Civil Protection Chief", Color(20, 20, 255, 255), "models/player/combine_soldier_prisonguard.mdl", [[The Chief is the leader of the Civil Protection unit. Coordinate the police forces to bring law to the city Hit them with arrest baton to put them in jail Bash them with a stunstick and they might learn better than to disobey the law. The Battering Ram can break down the door of a criminal with a warrant for his/her arrest. Type /wanted <name> to alert the public to this criminal Type /jailpos to set the Jail Position]], {"arrest_stick", "unarrest_stick", "m9k_m92beretta", "stunstick", "door_ram", "weaponchecker"}, "chief", 1, 75, 0, false, true, TEAM_POLICE) TEAM_MAYOR = AddExtraTeam("Mayor", Color(150, 20, 20, 255), "models/player/breen.mdl", [[The Mayor of the city creates laws to serve the greater good of the people. If you are the mayor you may create and accept warrants. Type /wanted <name> to warrant a player Type /jailpos to set the Jail Position Type /lockdown initiate a lockdown of the city. Everyone must be inside during a lockdown. The cops patrol the area /unlockdown to end a lockdown]], {"m9k_deagle"}, "mayor", 1, 85, 0, true, false, {}) TEAM_DJ = AddExtraTeam( "DJ", Color(255, 140, 0, 255), "models/player/corpse1.mdl", [[You can play music for people at a club, bar, restraunt or even on the streets. People can choose to pay you.]], {}, "dj", 1,250,0,false, function(ply) return ply:GetNWString("usergroup") == "VIP" or ply:IsAdmin() end) TEAM_OWNER = AddExtraTeam( "Server Owner", Color(102, 51, 153, 255), "models/player/agent_47.mdl", [[You are the server owner.]], {}, "owner", 1,5000000,2,false, function(ply) return ply:IsSuperAdmin() end ) TEAM_HITMAN = AddExtraTeam( "Hitman", Color( 30, 144, 255, 255 ), "models/player/phoenix.mdl", [[Get a target, Kill the target, Profit.]], {"keys", "pocket", "m9k_m24"}, "hitman", 1,250,0,true ) TEAM_ADMIN = AddExtraTeam( "ADMIN", Color(102, 51, 153, 255), "models/player/zerosuit.mdl", [[Make sure no one disobeys server rules.]], {}, "admin", 10,5000000,1,false ) TEAM_HOBO = AddExtraTeam( "Hobo", Color(80, 45, 0, 255), "models/player/corpse1.mdl", [[The lowest member of society. Everybody laughs at you. You have no home. Beg for your food and money Sing for everyone who passes to get money Make your own wooden home somewhere in a corner or outside someone else's door]],{"weapon_bugbait"}, "hobo", 10,0,0,false ) TEAM_HOBOKING = AddExtraTeam( "Hobo King", Color(80, 45, 0, 255), "models/player/corpse1.mdl", [[The lowest member of society. Everybody laughs at you. You have no home. Beg for your food and money Sing for everyone who passes to get money Make your own wooden home somewhere in a corner or outside someone else's door]],{"weapon_bugbait"}, "hoboking", 1,0,0,false, TEAM_HOBO ) TEAM_DRUG = AddExtraTeam( "Drug Dealer", Color(255, 140, 0, 255), "models/player/eli.mdl", [[Sell drugs to people but don't get caught by police in public.]], {}, "drug", 1, 100,0,false ) TEAM_TERRORIST = AddExtraTeam( "Terrorist", Color( 30, 144, 255, 255), "models/player/soldier_stripped.mdl", [[You have a jihad bomb, try your best to not abuse it by just randomly running up to people in public and killing them every second. Raid together with your leader, threaten people, scare people.]], {"weapon_jihadbomb"}, "terrorist", 2, 75,0,true, function(ply) return ply:GetNWString("usergroup") == "VIP" or ply:IsAdmin() end ) TEAM_KICKASS = AddExtraTeam( "Kick-Ass", { color = Color(25, 25, 170, 255), model = "models/norpo/ArkhamOrigins/Assassins/Deathstroke_ValveBiped.mdl", description = [[Kickass must protect the civilians of FuzzyRP, you can only use your baton provided, Kickass does not shoot guns.]], weapons = {"weapon_crowbar"}, command = "kickass", max = 1, salary = 750, admin = 0, vote =
Please use [noparse][lua][/lua][/noparse] tags for your code, and give us the script error(s).
[lua]/*-------------------------------------------------------- Default teams. Please do not edit this file. Please use the darkrpmod addon instead. --------------------------------------------------------*/ --------------------------------------------------------*/ TEAM_CITIZEN = AddExtraTeam("Citizen", Color(20, 150, 20, 255), { "models/player/Group01/Female_01.mdl", "models/player/Group01/Female_02.mdl", "models/player/Group01/Female_03.mdl", "models/player/Group01/Female_04.mdl", "models/player/Group01/Female_06.mdl", "models/player/Group01/Female_07.mdl", "models/player/group01/male_01.mdl", "models/player/Group01/Male_02.mdl", "models/player/Group01/male_03.mdl", "models/player/Group01/Male_04.mdl", "models/player/Group01/Male_05.mdl", "models/player/Group01/Male_06.mdl", "models/player/Group01/Male_07.mdl", "models/player/Group01/Male_08.mdl", "models/player/Group01/Male_09.mdl"}, [[The Citizen is the most basic level of society you can hold besides being a hobo. You have no specific role in city life.]], {}, "citizen", 0, 45, 0, false, false) TEAM_POLICE = AddExtraTeam("Civil Protection", Color(25, 25, 170, 255), "models/player/police.mdl", [[The protector of every citizen that lives in the city . You have the power to arrest criminals and protect innocents. Hit them with your arrest baton to put them in jail Bash them with a stunstick and they might learn better than to disobey the law. The Battering Ram can break down the door of a criminal with a warrant for his/her arrest. The Battering Ram can also unfreeze frozen props(if enabled). Type /wanted <name> to alert the public to this criminal OR go to tab and warrant someone by clicking the warrant button]], {"arrest_stick", "unarrest_stick", "m9k_m92beretta", "stunstick", "door_ram", "weaponchecker"}, "cp", 4, 65, 0, true, true) TEAM_GANG = AddExtraTeam("Gangster", Color(75, 75, 75, 255), { "models/player/Group03/Female_01.mdl", "models/player/Group03/Female_02.mdl", "models/player/Group03/Female_03.mdl", "models/player/Group03/Female_04.mdl", "models/player/Group03/Female_06.mdl", "models/player/Group03/Female_07.mdl", "models/player/group03/male_01.mdl", "models/player/Group03/Male_02.mdl", "models/player/Group03/male_03.mdl", "models/player/Group03/Male_04.mdl", "models/player/Group03/Male_05.mdl", "models/player/Group03/Male_06.mdl", "models/player/Group03/Male_07.mdl", "models/player/Group03/Male_08.mdl", "models/player/Group03/Male_09.mdl"}, [[The lowest person of crime. A gangster generally works for the Mobboss who runs the crime family. The Mobboss sets your agenda and you follow it or you might be punished.]], {}, "gangster", 3, 45, 0, false, false) TEAM_GANGLEADER = AddExtraTeam("Gangster Leader", Color(25, 25, 25, 255), "models/player/gman_high.mdl", [[The Mobboss is the boss of the criminals in the city. With his power he coordinates the gangsters and forms an efficent crime organization. He has the ability to break into houses by using a lockpick. The Mobboss also can unarrest you.]], {"lockpick", "unarrest_stick"}, "gangleader", 1, 60, 0, false, false, TEAM_GANG) TEAM_LGUN = AddExtraTeam("Light Gun Dealer", Color(255, 140, 0, 255), "models/player/monk.mdl", [[A gun dealer is the only person who can sell guns to other people.]], {}, "lgundealer", 2, 45, 0, false, false) TEAM_HGUN = AddExtraTeam("Heavy Gun Dealer", Color(255, 140, 0, 255), "models/player/monk.mdl", [[A gun dealer is the only person who can sell guns to other people.]], {}, "hgundealer", 2, 85, 0, false, false, TEAM_LGUN) TEAM_MEDIC = AddExtraTeam("Medic", Color(47, 79, 79, 255), "models/player/kleiner.mdl", [[With your medical knowledge, you heal players to proper health. Without a medic, people can not be healed. Left click with the Medical Kit to heal other players. Right click with the Medical Kit to heal yourself.]], {"med_kit"}, "medic", 3, 45, 0, false, false) TEAM_CHIEF = AddExtraTeam("Civil Protection Chief", Color(20, 20, 255, 255), "models/player/combine_soldier_prisonguard.mdl", [[The Chief is the leader of the Civil Protection unit. Coordinate the police forces to bring law to the city Hit them with arrest baton to put them in jail Bash them with a stunstick and they might learn better than to disobey the law. The Battering Ram can break down the door of a criminal with a warrant for his/her arrest. Type /wanted <name> to alert the public to this criminal Type /jailpos to set the Jail Position]], {"arrest_stick", "unarrest_stick", "m9k_m92beretta", "stunstick", "door_ram", "weaponchecker"}, "chief", 1, 75, 0, false, true, TEAM_POLICE) TEAM_MAYOR = AddExtraTeam("Mayor", Color(150, 20, 20, 255), "models/player/breen.mdl", [[The Mayor of the city creates laws to serve the greater good of the people. If you are the mayor you may create and accept warrants. Type /wanted <name> to warrant a player Type /jailpos to set the Jail Position Type /lockdown initiate a lockdown of the city. Everyone must be inside during a lockdown. The cops patrol the area /unlockdown to end a lockdown]], {"m9k_deagle"}, "mayor", 1, 85, 0, true, false, {}) TEAM_DJ = AddExtraTeam( "DJ", Color(255, 140, 0, 255), "models/player/corpse1.mdl", [[You can play music for people at a club, bar, restraunt or even on the streets. People can choose to pay you.]], {}, "dj", 1,250,0,false, function(ply) return ply:GetNWString("usergroup") == "VIP" or ply:IsAdmin() end) TEAM_OWNER = AddExtraTeam( "Server Owner", Color(102, 51, 153, 255), "models/player/agent_47.mdl", [[You are the server owner.]], {}, "owner", 1,5000000,2,false, function(ply) return ply:IsSuperAdmin() end ) TEAM_HITMAN = AddExtraTeam( "Hitman", Color( 30, 144, 255, 255 ), "models/player/phoenix.mdl", [[Get a target, Kill the target, Profit.]], {"keys", "pocket", "m9k_m24"}, "hitman", 1,250,0,true ) TEAM_ADMIN = AddExtraTeam( "ADMIN", Color(102, 51, 153, 255), "models/player/zerosuit.mdl", [[Make sure no one disobeys server rules.]], {}, "admin", 10,5000000,1,false ) TEAM_HOBO = AddExtraTeam( "Hobo", Color(80, 45, 0, 255), "models/player/corpse1.mdl", [[The lowest member of society. Everybody laughs at you. You have no home. Beg for your food and money Sing for everyone who passes to get money Make your own wooden home somewhere in a corner or outside someone else's door]],{"weapon_bugbait"}, "hobo", 10,0,0,false ) TEAM_HOBOKING = AddExtraTeam( "Hobo King", Color(80, 45, 0, 255), "models/player/corpse1.mdl", [[The lowest member of society. Everybody laughs at you. You have no home. Beg for your food and money Sing for everyone who passes to get money Make your own wooden home somewhere in a corner or outside someone else's door]],{"weapon_bugbait"}, "hoboking", 1,0,0,false, TEAM_HOBO ) TEAM_DRUG = AddExtraTeam( "Drug Dealer", Color(255, 140, 0, 255), "models/player/eli.mdl", [[Sell drugs to people but don't get caught by police in public.]], {}, "drug", 1, 100,0,false ) TEAM_TERRORIST = AddExtraTeam( "Terrorist", Color( 30, 144, 255, 255), "models/player/soldier_stripped.mdl", [[You have a jihad bomb, try your best to not abuse it by just randomly running up to people in public and killing them every second. Raid together with your leader, threaten people, scare people.]], {"weapon_jihadbomb"}, "terrorist", 2, 75,0,true, function(ply) return ply:GetNWString("usergroup") == "VIP" or ply:IsAdmin() end ) TEAM_KICKASS = AddExtraTeam( "Kick-Ass", { color = Color(25, 25, 170, 255), model = "models/norpo/ArkhamOrigins/Assassins/Deathstroke_ValveBiped.mdl", description = [[Kickass must protect the civilians of FuzzyRP, you can only use your baton provided, Kickass does not shoot guns.]], weapons = {"weapon_crowbar"}, command = "kickass", max = 1, salary = 750, admin = 0, vote = true, hasLicense = true, customCheck = function(ply) return ply:GetNWString("usergroup") == "VIP" or ply:IsAdmin() end }) TEAM_VIPDEALER = AddExtraTeam( "VIP Weapons Dealer", Color(255, 140, 0, 255) , "models/player/eli.mdl", [[Illegally sell weapons to people, don't do it in public or else the police will have all rights to arrest you.]], {}, "VIPdealer", 1, 300,0,t
Do a print statement on your group variable; make sure that it is, in fact, all uppercase which prints out. Additionally, it may not matter but I've always accessed the group var using upper-case. I'm not sure if it's case-sensitive or not: [lua]local _group = ply:GetNWString( "UserGroup" );[/lua]
[lua]Default teams. Please do not edit this file. Please use the darkrpmod addon instead.[/lua] I think that is your problem right there... -edit- In response to the post above mine: I believe it does matter if it is uppercase or lowercase.
[QUOTE=Acecool;44208611]Do a print statement on your group variable; make sure that it is, in fact, all uppercase which prints out. Additionally, it may not matter but I've always accessed the group var using upper-case. I'm not sure if it's case-sensitive or not: [lua]local _group = ply:GetNWString( "UserGroup" );[/lua][/QUOTE] Could you give me an example of one of my classes I tried to make vip please?
First, use the darkrpmodification folder under garrysmod\addons\darkrpmodification\lua\darkrp_customthings\jobs.lua There you can do many things THAT WILL NOT HARM YOUR SERVER and all of which are easily fixed. there you can use this script [lua] Group = {"", "", "", ""} function table.contains(table, element) for _, value in pairs(table) do if value == element then return true end end return false end [/lua] for example I can do this [lua] BronzeVIPs = {"Bronze VIP", "Silver VIP", "Gold VIP", "Trial Moderatorz", "Moderator", "Trial Adminz", "Administrator", "S-Admin", "Developer", "Owner"} SilverVIPs = {"Silver VIP", "Gold VIP", "Trial Moderatorz", "Moderator", "Trial Adminz", "Administrator", "S-Admin", "Developer", "Owner"} GoldVIPs = {"Gold VIP", "Trial Moderatorz", "Moderator", "Trial Adminz", "Administrator", "S-Admin", "Developer", "Owner"} STAFF = {"Moderator", "Administrator", "S-Admin", "Developer", "Owner"} function table.contains(table, element) for _, value in pairs(table) do if value == element then return true end end return false end [/lua] after that I could then use a customCheck to make only those usergroups able to become those jobs for example [lua] TEAM_THIEF = DarkRP.createJob("[Bronze Only] Thief", { color = Color(0, 0, 0, 0), model = "models/player/robber.mdl", description = [[HEY]], weapons = {"lockpick", "keypad_cracker"}, command = "thief", max = 1, salary = 40, admin = 0, vote = false, customCheck = function(ply) return table.contains(BronzeVIPs, ply:GetUserGroup()) end, customCheckFailMsg = "This is the fail message" }) [/lua] Additionally you can make everyone able to view it and only the groups that you choose able to become it by using this customCheck = function(ply) return CLIENT or table.contains(BronzeVIPs, ply:GetUserGroup()) end, Edit: These tabs are not exactly correct :P my tab key was not working correctly, so you will have to re-add your tabs if this does not work.
[QUOTE=Vorpalbunny;44219813]-snip-[/QUOTE] [URL="http://wiki.garrysmod.com/page/table/HasValue"]http://wiki.garrysmod.com/page/table/HasValue[/URL]
[QUOTE=Vorpalbunny;44219813]-Redundant-[/QUOTE] While I agree that you "can" use such a method which is the same as table.HasValue as brandon pointed out; it is not cost efficient. If you were you were to implement something like that, read this and then let's apply it: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/benchmarking_tips/benchmarking_hud_stuff.lua[/url] [lua]// Define a GroupLevels table where we can define sort of a ranking system for players. // The best thing to do for something like this it use an ENUMERATION system ( Essentially creating CONSTANT GLOBAL variables with numbers whereby // other scripts would then use those to check for permissions like so: if ( ply:GroupLevel( ) >= GROUPLEVEL_ADMIN ) then ... end // GROUPLEVEL_ADMIN = 3; -- This number can be changed without needing to go through the rest of the script, so long as the original principle is retained with a higher-number as you rank up. // This could even be 1000, SuperAdmin could be 2000, Owner could be 9000, etc... and then moving numbers around would be easier. // EXAMPLE Group Names, normal strings do not need to be encased. A non-normal string is something which starts with a number, or has a space or other special character in it and does need to be encased such as in the example of "server owner" local GroupLevels = { user = 1; vip = 2; admin = 3; superadmin = 4; ["server owner"] = 5; // To allow the space, we need to encase it - the other strings don't need it } local PLAYER_META = FindMetaTable( "Player" ); function PLAYER_META:GroupLevel( ) // Get the group-name and convert it to all lower-case letters local _group = string.lower( self:GetNWString( "UserGroup" ) ); // Return the UserGroup Level based on our GroupLevels table // If the group name / level doesn't exist, return 0. IF you use ENUMERATION system, REPLACE 0 with USERLEVEL_GUEST or something. return GroupLevels[ _group ] || 0; end[/lua]
[QUOTE=Acecool;44219928]While I agree that you "can" use such a method which is the same as table.HasValue as brandon pointed out; it is not cost efficient. If you were you were to implement something like that, read this and then let's apply it: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/benchmarking_tips/benchmarking_hud_stuff.lua[/url] I am coming over from python (I still know my stuff about lua), and this worked on my server. Would you mind explaining why it is not "cost efficient". It is only a few lines of code + a customCheck.
[QUOTE=Vorpalbunny;44229148] I am coming over from python (I still know my stuff about lua), and this worked on my server. Would you mind explaining why it is not "cost efficient". It is only a few lines of code + a customCheck.[/QUOTE] What don't you understand? You're making a function that already exists, so why not just use the function that exists.. Besides the point, using direct access, like it's already been said, is A LOT faster than looping through table to find a value in lua. [URL="https://github.com/garrynewman/garrysmod/blob/36a6ea7788ef96bac3317839248fc486bdc57d7e/garrysmod/lua/includes/extensions/table.lua#L98"]https://github.com/garrynewman/garrysmod/blob/36a6ea7788ef96bac3317839248fc486bdc57d7e/garrysmod/lua/includes/extensions/table.lua#L98[/URL]
Sorry, you need to Log In to post a reply to this thread.