Setting hp on initial spawn? using ulx command?

Hi, I have this code:



function PlayerInitialSpawn(ply)
	ply:ConCommand("ulx hp"..ply.."250")
end


I understand that this should work, but I am unsure where to put it, as the gamemode I am using, hates being edited, it always spits out errors if I touch it.

so, where do I put it?

-Thanks

Matt

Use this in a hook rather than overwriting the function:

[lua]
hook.Add( “PlayerInitialSpawn”, “SetHP”, function(ply)
ply:ConCommand(“ulx hp “…ply:Nick()…” 250”)
end )
[/lua]

You will need to place this server sided, so somewhere in a file in garrysmod/lua/autorun/server

thankyou, it seems to run it, but it seems to use the players nick as the int, and im not sure why

I set it to use the players name as I believe that’s what ULX takes as a console command?

It would run the command “ulx hp Mrkrabz 250” in console which should work fine

yes, thats what I thought, it works when I manually type it in. I get the error in game:
Command “ulx hp”, argument #1: no targets found

Why ply:ConCommand if it’s serverside?
[lua]
hook.Add( “PlayerInitialSpawn”, “SetHP”, function(ply)
RunConsoleCommand(“ulx”, “hp” …ply:Nick()… " 250")
end )
[/lua]

that doesn’t seem to run at all

[lua]
hook.Add( “PlayerInitialSpawn”, “SetHP”, function(ply)
RunConsoleCommand(“ulx”, “hp” ,ply:Nick(),250)
end )
[/lua]

Runconsole takes parameters

-snip-

thankyou :slight_smile:

Why use ULX for this? Why not use ply:SetHealth(250) directly?

Maybe he wants to log this, it’s something…Silly but he asked that :v

Maybe he didn’t know that you can do this in other way or something.