Lua Script

Hi, I dont know like are the functions of “lua” in gmod, but I want to create a script where messages death are randoms.

Example:

**local Msj = { ‘noob’, ‘fag’, ‘LOL’ }

function GM:PlayerDeath( victim, inflictor, attacker )
local text = Msj [ math.random ( 1, #Msj ) ]
if ( victim == attacker ) then
PrintMessage( HUD_PRINTTALK, victim:Name() … text )
else
PrintMessage( HUD_PRINTTALK, victim:Name() … " killed by " … attacker:Name() … " !")
end
end**

is understood?

PS: Sorry for my english :stuck_out_tongue:

http://facepunch.com/forumdisplay.php?f=65

Please use


 tags for code. Also, if you're not making a game-mode, use hook.Add. Also, don't return a non-nil value in any hook.Add unless you're overriding behavior or you can break functionality of game-modes.

Here you go: https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_death_message_system/sv_simple_death_message_system.lua.html Remove .html for .lua.

Please don’t bold your code, use the


 tags, as Acecool said and also help threads go in Developer Discussion, thanks!