1. Post #1

    December 2012
    28 Posts
    I am trying to get one of my jobs to spawn with armor. But when I put it like this:
    Code:
    TEAM_CHIEF = AddExtraTeam("Civil Protection Chief", {
    	color = Color(20, 20, 255, 255),
    	model = "models/player/combine_soldier_prisonguard.mdl",
    	description = [[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]],
    	weapons = {"arrest_stick", "unarrest_stick", "weapon_mad_glock", "stunstick", "door_ram", "weaponchecker"},
    	command = "chief",
    	max = 1,
    	salary = 75,
    	admin = 0,
    	vote = false,
    	hasLicense = true,
    	chief = true,
    	NeedToChangeFrom = TEAM_POLICE,
            customCheck = function(ply)
    return ply:Team() == CHIEF then ply:SetArmor(100))}
    end
    	help = {
    		"Please don't abuse your job",
    		"When you arrest someone they are auto transported to jail.",
    		"They are auto let out of jail after some time",
    		"Type /warrant [Nick|SteamID|Status ID] to set a search warrant for a player.",
    		"Type /wanted [Nick|SteamID|Status ID] to alert everyone to a wanted suspect",
    		"Type /unwanted [Nick|SteamID|Status ID] to clear the suspect",
    		"Type /jailpos to set the jail position"
    	}
    })
    I just get an error

  2. Post #2
    circuitbawx's Avatar
    February 2013
    186 Posts
    Looks like you pulled the code from this thread here http://facepunch.com/showthread.php?t=1237404

    The reason why your code is giving you an error is because the code from that thread actually has a team called JUGG, while your class is called CHIEF. Look at your customCheck function.

    EDIT: I see that you've edited your post and changed JUGG to CHIEF, are you still getting an error?

    Edited:

    Code:
            customCheck = function(ply)
    return ply:Team() == CHIEF then ply:SetArmor(100))}
    end
    Look at that line. You're ending the customCheck function after you end the table declaration for the job, then placing the team help outside of it all because of the two characters at the end of the line. Try this.

    Code:
            customCheck = function(ply)
    return ply:Team() == CHIEF then ply:SetArmor(100)
    end
    Reply With Quote Edit / Delete Reply Windows 8 United States Show Events Disagree Disagree x 2 (list)

  3. Post #3

    December 2012
    28 Posts
    Even when edited I get this error

    Code:
    [ERROR] gamemodes/darkrp/gamemode/shared.lua:181: 'end' expected (to close 'function' at line 180) near 'then'
      1. unknown - gamemodes/darkrp/gamemode/shared.lua:0

  4. Post #4

    May 2012
    144 Posts
    Create an addon if you know how to, go inside lua/autorun and create a file then call it armor.lua

    open armor.lua and put this:

    hook.Add("PlayerSpawn", "ArmorTeam", function(ply)
            if ply:Team() == TEAM_CHIEF then
                 ply:SetArmor(100)
            end
    end)
    
    Reply With Quote Edit / Delete Reply Windows 7 Iran, Islamic Republic of Show Events Agree Agree x 1Winner Winner x 1 (list)

  5. Post #5
    circuitbawx's Avatar
    February 2013
    186 Posts
    The DarkRP wiki says that customCheck is meant to check to see if a user has a certain rank or not. I'd create a hook to check the player's team when they spawn, and if they're the Chief give them armor.

  6. Post #6

    May 2012
    144 Posts
    Looks like you pulled the code from this thread here http://facepunch.com/showthread.php?t=1237404

    The reason why your code is giving you an error is because the code from that thread actually has a team called JUGG, while your class is called CHIEF. Look at your customCheck function.

    EDIT: I see that you've edited your post and changed JUGG to CHIEF, are you still getting an error?

    Edited:

    Code:
            customCheck = function(ply)
    return ply:Team() == CHIEF then ply:SetArmor(100))}
    end
    Look at that line. You're ending the customCheck function after you end the table declaration for the job, then placing the team help outside of it all because of the two characters at the end of the line. Try this.

    Code:
            customCheck = function(ply)
    return ply:Team() == CHIEF then ply:SetArmor(100)
    end
    Custom check runs when player is opening the F4 Menu or changing their job to that job, It doesn't really affect changing player vars. Also please use lua tags ([.lua] without dot and [./lua] without dot)

  7. Post #7
    circuitbawx's Avatar
    February 2013
    186 Posts
    Custom check runs when player is opening the F4 Menu or changing their job to that job, It doesn't really affect changing player vars. Also please use lua tags ([.lua] without dot and [./lua] without dot)
    Just realized that right after you posted, didn't know there was a lua tag so thanks
    Reply With Quote Edit / Delete Reply Windows 8 United States Show Events Zing Zing x 1 (list)

  8. Post #8

    December 2012
    28 Posts
    I put it in lua/autorun, but they still don't spawn with armor.

  9. Post #9

    May 2012
    144 Posts
    As i said you have to create an addon, here is how to do that:

    Goto your addons folder
    Create a folder and call it armor
    go on it
    Create new text file and call it:
    addon.txt
    create a folder and name it lua
    go on lua, create a new folder and call it autorun
    then put the file you created on autorun.
    Reply With Quote Edit / Delete Reply Windows 7 Iran, Islamic Republic of Show Events Disagree Disagree x 1 (list)

  10. Post #10
    andre_bule
    andre_bule's Avatar
    January 2012
    168 Posts
    -SNIP-
    Someone already told you how.
    Reply With Quote Edit / Delete Reply Windows 7 Portugal Show Events Dumb Dumb x 1 (list)