Jump to content

How to do this?


Recommended Posts

Posted

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?

Posted

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 
) 

Posted
addEventHandler( "onPlayerChat", root, 
    function ( message ) 
        if message:find( "lol" ) then 
            cancelEvent( ) 
            outputChatBox( "Message", root, 255, 255, 0, true ) 
        end 
    end 
) 

Posted

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?

Posted

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 :) !

Posted
  
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?

Posted
  
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 
) 
  

Posted
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.

Posted
-- # 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 
) 

Posted
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 .. :wink: .

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...