• This Lua code will not work!
    6 replies, posted
I am trying to make a code to block suicide and only allow it to admins and super admins. this wouldn't work. Can someone help? [CODE] function GM:CanPlayerSuicide( ply ) if ply:IsAdmin() then ply:PrintMessage(HUD_PRINTTALK, "You commited suicide!") return true end ply:PrintMessage(HUD_PRINTTALK, "You were revived!") return false end [/CODE]
Do you get any server or client errors? Also, I suggest hooking it rather than overwriting a gamemode function
I get no errors also how would I hook it? Sorry I am kind of new to lua.
[QUOTE=awesomenessis;46210715]I get no errors also how would I hook it? Sorry I am kind of new to lua.[/QUOTE] [url=http://wiki.garrysmod.com/page/hook/Add]The wiki is always a helpful resource[/url].
[code]function GM:CanPlayerSuicide( ply ) if ply:IsAdmin() then ply:PrintMessage(HUD_PRINTTALK, "You commited suicide!") return true end ply:PrintMessage(HUD_PRINTTALK, "You were revived!") return false end hook.Add( "No suicide", "adminonly", CanPlayerSuicide )[/code] This is still not working!
[code]function CustomCanPlayerSuicide( ply ) if ply:IsAdmin() then ply:PrintMessage(HUD_PRINTTALK, "You commited suicide!") return true end ply:PrintMessage(HUD_PRINTTALK, "You were revived!") return false end hook.Add( CanPlayerSuicide, "adminonlysuicide", CustomCanPlayerSuicide )[/code]
The problem was i had the script in the client autorun not server lol.
Sorry, you need to Log In to post a reply to this thread.