Could someone please tell me why my code dosnt work
[CODE]hook.Add("PlayerSpawn", "RunCommand", function(ply)
if ply:SteamID() == "STEAM_0:1:50915956" then
ply:Run("ulx health 255")
elseif ply:SteamID() == "STEAM_0:0:68376050" then
ply:Run("ulx health 255")
end
end)[/CODE]
When i use this i dont get any errors in consol it just dosnt work! please help me fix!
Replace ply:Run with RunConsoleCommand("ulx health [steam id] 255). If that doesn't work look for more commands that will let you do this.
[QUOTE=sackcreator54;41876332]Replace ply:Run with RunConsoleCommand("ulx health [steam id] 255). If that doesn't work look for more commands that will let you do this.[/QUOTE]
RunConsolCommand dosnt work even to test it i did
ply:RunConsoleCommand("say testing")
and nothing came up in chat
ply:SetHealth(255)
[lua]
hook.Add("PlayerSpawn", "RunCommand", function(ply)
if ply:SteamID() == "STEAM_0:1:50915956" then
ply:ConCommand("ulx health 255")
elseif ply:SteamID() == "STEAM_0:0:68376050" then
ply:ConCommand("ulx health 255")
end
end)
[/lua]
code form of the above:
[code]hook.Add("PlayerSpawn", "RunCommand", function(ply)
if ply:SteamID() == "STEAM_0:1:50915956" then
RunConsoleCommand("ulx health STEAM_0:1:50915956 255")
elseif ply:SteamID() == "STEAM_0:0:68376050" then
RunConsoleCommand("ulx health STEAM_0:0:68376050 255")
end
end)[/code]
that is, of sackcreator54's post
Still none of these work tested all of them
Make sure you're running it serverside, and it's in lua/autorun/server/255hp(or whatever you want to call it).lua
[QUOTE=sackcreator54;41876498]Make sure you're running it serverside, and it's in lua/autorun/server/255hp(or whatever you want to call it).lua[/QUOTE]
Pretty sure its supposed to be in lua/autorun thats where i put ever other hook i made
Noooo... Put it in lua/autorun/server. That's your problem.
Why do all my other ones work in lua/autorun
I have no clue. Just put it in lua/autorun/server.
I'm pretty sure if you knew how to make it you wouldn't be asking for help then disagreeing with said help.
[code]Health4playar = {
["STEAM_0:1:50915956"] = 255,
["STEAM_0:0:68376050"] = 255,
["another steam id"] = 666, -- Remove these if you don't want to add more
["yet another steam id"] = 1337 -- this too
}
hook.Add("PlayerSpawn", "Health5players", function(ply)
for yolo, swag in pairs(Health4playar)do
if ply:SteamID() == yolo then
ply:SetHealth(swag)
end
end
end)
-- meh way of doin it.[/code]
[QUOTE=Ilyaaa;41876822]snnnnnniiiiippppp[/QUOTE]
This would be more appropriate for this kind of person:
[CODE]hook.Add("PlayerSpawn", "sawg", function(ply)
ply:Ban( 0, "I cAN CodE lUa" )
ply:Kick( "I cAN CodE lUa" )
end)[/CODE]
That table should be local, by the way. It's good practice not to use globals. Also, you're wasting processing time by using a loop. Just check the table using the SteamID as the key, if it exists then set their health to the value mapped to the key.
Sorry, you need to Log In to post a reply to this thread.