Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Survivors don't have weapons #91

Open
thewsmred opened this issue Jan 11, 2023 · 1 comment
Open

Survivors don't have weapons #91

thewsmred opened this issue Jan 11, 2023 · 1 comment

Comments

@thewsmred
Copy link

It's there a way to make survivors spawn with weapons?

@Dadido3
Copy link
Owner

Dadido3 commented Jan 11, 2023

Survivor bots will get a random loadout like any other player that does not choose a loadout. This is done by ZS itself, so you need to modify the gamemode in some way. The logic that gives default or random loadouts starts here:

https://github.com/JetBoom/zombiesurvival/blob/310793aff3e200dd9e8d31b1f9241f4bce416c84/gamemodes/zombiesurvival/gamemode/init.lua#L2447-L2464

You could modify it directly, or you could add a hook to this GM event, see facepunch.com/gmod/hook.Add.

I can't test it right now, but a hook for this could look like this:

hook.Add("GiveDefaultOrRandomEquipment", "GiveSurvivorBotLoadout", function(pl)
    if not pl:IsBot() then return end
    if GAMEMODE.CheckedOut[pl:UniqueID()] then return end
    GAMEMODE.CheckedOut[pl:UniqueID()] = true
    
    pl:Give("weapon_zs_peashooter")
    pl:GiveAmmo(50, "pistol")
end)

This should give any survivor bot a peashooter and 50 ammo at the start of the round.

Save this as ...\garrysmod\lua\autorun\server\custom_bot_loadout.lua or something similar. (Or even better: Put it into your own custom addon.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants