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.

DarkRP Maximum Health *FIXED*

Discussion in 'DarkRP Modding Questions & Help' started by konamikode, Dec 21, 2014.

  1. konamikode

    konamikode Member

    Is there any way to make a job have maximum health when they spawn? I want to set a certain job's health to
    be 200.

    Follow the instructions with playerloadout. If you want to make your other jobs have 200 health, then just make the "SetHealth(200)" into "SetHealth(100)"
     
    Last edited: Dec 23, 2014
  2. Matryan

    Matryan Well-Known Member

  3. konamikode

    konamikode Member

  4. Matryan

    Matryan Well-Known Member

    Paste the job that you did it for.
     
  5. konamikode

    konamikode Member

    Code (Text):
    TEAM_MUTANT = DarkRP.createJob("Mutant", {
            color = Color(47, 161, 81, 255),
            model = {
            "models/player/vad36alien/praetorian_ver2.mdl",
        },
            description = [[You are a mutant. Your natural habitat is in underground areas or dark areas. The
            humans hate you, so you hate them back.]],
            weapons = {"lockpick"},
            command = "mutant",
            max = 2,
            salary = 0,
            admin = 0,
            vote = true,
            hasLicense = false
            PlayerSpawn = function(ply) ply:SetHealth(200) end,
        })
     
  6. Cake

    Cake Active Member

    Try and add a delay in... Might be setting your health too early.
     
  7. konamikode

    konamikode Member

    Sorry, but how do I do that?
     
  8. Cake

    Cake Active Member

    From memory, may be a typo or something.
     
  9. Matryan

    Matryan Well-Known Member

    No, you're missing a comma after hasLicense. Like this:
    Code (Text):
    TEAM_MUTANT = DarkRP.createJob("Mutant", {
        color = Color(47, 161, 81, 255),
        model = {
            "models/player/vad36alien/praetorian_ver2.mdl",
        },
        description = [[You are a mutant. Your natural habitat is in underground areas or dark areas. The
            humans hate you, so you hate them back.]],
        weapons = {"lockpick"},
        command = "mutant",
        max = 2,
        salary = 0,
        admin = 0,
        vote = true,
        hasLicense = false,
        PlayerSpawn = function(ply) ply:SetHealth(200) end,
    })
    What Cake said --->
     
    Last edited: Dec 22, 2014
  10. Cake

    Cake Active Member

    Comma on last entry in a table is optional.
     
  11. konamikode

    konamikode Member

    Thank you! That worked!
     
  12. konamikode

    konamikode Member

    Actually, never mind! This causes MORE PROBLEMS.
    I can only get the health when I die, and when I switch to another job, the health is still there!
     
  13. stapler2025

    stapler2025 Member

    use PlayerLoadout rather than playerspawn
     
    konamikode likes this.
  14. Try this one

    TEAM_MUTANT = DarkRP.createJob("Mutant", {
    color = Color(47, 161, 81, 255),
    model = { "models/player/vad36alien/praetorian_ver2.mdl" },
    description = [[You are a mutant. Your natural habitat is in underground areas or dark areas. The
    humans hate you, so you hate them back.]],
    weapons = {"lockpick"},
    command = "mutant",
    max = 2,
    salary = 0,
    admin = 0,
    vote = true,
    hasLicense = false,
    PlayerLoadout = function(ply) ply:SetHealth(200) end
    })
     
  15. konamikode

    konamikode Member

    That solves one problem. But it doesn't solve that when you switch jobs, the health is still there.
     
  16. Cake

    Cake Active Member

  17. Matryan

    Matryan Well-Known Member

    Oh this is stuffed...
    I made a whole module for just this...:

    cl_givehealthonjob.lua
    Code (Text):

    hook.Add("teamchanged", "telltheserver", function()

        net.Start("changedmyteamonclient")
            net.WriteEntity(LocalPlayer())
        net.SendToServer()

    end
     
    sv_givehealthonjob.lua
    Code (Text):
    util.AddNetworkString("changedmyteamonclient")

    jobsneedhp = {
     
        TEAM_MUTANT,

    }

    net.Receive("changedmyteamonclient", function()

        ply = net.ReadEntity()

        if table.HasValue(jobsneedhp, ply:Team()) then
         
            ply:SetHealth(200)

        end

    end)
    God knows whether it's going to work. Goodluck.
     

Share This Page