yeah, we use this in stranded to prevent people from suiciding on PvP worlds to avoid being killed.
function GM:CanPlayerSuicide(ply)
if ply:InPvP() then
ply:SendMessage("Can not suicide here.",3,Color(200,0,0,255))
return false
end
return true
end
so if you wanted to prevent the player from suiciding all the time.. you could just put this in a file in autorun/server
function PreventSuicide(ply)
return false
end
hook.Add( "CanPlayerSuicide", "preventsuicide", PreventSuicide )
now assume you wanted to be able to change it with a con-variable... this would do the trick.
CreateConVar("gm_cansuicide","0",FCVAR_ARCHIVED)
function PreventSuicide(ply)
if GetConVarNumber("gm_cansuicide") == 0 then
return false
else
return true
end
hook.Add( "CanPlayerSuicide", "preventsuicide", PreventSuicide )
this would create a server variable that could be changed from the server rcon or with ulx rcon called gm_cansuicide 1/0 where 1 is yes.. and 0 is no.
*Disclaimer* Completely untested.. but should work.! =)