Maybe this will help get you into trying to learn lua for yourself. A lot of stuff like this I don’t believe is worth being paid for so you should try to save yourself some money and use this to learn from.
This is a working script that prevents players from being hurt after they spawn for the set amount of time.
[lua]
MyGamemode = {} --This is a table, it will hold all of our custom functions or variables. This is not needed, but makes things look more clean and helps prevent conflicts.
MyGamemode.SpawnProtection_Length = 4 --How long before the player will be invicible for after they spawn.
--------------------Anti Spawn Kill-----------------------------
–These two functions are helpers to make the ‘MyGamemode.Anti_SpawnKill’ function work properly.
MyGamemode.Remove_PlayerInvincibility = function(pl)
if pl:IsValid() then --We want to make sure the player is still in the server before we try to do stuff to them.
pl:SetNetworkedBool(“PlayerInvincible”, false) --This sets a variable to the player, this way we can adjust it in other functions if needed.
pl:PrintMessage(HUD_PRINTCENTER, “Spawn protection has been removed!”) --This will print a message to the center of the players screen.
end
end
MyGamemode.Disable_Players_Damage = function(pl, attacker)
if pl:GetNetworkedBool(“PlayerInvincible”) then --If the ‘PlayerInvincible’ variable is set to true, do not allow the player to get hurt.
return false --Returning false means the ‘PlayerShouldTakeDamage’ function will stop dead in its tracks, in this case the player will not take damage.
end
end
hook.Add(“PlayerShouldTakeDamage”, “Disable players from being hurt when their [PlayerInvincible] variable is set true”, MyGamemode.Disable_Players_Damage)
–This is where the magic happens.
MyGamemode.Anti_SpawnKill = function(pl) --This is one of our custom functions, it will make players invincible for a period of time after they spawn.
pl:SetNetworkedBool(“PlayerInvincible”, true)
pl:PrintMessage(HUD_PRINTCENTER, “Spawn protection added for “…tostring(MyGamemode.SpawnProtection_Length)…” seconds!”)
timer.Simple(MyGamemode.SpawnProtection_Length, function() MyGamemode.Remove_PlayerInvincibility(pl) end)
--This timer will start, then run the 'MyGamemode.Remove_PlayerInvincibility' function after the timer length is reached.
end
hook.Add( --This is a hook, it makes the function ‘to be hooked’ run after the main function is completed.
“PlayerSpawn”, --This is the main function we want our custom function hooked to. ‘PlayerSpawn’ is a function that already exists in Garry’s Mod and runs when the player spawns.
“Make players invincible for a period of time after they spawn.”, --Description of our hook, this is to help make hooks unique so they do not overlap each other.
MyGamemode.Anti_SpawnKill --Name of our custom function to run when the ‘PlayerSpawn’ function is completed.
)
[/lua]
[editline]29th April 2013[/editline]
Your bibles for learning
You want to use an lua editor, otherwise writing scripts will be miserable
functions
variables
tables
This is more specific for understanding the script I just provided for you.