1. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

v 2.5.x Giving jobs extra speed/armor/health/ect...

Discussion in 'Tutorials' started by D3Network, Feb 18, 2016.

  1. D3Network

    D3Network Member

    This is extremely easy. But I find people asking "How to give jobs extra armor" and stuff. So here's a quick post

    Code (Lua):

    TEAM_EXAMPLE = DarkRP.createJob("Example team", {
        color = Color(255, 255, 255, 255),
        model = {"models/player/Group03/Female_01.mdl", "models/player/Group03/Female_02.mdl"},
        description = [[This text will serve as the description of
    this team.]]
    ,
        weapons = {"weapon_p2282"},
        command = "example",
        salary = 45,
        vote = false,
        hasLicense = false,
        candemote = true,
        PlayerLoadout = function(ply)
            ply:SetRunSpeed(500)
            ply:SetArmor(100)

            return true
        end
    })
     

    Or, just create a new lua file called "jobfunctions" or whatever in darkrp modules. (Or modification)

    Then do
    Code (Lua):

    -- Name the function to what ever you want.
    local function jobfunshit(ply)
        -- If the player's team is police, then do this
        if ply:Team() == TEAM_POLICE then
            ply:SetRunSpeed(500)
            ply:SetArmor(100)
        end
    end

    hook.Add("PlayerLoadout", "jobsfunshit", jobfunshit)
     

    You can find the job/shipments/ect Fields/Hooks/etc. here.

    http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields


    You can also find functions/hooks for gmod at

    https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html -- Outdated, but I like better
    http://wiki.garrysmod.com/page/Main_Page -- All updated functions/hooks. I also use this.
     
    Last edited by a moderator: Feb 23, 2016
  2. Pab14567

    Pab14567 Well-Known Member

    Quick question, why don't you make it run for the entire police team table? ( unless if I'm reading it wrong or misunderstanding it )
     
  3. D3Network

    D3Network Member

    This is a tutorial for SPECIFIC jobs. If you wanted a special option (Extra walk speed) for all cops. Then just use

    ply:isCP( ) <--- Spaced that out because it looks like an oddly shaped 0. >_>
     
  4. Pab14567

    Pab14567 Well-Known Member

    Ah thank you for pointing it out, I must've read too quick and didn't understand it properly, sorry lol.

    Might want to make it as well So you can show people how it's done or "copy paste developers " ( don't get me wrong I started off copy pasting but I read it all and tried to understand how it worked and went together )
     
  5. (FPtje) Atheos

    (FPtje) Atheos Main Developer Staff Member

    I've edited the OP with some improvements. I added [ code=lua][/code ] tags and I added the PlayerLoadOut hook to your job function.
     
    D3Network and Pab14567 like this.
  6. [Xenetics]Apries

    [Xenetics]Apries New Member

    Very Thanks
     
  7. MaDmAxWeLl

    MaDmAxWeLl Member

    Why would you use PlayerLoadout and not PlayerSpawn?
     
  8. (FPtje) Atheos

    (FPtje) Atheos Main Developer Staff Member

    PlayerLoadOut is often called from within PlayerSpawn. It's more appropriate since you conceptually get your armor when you "load up" your weapons, and not when you spawn.

    It makes the thing work when PlayerLoadOut is being called outside of PlayerSpawn.
     
  9. [TF-O] MiK

    [TF-O] MiK New Member

    Is it possible to set XX amount of Ammo too?
     
  10. Pab14567

    Pab14567 Well-Known Member

    Code (Text):
     
    ammo = {
    ["pistol"] = 60,
    },
     
     
  11. [TF-O] MiK

    [TF-O] MiK New Member

    in "pistol" do I put the Entity of the Weapon or just Rifle|Pistol|Grenade & etc
     
  12. Pab14567

    Pab14567 Well-Known Member

  13. [TF-O] MiK

    [TF-O] MiK New Member

    So entity it is :p
     
  14. Pab14567

    Pab14567 Well-Known Member

    woops sorry misread the question, and you put the name of the ammo
     

Share This Page