• Set Health for player using steamID?
    12 replies, posted
Alright, I'm a noob at coding in lua but I would like to know if this would work to give 200 health to a player with that steam ID. [lua]function donatorHealth( ply ) if ply:SteamID == steamidhere then ply:SetMaxHealth(200) ply:SetHealth(200) end end function donatorHealth()[/lua]
FUUUUUUUUUUUUUUUU WIZARD! :P
[lua] hook.Add("PlayerSpawn", "donator_health_stuff", function(ply) if ply:SteamID() == <steamID> then ply:SetMaxHealth(200) ply:SetHealth(200) end end) [/lua] Your donatorHealth function takes a ply argument that you never provide.
[QUOTE=wizardsbane;35868877][lua] hook.Add("PlayerSpawn", "donator_health_stuff", function(ply) if ply:SteamID() == <steamID> then ply:SetMaxHealth(200) ply:SetHealth(200) end end) [/lua] Your donatorHealth function takes a ply argument that you never provide.[/QUOTE] This helped me also. How would you add multiple Steam Id's? Thanks again.
[QUOTE=Axton;35869030]This helped me also. How would you add multiple Steam Id's? Thanks again.[/QUOTE] [lua] hook.Add("PlayerSpawn", "donator_health_stuff", function(ply) local donators = { <steamID_1>, <steamID_2>, <etc> } if table.HasValue(donators, ply:SteamID()) then ply:SetMaxHealth(200) ply:SetHealth(200) end end) [/lua]
[QUOTE=wizardsbane;35869078][lua] hook.Add("PlayerSpawn", "donator_health_stuff", function(ply) local donators = { <steamID_1>, <steamID_2>, <etc> } if table.HasValue(donators, ply:SteamID()) then ply:SetMaxHealth(200) ply:SetHealth(200) end end) [/lua][/QUOTE] This is extremely weird, but when the code is added (init.lua) it messes the game up and spawns you with a weapon in a Deathrun Gamemode. We removed it and it worked perfectly, but why is it now working?
Check for errors in the console.
[QUOTE=Persious;35873195]Check for errors in the console.[/QUOTE] Alright, testing now. [editline]8th May 2012[/editline] [QUOTE=Persious;35873195]Check for errors in the console.[/QUOTE] There aren't any errors in the console... Is there any other way we can give donators 200 HP? Thanks!
What's your code. (post it with steamid's and all, we don't care)
I've tried the following... [lua] hook.Add("PlayerSpawn", "donator_health_stuff", function(ply) if ply:SteamID() == STEAM_0:0:31436899 then ply:SetMaxHealth(200) ply:SetHealth(200) end end)[/lua]
Put the SteamID in quotes. It's a string.
What admin mod are you using? I'll write you a quick code using that to not use shit coding.
[QUOTE=nofear1999;35877314]What admin mod are you using? I'll write you a quick code using that to not use shit coding.[/QUOTE] im using valve ban and kick system can you please rite it up for me 2 i have the same problem
Sorry, you need to Log In to post a reply to this thread.