EDIT: updated for ulx mod 1.1
This is a simple playsounds plugin for ulx mod. I got the idea from my old friend in an old dead clan who used to make plugins for amx in the cs 1.5 days.
--[[
ULX plugin by InstantDeath
if you use or run the copygun, you must reload this script after you are done loading/saving your props because
the script will override this one.
simply type lua_openscript ulx/ulx_playsounds.lua in console to reload script.
--]]
playsounds = true;
soundtext = "";
function eventPlayerSay(userid, strText, bTeam)
if(playsounds == true) then
local strCompare = string.lower(strText);
local crap = string.find(strCompare, "crap", 1, true);
local doh = string.find(strCompare, "doh", 1, true);
local lol = string.find(strCompare, "lol", 1, true);
local haha = string.find(strCompare, "haha", 1, true);
if (crap ~= nil) then
_PlaySound("mysound/crap.wav")
soundtext = "<PlaySound> " .. strText
return soundtext;
elseif (doh ~= nil) then
_PlaySound("mysound/doh.wav")
soundtext = "<PlaySound> " .. strText
return soundtext;
elseif (lol ~= nil) then
_PlaySound("mysound/lol.wav")
soundtext = "<PlaySound> " .. strText
return soundtext;
elseif (haha ~= nil) then
_PlaySound("mysound/haha.wav")
soundtext = "<PlaySound> " .. strText
return soundtext;
else
return strText;
end
else
return strText;
end
end
function cc_ulxPlaysounds()
if (playsounds == false) then
playsounds = true;
Msg("Playsounds Enabled.\n")
elseif (playsounds) then
playsounds = false
Msg("Playsounds Disabled.\n")
end
return true;
end
ULX_CONCOMMAND( "ulx_playsounds", cc_ulxPlaysounds, ACCESS_CUSTOM_A, " : enables or disables playsounds ",0, "ulx_playsounds")
Installation:
copy - paste then save as ulx_Playsounds.lua and save into the modules folder.
you may add, remove any sounds from the list, so long as the sound exists.
also, you need to include the files in the dynamic res list. otherwise everyone else will not be able to hear them.
anyone that wishes to improve my code may do so, so long as they give me credit.
edit: one more thing i forgot, if you have more than one entry that has the same word in it but different number of works, you must put the phrase of words that has the most FIRST in the elseif statement, otherwise your sounds wont play to the proper text.
ex. say i had the words "stupid" and "stupid idiot" for playsounds. i need to put "stupid idiot" before "stupid" otherwise the sound for "stupid" will play also for "stupid idiot" , make sense?