Author Topic: Custom Job Help  (Read 153 times)

0 Members and 1 Guest are viewing this topic.

Offline Merlin

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
  • Owner of MythaneRP on Gmod
    • MythaneRP-Forums
Custom Job Help
« on: September 12, 2018, 11:07:13 AM »
So the following arguments of the PlayerSpawn function (SetWalkSpeed, SetRunSpeed & SetJumpPower) are not working for any custom job after you spawn as the job, they just revert to default.

I have no custom spawn points system/script/addon.

Here's an example of a job with the PlayerSpawn function and arguments: (Due note that the HP & Armor arguments work as intended)

Code: [Select]
TEAM_CUSTOMK1 = DarkRP.createJob("Aimbotting Hacker", {
    color = Color(196, 7, 54, 255),
    model = {"models/player/baldi/baldi.mdl"},
    description = [[The Aimbotting Hacker, very quick and nimble, but more importantly than that, THE MOST BROKEN DARKRP JOB YOU'LL EVER SEE! Given 100 starting HP, no armor, super speed and super jump power and the most OP gun you'll see, the Aimbot Assault Rifle! Running from this monster will not help you, either attempt to kill him or take the bullet to the face! This job can start Mass Terrors just like the Taliban Terrorist but he's always KOS.

This is [Owner] Merlin's Custom Psycho Killer/Terrorist Job!

You can donate for a Custom Job yourself by typing !donate and going to the website given to you.]],
    weapons = {"weapon_aimbot_ar2", "pack_sswep_prize", "pack_sswep_puppet", "pack_sswep_baldi", "pack_sswep_baldi2", "pack_sswep_filename", "pack_sswep_sweep", "pack_sswep_bully", "pack_sswep_music", "pack_sswep_playtime", "pack_sswep_principal", "pack_sswep_principal2", "pack_sswep_ruler"},
    command = "aimbotter",
    max = 1,
    salary = 0,
    admin = 0,
    vote = false,
    hasLicense = true,
    candemote = false,
    category = "Custom Jobs",
PlayerLoadout = function(ply) return true end,
PlayerSpawn = function(ply)
        ply:SetMaxHealth(100)
        ply:SetHealth(100)
ply:SetArmor(0)
        ply:SetWalkSpeed(100)
        ply:SetRunSpeed(1750)
        ply:SetJumpPower(500)
    end,
    customCheck = function(ply) return CLIENT or
        table.HasValue({"STEAM_0:0:89866500"}, ply:SteamID())
    end,
    CustomCheckFailMsg = "Merlin's Custom Job, check !donate to get yours!",
})

Offline iViscosity

  • Hero Member
  • *****
  • Posts: 768
  • Karma: 50
Re: Custom Job Help
« Reply #1 on: September 12, 2018, 11:22:30 AM »
Now, I'd like to preface this with the fact that I don't know a ton about DarkRP. This is just information I found while looking up info.


I believe DarkRP's PlayerSpawn hook is overwriting this.

https://github.com/FPtje/DarkRP/blob/c25bc7f13d693f87353b78b18c986c2c3315b5f9/gamemode/modules/base/sv_gamemode_functions.lua#L743

That line calls this function: https://github.com/FPtje/DarkRP/blob/fd95cf68e6a01a1b0522c4a989d4512fc0fb202d/gamemode/modules/base/sv_util.lua#L157

Which overwrites walk speed, run speed, and jump power.

Looking at the lines:

Code: Lua
  1.     self:SetWalkSpeed(playerClass.WalkSpeed >= 0 and playerClass.WalkSpeed or GAMEMODE.Config.walkspeed)
  2.     self:SetRunSpeed(playerClass.RunSpeed >= 0 and playerClass.RunSpeed or (self:isCP() and GAMEMODE.Config.runspeedcp or GAMEMODE.Config.runspeed))
  3.     -- ...
  4.     -- Omitted for lack of relevance
  5.     -- ...
  6.     self:SetJumpPower(playerClass.JumpPower)
  7.  

(self referring to the player here), you should be able to include the "RunSpeed", "WalkSpeed", and "JumpSpeed" values into your actual team.


If that DOESN'T work, which -- after looking more into player_manager in the Sandbox gamemode -- might not, you could always try adding a timer to your PlayerSpawn to make sure those values are set after DarkRP sets them.


EDIT: Actually, my first solution there won't help. According to this line: https://github.com/FPtje/DarkRP/blob/c25bc7f13d693f87353b78b18c986c2c3315b5f9/gamemode/modules/base/sv_gamemode_functions.lua#L753, DarkRP already calls your custom PlayerSpawn hook if it exists... I'm not sure, in that case, since setting HP and armour work properly.
« Last Edit: September 12, 2018, 11:24:36 AM by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me a PM or Join my Discord!.
--==[ Links ]==--
Steam
YouTube
Steam Group (feel free to join!)
Discord

Quote from: Steve Jobs
Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.

Offline Merlin

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
  • Owner of MythaneRP on Gmod
    • MythaneRP-Forums
Re: Custom Job Help
« Reply #2 on: September 12, 2018, 11:53:46 AM »
Then why isn't the SetWalkSpeed, SetRunSpeed & SetJumpPower functions not working?

Offline iViscosity

  • Hero Member
  • *****
  • Posts: 768
  • Karma: 50
Re: Custom Job Help
« Reply #3 on: September 12, 2018, 11:59:04 AM »
That's what I said... I'm not sure.

Maybe someone with more DarkRP knowledge could help you, because if I had to guess it's because of that. Do you know if you're getting any errors at all?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me a PM or Join my Discord!.
--==[ Links ]==--
Steam
YouTube
Steam Group (feel free to join!)
Discord

Quote from: Steve Jobs
Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.

Offline Merlin

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
  • Owner of MythaneRP on Gmod
    • MythaneRP-Forums
Re: Custom Job Help
« Reply #4 on: September 12, 2018, 12:01:36 PM »
I would've most likely solved the problem if I were getting any lua errors but alas i'm not getting any ;-;

Offline Merlin

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
  • Owner of MythaneRP on Gmod
    • MythaneRP-Forums
Re: Custom Job Help
« Reply #5 on: September 14, 2018, 02:39:42 PM »
Wait, can it be that PlayerLoadout is being called before PlayerSpawn and overriding the function?

Is there a way to add the PlayerLoadout function as an argument to the PlayerSpawn function?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2640
  • Karma: 413
    • |G4P| Gman4President
Re: Custom Job Help
« Reply #6 on: September 14, 2018, 03:04:51 PM »
Put this inside of playerspawn

hook.Call( "PlayerLoadout", GAMEMODE, ply )

that calls the gamemode's PlayerLoadout hook on the ply player object.

Offline Merlin

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
  • Owner of MythaneRP on Gmod
    • MythaneRP-Forums
Re: Custom Job Help
« Reply #7 on: September 14, 2018, 04:35:31 PM »
Nope, that didn't resolve my issue.

And I just noticed another Custom Job doesn't have the PlayerLoadout function and the Ply:SetRunSpeed, Ply:SetWalkSpeed & Ply:SetJumpPower arguments don't work.

Is there a way to force a ULX command on a job when they spawn? If I can do that then I can force the ULX runspeed, walkspeed and jumppower commands on a job when they spawn.