GamerDeMTA Posted June 14, 2013 Share Posted June 14, 2013 I wanna execute a function if a message = lol. I know how to do it, but I want to do it also if the message is lollll it executes and if the message is #ff0000lol too. understand? Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 I didn't understand what you mean . Link to comment
uhm Posted June 14, 2013 Share Posted June 14, 2013 (edited) like w/ onPlayerChat but instead of if msg=lol do like if msg:find("lol")~=nil * untested huehue Edited June 14, 2013 by Guest Link to comment
GamerDeMTA Posted June 14, 2013 Author Share Posted June 14, 2013 Could u give me an example with this? addEventHandler ( "onPlayerChat", root, function ( message ) if ( message == "lol" ) then cancelEvent ( ) outputChatBox("Message",root,255,255,0,true) end end ) Link to comment
PaiN^ Posted June 14, 2013 Share Posted June 14, 2013 addEventHandler( "onPlayerChat", root, function ( message ) if message:find( "lol" ) then cancelEvent( ) outputChatBox( "Message", root, 255, 255, 0, true ) end end ) Link to comment
GamerDeMTA Posted June 14, 2013 Author Share Posted June 14, 2013 ah thanks and... do you know how to do this? I wanna do that, if the player says "lol" 4 times in a row (if the messages who the player say contains "lol") he gets muted for 2 mins (120000ms). How to? Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 Hello Gamer Try this : -- # Server Side ! local LastMassage = 0 addEventHandler('onPlayerChat',root, function ( message ) if string.find ( message,'lol' ) then LastMassage = LastMassage +1 if LastMassage == 4 then setPlayerMuted ( source,true ) outputChatBox('You said lol 4 times you are muted now!',source,255,0,0) setTimer ( function ( source ) setPlayerMuted ( source,false ) LastMassage = 0 outputChatBox('You are unmuted now!',source,0,255,0) end,120000,1,source ) end end end ) Add the resource to the acl for the mute function ( resource.ResourceName ) ! And try it and tell me ! Link to comment
GamerDeMTA Posted June 14, 2013 Author Share Posted June 14, 2013 wait... the line 3 is good? LastMassage or u meant Message? ah and thanks for help Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 (edited) Yes . Edited June 14, 2013 by Guest Link to comment
GamerDeMTA Posted June 14, 2013 Author Share Posted June 14, 2013 addEventHandler("onClientRender", root, function() dxDrawText("lol", 162, 131, 325, 163, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, true, false, false) dxDrawText("!!", 421, 131, 584, 163, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, true, false, false) dxDrawText("d", 163, 342, 417, 363, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, true, false, false) dxDrawText("draw.", 166, 363, 541, 381, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, true, false, false) end ) Do u know how to use drawText ONLY when the window "wnd" is opened? Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 addEventHandler("onClientRender", root, function ( ) if guiGetVisible ( MyWindow ) then dxDrawText("lol", 162, 131, 325, 163, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, true, false, false) dxDrawText("!!", 421, 131, 584, 163, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, true, false, false) dxDrawText("d", 163, 342, 417, 363, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, true, false, false) dxDrawText("draw.", 166, 363, 541, 381, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, true, false, false) end end ) Link to comment
GamerDeMTA Posted June 14, 2013 Author Share Posted June 14, 2013 And for put a Min. Length for a EDITBOX? a Min. Length not Max. U know Pls? Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 if string.len ( guiGetText ( MyBox ) ) >= 3 then 3 For example . Link to comment
Castillo Posted June 14, 2013 Share Posted June 14, 2013 Hello Gamer Try this : -- # Server Side ! local LastMassage = 0 addEventHandler('onPlayerChat',root, function ( message ) if string.find ( message,'lol' ) then LastMassage = LastMassage +1 if LastMassage == 4 then setPlayerMuted ( source,true ) outputChatBox('You said lol 4 times you are muted now!',source,255,0,0) setTimer ( function ( source ) setPlayerMuted ( source,false ) LastMassage = 0 outputChatBox('You are unmuted now!',source,0,255,0) end,120000,1,source ) end end end ) Add the resource to the acl for the mute function ( resource.ResourceName ) ! And try it and tell me ! This will make it a global variable, meaning that if another player says "lol", it'll increase the variable. He should use a table instead. Link to comment
GamerDeMTA Posted June 14, 2013 Author Share Posted June 14, 2013 then can u say me a code for that? Link to comment
PaiN^ Posted June 15, 2013 Share Posted June 15, 2013 -- # Server Side ! local LastMassage = { } addEventHandler('onPlayerChat',root, function ( message ) if string.find ( message,'lol' ) then if LastMassage[source] then LastMassage[source] = LastMassage[source] + 1 else LastMassage[source] = 1 end if LastMassage[source] == 4 then setPlayerMuted ( source,true ) outputChatBox('You said lol 4 times you are muted now!',source,255,0,0) setTimer ( function ( source ) setPlayerMuted ( source,false ) LastMassage[source] = nil outputChatBox('You are unmuted now!',source,0,255,0) end,120000,1,source ) end end end ) Link to comment
iPrestege Posted June 15, 2013 Share Posted June 15, 2013 Hello Gamer Try this : -- # Server Side ! local LastMassage = 0 addEventHandler('onPlayerChat',root, function ( message ) if string.find ( message,'lol' ) then LastMassage = LastMassage +1 if LastMassage == 4 then setPlayerMuted ( source,true ) outputChatBox('You said lol 4 times you are muted now!',source,255,0,0) setTimer ( function ( source ) setPlayerMuted ( source,false ) LastMassage = 0 outputChatBox('You are unmuted now!',source,0,255,0) end,120000,1,source ) end end end ) Add the resource to the acl for the mute function ( resource.ResourceName ) ! And try it and tell me ! This will make it a global variable, meaning that if another player says "lol", it'll increase the variable. He should use a table instead. I know that , It's an example we don't accept requests here .. . Link to comment
Castillo Posted June 15, 2013 Share Posted June 15, 2013 Well, I actually think that when you give an "example" as you say, it should do what he wanted, else, he'll later think that he has to use variables and not tables, so is an incomplete example. Link to comment
GamerDeMTA Posted June 15, 2013 Author Share Posted June 15, 2013 the code of Pain is good ? because its the same as Prestege's. can you please give me a good example? This is a bit hard for 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