Mefisto_PL Posted July 3, 2013 Share Posted July 3, 2013 (edited) Hi, I have a problem.. this function is bugged idk why.. I want to make that sound could be played one time on 15 seconds, but text will created and turn off my message from the chat when I used the command. ( for example: Mefisto_PL: !bitch ) Can you help me plz? SERVER-Side local LastUsedTime = 0 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 ) if getTickCount()-LastUsedTime < 15000 then --outputChatBox ( "[sERVER] Emm.. You can't do that now.. Wait 15 seconds for it.", source ) return end LastUsedTime = getTickCount() local source_name = getPlayerName( source ):gsub("#%x%x%x%x%x%x", "") if ( string.find ( message,"!bitch" ) ) and not ( string.find ( message," !bitch" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: You're son of a bitch !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/bitch.mp3" ) elseif ( string.find ( message,"!suck" ) ) and not ( string.find ( message," !suck" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: You suck..", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/suck.mp3" ) elseif ( string.find ( message,"!2suck" ) ) and not ( string.find ( message," !2suck" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: Hey ! You suck !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/suck(1).mp3" ) elseif ( string.find ( message,"!babies" ) ) and not ( string.find ( message," !babies" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: All of you are babies !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/babies.mp3" ) elseif ( string.find ( message,"!zag" ) ) and not ( string.find ( message," !zag" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: Zag Zag !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/zag.mp3" ) elseif ( string.find ( message,"!laugh" ) ) and not ( string.find ( message," !laugh" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: Muahahahahaha !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/laugh.mp3" ) elseif ( string.find ( message,"!noobwins" ) ) and not ( string.find ( message," !noobwins" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: Noob wins..", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/noobwins.mp3" ) elseif ( string.find ( message,"!noob" ) ) and not ( string.find ( message," !laugh" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: You're noob !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/noob.mp3" ) elseif ( string.find ( message,"!surprise" ) ) and not ( string.find ( message," !surprise" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: Surprise !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/surprise.mp3" ) elseif ( string.find ( message,"!awful" ) ) and not ( string.find ( message," !awful" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: Ahahaha.. That's awful !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/awful.mp3" ) elseif ( string.find ( message,"!goodmorning" ) ) and not ( string.find ( message," !goodmorning" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: Good morning !", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/goodmorning.mp3" ) elseif ( string.find ( message,"!wth" ) ) and not ( string.find ( message," !wth" ) ) then outputChatBox ( "*#FF9900" .. source_name .. "#FF4500: What the hell was that?!", getRootElement(), 255, 255, 255, true ) triggerClientEvent ( "startSound", getRootElement(), "sounds/hell.mp3" ) end cancelEvent() end addEventHandler ( "onPlayerChat", getRootElement(), soundCommands ) Edited July 4, 2013 by Guest Link to comment
Castillo Posted July 3, 2013 Share Posted July 3, 2013 The problem is that it's not letting you chat even if you don't say one of these commands? Link to comment
Mefisto_PL Posted July 3, 2013 Author Share Posted July 3, 2013 I don't get it. Explain please Link to comment
Castillo Posted July 3, 2013 Share Posted July 3, 2013 Well, I don't understand your problem, so I'm asking if that's what your problem is. Link to comment
Mefisto_PL Posted July 3, 2013 Author Share Posted July 3, 2013 I want to make that when I write my command ( for example !bitch ) then it plays sound and send message. But I want to block spam and make a limit that sound can be played once time in 15 seconds. Link to comment
Castillo Posted July 4, 2013 Share Posted July 4, 2013 Yes, I understood that part, but I don't understand the PROBLEM with your script. Link to comment
Mefisto_PL Posted July 4, 2013 Author Share Posted July 4, 2013 That blocked sounds.. yea great.. but I want to block sound and I want to make when sound is blocked then only text is showed. ( Oh god.. My english sucks so much :E ) Link to comment
Dealman Posted July 4, 2013 Share Posted July 4, 2013 Basically, whenever one of your commands with a prefix of "!" is entered, depending on which - a sound should be played. If the player tries to do another command under 15 seconds, only the text will be output - no sound, is this what you want? Link to comment
Mefisto_PL Posted July 4, 2013 Author Share Posted July 4, 2013 Oh god.. Yes ! This is what I mean . So anybody can help me? Link to comment
Castillo Posted July 4, 2013 Share Posted July 4, 2013 But, WHAT IS THE PROBLEM WITH YOUR CURRENT SCRIPT? you aren't answering my question at all, how do you expect to get help? I don't see the problem, your script is doing what you are saying, so what is the problem with it? If your english is that bad, then go to the Polish section and done. Link to comment
Mefisto_PL Posted July 4, 2013 Author Share Posted July 4, 2013 I want this: Player used a command and sound and text was outputed(I made it). If players try to use any of these commands again under 15 seconds then only text will be outputed, not sound(I made it in half.. text and sound isn't outputed) .. After 15 seconds: Sound and text outputed.. I think you understand. Link to comment
Castillo Posted July 4, 2013 Share Posted July 4, 2013 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. Link to comment
Mefisto_PL Posted July 4, 2013 Author Share Posted July 4, 2013 I love you Castillo Thanks for help me ! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now