See? now I understand you, here's an easier way of doing it
local LastUsedTime = 0
local commands =
{
[ "!bitch" ] = { "You're son of a bitch !", "bitch.mp3" },
[ "!suck" ] = { "You suck..", "suck.mp3" },
[ "!2suck" ] = { "Hey ! You suck !", "suck(1).mp3" },
[ "!babies" ] = { "All of you are babies !", "babies.mp3" },
[ "!zag" ] = { "Zag Zag !", "zag.mp3" },
[ "!laugh" ] = { "Muahahahahaha !", "laugh.mp3" },
[ "!noobwins" ] = { "Noob wins..", "noobwins.mp3" },
[ "!noob" ] = { "You're noob !", "noob.mp3" },
[ "!surpise" ] = { "Surprise !", "surprise.mp3" },
[ "!awful" ] = { "Ahahaha.. That's awful !", "awful.mp3" },
[ "!goodmorning" ] = { "Good morning !", "goodmorning.mp3" },
[ "!wth" ] = { "What the hell was that?!", "wth.mp3" }
}
function scriptStart ( )
outputChatBox ( "[sERVER] Sounds_Commands by Mefisto_PL activated ! Type !help for commands !", source, 255, 255, 255, true )
end
addEventHandler ( "onPlayerJoin", getRootElement(), scriptStart )
function helpCommand ( message, type )
if ( string.find ( message,"!help" ) ) and not ( string.find ( message," !help" ) ) then
outputChatBox ( "Sounds commands: !awful, !babies, !bitch, !laugh, !goodmorning, !noob, !noobwins, !suck, !2suck, !surprise, !wth, !zag", source )
end
end
addEventHandler ( "onPlayerChat", getRootElement(), helpCommand )
function soundCommands ( message, type )
local source_name = getPlayerName ( source ):gsub ( "#%x%x%x%x%x%x", "" )
local cmdData = commands [ message ]
if ( cmdData ) then
outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: ".. cmdData [ 1 ], getRootElement(), 255, 255, 255, true )
if ( getTickCount ( ) - LastUsedTime > 15000 ) then
triggerClientEvent ( "startSound", getRootElement(), "sounds/".. cmdData [ 2 ] )
end
LastUsedTime = getTickCount ( )
end
cancelEvent ( )
end
addEventHandler ( "onPlayerChat", getRootElement(), soundCommands )
Now you can add as much commands as you want, with an easy way.