Jump to content

Help in Simple Script Please


Evil-Cod3r

Recommended Posts

Hey All i want Make a script that Make The Player Type only Team Chat !

This is My Script

function Extra () 
   cancelEvent () 
   outputChatBox("You Cant Type in Here Type Team Chat Only",source, 255,255,0) 
end 
addEventHandler( "onPlayerChat", getRootElement(), Extra) 

:D

Edited by Guest
Link to comment

So it Be Like this ?

function Extra (msg,msgType) 
    if msgType ~= 2 then 
    cancelEvent () 
    outputChatBox("You Cant Type in Here Type Team Chat Only",source,255,255,0) 
   end 
end 
addEventHandler( "onPlayerChat", getRootElement(), Extra) 
  
function mta () 
    outputChatBox ( "#FF0000Anti-Chat #00FF00", getRootElement(), 255, 255, 255, true ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), mta) 

Link to comment

it dont work i chat its output dont cancelEvent i even try this

function colouredChat ( message, theType ) 
    if theType == 0 then 
        cancelEvent() 
        outputChatBox("You Cant Type in Here Type Team Chat Only",source,255,0,0) 
end 
addEventHandler( "onPlayerChat", getRootElement(), colouredChat) 

Link to comment
addEventHandler( "onPlayerChat", getRootElement(), 
function (messageType) 
    if messageType == 0 then 
        outputChatBox("Sorry you cant use this chat, use team chat.", source, 255, 0, 0) 
        cancelEvent() 
    end 
end) 

Edited by Guest
Link to comment

Server

function noChat( msg,messageType ) 
    if messageType == 0 then 
        outputChatBox( "Sorry you cant use this chat, use team chat.", source, 255, 0, 0 ) 
        cancelEvent( ) 
    end 
end 
addEventHandler( "onPlayerChat", root, noChat ) 

Klesh,Your code is wrong.

P.S Tabulate code in next time.

Link to comment

No problem :)

P.S Its Possble to add anti-Flood for it if he type 5 time give him mute 10 sec ?

Yeah

Example

function noChat( msg,messageType ) 
    if messageType == 0 then 
        if not tCounts[ source ] then 
            tCounts[ source ] = 0 
        end 
        if tCounts[ source ] ~= Max then 
            tCounts[ source ] = tCounts[ source ] + 1 
            outputChatBox( "Sorry you cant use this chat, use team chat.", source, 255, 0, 0 ) 
            if isTimer( tTimerInterv[ source ] ) then killTimer( tTimerInterv[ source ] ) end 
            tTimerInterv[ source ] = setTimer( 
                function( player ) 
                    tCounts[ player ] = 0 
                end, 
            interv*1000, 
            1,source )   
        else 
            if not isPlayerMuted( source ) then 
                setPlayerMuted( source,true ) 
                outputChatBox( "Sorry you are muted.", source, 255, 0, 0 ) 
                if isTimer( tTimer[ source ] ) then killTimer( tTimer[ source ] ) end 
                tTimer[ source ] = setTimer( 
                    function( player ) 
                        outputChatBox( "You are unmuted.", player, 255, 0, 0 ) 
                        setPlayerMuted( player,false ) 
                        tCounts[ player ] = 0 
                    end, 
                Time*1000,   
                1,source ) 
            end  
        end  
        cancelEvent( ) 
    end 
end 
addEventHandler( "onPlayerChat", root, noChat ) 
  
addEventHandler( "onPlayerQuit", root,  
    function( ) 
        tTimerInterv[ source ] = nil 
        tTimer[ source ] = nil 
        tCounts[ source ] = nil 
    end 
)    

P.S Need acl rights.

Update code.

Edited by Guest
Link to comment
Anyways, always i post the first fix script and later give the thanks to the last make the fix. :x
addEventHandler( "onPlayerChat", getRootElement(), -- use root  in next time 
function (messageType) -- first argument is message second is message type see on wiki. 
    if messageType == 0 then -- I think you understand problem. 
        outputChatBox("Sorry you cant use this chat, use team chat.", source, 255, 0, 0) 
        cancelEvent() 
    end 
end) 

In first time you post code with syntax error.And i at once write my code.

Link to comment

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