GamerDeMTA Posted June 14, 2013 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?
uhm Posted June 14, 2013 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
GamerDeMTA Posted June 14, 2013 Author 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 )
PaiN^ Posted June 14, 2013 Posted June 14, 2013 addEventHandler( "onPlayerChat", root, function ( message ) if message:find( "lol" ) then cancelEvent( ) outputChatBox( "Message", root, 255, 255, 0, true ) end end )
GamerDeMTA Posted June 14, 2013 Author 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?
iPrestege Posted June 14, 2013 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 !
GamerDeMTA Posted June 14, 2013 Author Posted June 14, 2013 wait... the line 3 is good? LastMassage or u meant Message? ah and thanks for help
GamerDeMTA Posted June 14, 2013 Author 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?
iPrestege Posted June 14, 2013 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 )
GamerDeMTA Posted June 14, 2013 Author Posted June 14, 2013 And for put a Min. Length for a EDITBOX? a Min. Length not Max. U know Pls?
iPrestege Posted June 14, 2013 Posted June 14, 2013 if string.len ( guiGetText ( MyBox ) ) >= 3 then 3 For example .
Castillo Posted June 14, 2013 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.
PaiN^ Posted June 15, 2013 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 )
iPrestege Posted June 15, 2013 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 .. .
Castillo Posted June 15, 2013 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.
GamerDeMTA Posted June 15, 2013 Author 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.
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