Hello,
I just wrote a simple code with that AddCSLuaFile because I want it to autostart/download, when a player joins the server.
Now I dont now where to put this.
The Gmod wiki says this:
To make the script run automatically when the server starts, you simply put it into one of those
Folders:
For shared scripts ( Loaded on both client and server )
C:\Program Files\Steam\steamapps\common\garrysmod\garrysmod\lua\autorun
For client-only scripts ( Loaded only on client )
C:\Program Files\Steam\steamapps\common\garrysmod\garrysmod\lua\autorun\client
For server-only scripts ( Loaded only on server )
C:\Program Files\Steam\steamapps\common\garrysmod\garrysmod\lua\autorun\server
But how the fuck can it be automaticly downloaded from other users when I put it in my folder???
Thanks for help!
you dont put it in YOUR folder you put it in the SERVERS folder...
yeah I did
https://files.facepunch.com/forum/upload/305674/5476de86-2402-4f07-8bc4-dc41a1a7d472/Screenshot_17.png
Sooo I guess my code is wrong.
AddCSLuaFile("TestKeyPress.Lua")
function GM:KeyPress( ply, IN_USE )
ply:SetHealth( ply:Health() - 50 )
if (ply:Health() <= 0) then
ply:Kill()
end
end
AddCSLuaFile makes the client download the file, it does not auto execute it. Put it in autorun/client. Also instead of:
function GM:KeyPress
Use:
hook.Add("KeyPress", "insertfunnynamehere", function()
-- Code
end
Can u help me with this again?
AddCSLuaFile("server.lua")
hook.Add( "KeyPress", "keypress_use_hi", function(ply, key )
if (key == IN_USE) then
ply:SetHealth(ply:Health()-50)
elseif (ply:Health() <= 0) then
ply:Kill()
end
end
I guess its obs what I'm trying to do..
Just want to kill the player, when when he has less than 0 hp.
Why does it not work?
Less than 0 HP already kills the player :/ If you're looking to learn lua i suggest using Code Blue's tutorials instead of posting on the forums.
no its stops at 0 hp
It shouldn't. Validate the game files and check if any Addons are interfiering.
Sorry, you need to Log In to post a reply to this thread.