Hi. I need to modify lua\includes\modules\player_manager.lua but I don't want it to affect other
gamemodes. I want to uninclude it, copy it to my gamemode folder, modify it and then include the modified version. Is there a way to do this?
Thanks.
Unfortunately, Garry's Mod loads everything to the global table, so you cannot simply uninclude it. You could load your gamemode in an environment that strips away the previous player_manager functions, or put your versions in a different table (player_manager2 or something).
Run a modified version of the file after it's loaded?
Gotta be honest though, I'm sure there are betters ways...
I tried this but I got errors.
But maybe my problem can be solved other way
I'm working on this part of the script:
function OnPlayerSpawn( ply )
local class = LookupPlayerClass( ply )
if ( !class ) then return end
ply:SetWalkSpeed( class.WalkSpeed)
ply:SetRunSpeed( class.RunSpeed )
ply:SetCrouchedWalkSpeed( class.CrouchedWalkSpeed )
ply:SetDuckSpeed( class.DuckSpeed )
ply:SetUnDuckSpeed( class.UnDuckSpeed )
ply:SetJumpPower( class.JumpPower )
ply:AllowFlashlight( class.CanUseFlashlight )
ply:SetMaxHealth( class.MaxHealth )
ply:SetHealth( class.StartHealth )
ply:SetArmor( class.StartArmor )
ply:ShouldDropWeapon( class.DropWeaponOnDie )
ply:SetNoCollideWithTeammates( class.TeammateNoCollide )
ply:SetAvoidPlayers( class.AvoidPlayers )
end
I want to change the max health of a player on spawn (to 500HP for example). But whenever I do it in
a hook it just doesn't seem to work. I noticed that modifying the values directly in player_manager
module does what I need, but the problem is I don't want to modify it. I tried calling the OnPlayerSpawn
function in the spawn hook to overwrite it but this part:
LookupPlayerClass( ply )
Is local to the module, so I can't really call it unless I copy the code, but as I said it keeps giving me errors.
Sorry, you need to Log In to post a reply to this thread.