Author Topic: Playsounds plugin  (Read 18501 times)

0 Members and 1 Guest are viewing this topic.

Offline InstantDeath

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Playsounds plugin
« on: January 30, 2006, 06:30:25 PM »
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.

Code: [Select]
--[[
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?
« Last Edit: February 10, 2006, 06:33:25 PM by InstantDeath »

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: Playsounds plugin
« Reply #1 on: January 30, 2006, 10:04:33 PM »
looks good, but definately edit the dirty words out. I myself don't have a problem with them, but the devs frown upon them and you may have the plugin removed.


Offline InstantDeath

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Re: Playsounds plugin
« Reply #2 on: January 31, 2006, 12:36:49 PM »
sure. i just fixed it now... i forgot to remove the cuss words. sorry.

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: Playsounds plugin
« Reply #3 on: January 31, 2006, 03:40:25 PM »
np, looks good.


Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Playsounds plugin
« Reply #4 on: February 02, 2006, 05:46:44 PM »
Good work!
Experiencing God's grace one day at a time.

Offline darkdeath

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 2
Re: Playsounds plugin
« Reply #5 on: February 07, 2006, 11:41:12 AM »
looks good but it says this:


this is what my forcedownload looks like:
Quote
//ULX-Dynamic res generator
//Put files you wish to force the client to download in this file, seperated by newlines.
//For example, you might put "sound/supafly.mp3" in here, make sure it has the quotes.
//DO NOT CHANGE THESE COMMENTS.
"sound/d-sounds/bye.mp3"
"sound/d-sounds/english.wav"
"sound/d-sounds/haha.wav"
"sound/d-sounds/lol.mp3"

in my sounds folder is another folder d-sounds in the folder are afcourse the :
bye.mp3
english.wav
haha.wav
lol.mp3

Then here is my ulx_playsounds.lua:
Quote
playsounds = true;
soundtext = "";


function eventPlayerSay(userid, strText, bTeam)
if(playsounds == true) then

local strCompare = string.lower(strText);
local bye = string.find(strCompare, "bye", 1, true);
local english = string.find(strCompare, "english", 1, true);
local haha = string.find(strCompare, "haha", 1, true);
local lol = string.find(strCompare, "lol", 1, true);



if (bye ~= nil) then
_PlaySound("d-sounds/bye.mp3")
soundtext = "<PlaySound> " .. strText
return soundtext;
elseif (english ~= nil) then
_PlaySound("d-sounds/english.wav")
soundtext = "<PlaySound> " .. strText
return soundtext;
elseif (haha ~= nil) then
_PlaySound("d-sounds/haha.wav")
soundtext = "<PlaySound> " .. strText
return soundtext;
elseif (lol ~= nil) then
_PlaySound("d-sounds/lol.mp3")
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 ",1, "ulx_playsounds")

and this is what my ulx_init.lua looks like:
Quote
_OpenScript( "ulx/ulx_defines.lua" ) -- ULX defines
_OpenScript( "ulx/ulx_lib.lua" ) -- ULX helper functions
_OpenScript( "ulx/ulx_base.lua" ) -- Base functions needed by ULX
_OpenScript( "ulx/ulx_config.lua" ) -- ULX configuration
_OpenScript( "ulx/ulx_users.lua" ) -- This is where our users for ULX are kept
_OpenScript( "ulx/ulx_util.lua" ) -- ULX utility functions ( IE ulx_who )
_OpenScript( "ulx/ulx_fun.lua" ) -- Fun commands ( IE ulx_slay )
_OpenScript( "ulx/ulx_menu_base.lua" ) -- Do I really need to explain this?
_OpenScript( "ulx/ulx_menus.lua" ) -- ULX menus
_OpenScript( "ulx/ulx_props.lua" ) -- Prevents prop spamming and protects props
_OpenScript( "ulx/ulx_end.lua" ) -- Has some clean up functions, sorts the help
_OpenScript( "newscripts/chimneyblock.lua" ) -- For ppl who try to spawn a chimney *NEW* 
_OpenScript( "newscripts/invisible.lua" ) -- Invisible mode 1,2,3 *NEW* 
_OpenScript( "newscripts/textfloatuncvar.lua" ) -- Text floating above your head *NEW*
_OpenScript( "newscripts/playsounds.lua" ) -- Play sounds in game

i don't get what the problem is !
« Last Edit: February 11, 2006, 03:36:56 AM by darkdeath »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Playsounds plugin
« Reply #6 on: February 10, 2006, 02:13:30 PM »
Please update this plugin to use ULX v1.1's new module system
Experiencing God's grace one day at a time.

Offline InstantDeath

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Re: Playsounds plugin
« Reply #7 on: February 10, 2006, 05:47:27 PM »
sure... ill see what i can do.

and darkdeath, why do you have a 1 added to the the variable soundtext? thats not needed and could have the wrong effect.
« Last Edit: February 10, 2006, 05:49:19 PM by InstantDeath »

Offline darkdeath

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 2
Re: Playsounds plugin
« Reply #8 on: February 11, 2006, 03:14:00 AM »
yes maby... ill try again :)...
and thx for updating :)

EDIT:
still aint working !
same message and same fault
« Last Edit: February 11, 2006, 03:37:20 AM by darkdeath »

Offline InstantDeath

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Re: Playsounds plugin
« Reply #9 on: February 20, 2006, 07:12:04 PM »
try putting the script in the modules folder instead of adding the script to the ulx init.

Offline dragster112

  • Newbie
  • *
  • Posts: 10
  • Karma: 0
Re: Playsounds plugin
« Reply #10 on: April 16, 2006, 05:09:40 PM »
Doesnt work i type doh in and it says were the text cums up
<PlaySound>doh
but nuthing happens
« Last Edit: April 16, 2006, 06:03:18 PM by dragster112 »
i rock woohooo

Offline InstantDeath

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Re: Playsounds plugin
« Reply #11 on: June 15, 2006, 06:11:37 PM »
make sure you put the file in the right place and that it points to the same place.

Offline Griff

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
Re: Playsounds plugin
« Reply #12 on: August 01, 2006, 02:20:16 PM »
can anyone re-script this or edit it for compatable use with V2 please? looks realy good.

Offline Silver

  • Newbie
  • *
  • Posts: 8
  • Karma: 1
Re: Playsounds plugin
« Reply #13 on: August 01, 2006, 06:49:10 PM »
This is fun to do. I like to annoy people in my server typing the same sound over and over again.  :)

Offline Griff

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
Re: Playsounds plugin
« Reply #14 on: August 06, 2006, 02:34:19 PM »
Code: [Select]
--[[
ULX.CONCOMMAND( "ulx playsounds", cc_ulxPlaysounds, ACCESS_CUSTOM_A, " : enables or disables playsounds ",0, "ulx playsounds")

How do i make this line commpatible with ULX v2???

also. is there any way to make it so that i can define Permissions for certain sounds. and maybe add a ammount of sounds that can be played by a certain player in a certain amount of time?

Thanks for any help.