Jump to content

cancelEvent in onPlayerChat


hemen

Recommended Posts

Function cancelevent doesn't works in onplayerchat. this functions sends two messages in chat. what should i do?

function vipMessage( message, messageType ) 
    if PlayerVIP[source] == 1 then 
        if messageType == 0 then 
            local r,g,b = getPlayerNametagColor ( source ) 
            outputChatBox ( getPlayerName ( source ) .. ": (VIP) #FFFFFF" .. message, source, r,g,b,true ) 
            cancelEvent() 
            outputServerLog( "CHAT: " .. getPlayerName ( source ).. ": " .. message ) 
            return 
        end 
    end 
end 
  
addEventHandler( "onPlayerChat", getRootElement(), vipMessage ) 

Link to comment

You are canceling the event after the outputChatBox function, it won't cancel anything, so use cancelEvent before.

So it will look like

  
function vipMessage( message, messageType ) 
    if PlayerVIP[source] == 1 then 
        if messageType == 0 then 
            cancelEvent() 
            local r,g,b = getPlayerNametagColor ( source ) 
            outputChatBox ( getPlayerName ( source ) .. ": (VIP) #FFFFFF" .. message, source,r,g,b,true ) 
            outputServerLog( "CHAT: " .. getPlayerName ( source ).. ": " .. message ) 
            return 
        end 
    end 
end 
addEventHandler( "onPlayerChat", getRootElement(), vipMessage ) 

Link to comment

<resource src="admin" startup="1" protected="0"/> 
<resource src="joinquit" startup="1" protected="0"/> 
<resource src="defaultstats" startup="1" protected="0"/> 
<resource src="parachute" startup="1" protected="0"/> 
<resource src="scoreboard" startup="1" protected="0"/> 
<resource src="interiors" startup="1" protected="0"/> 
<resource src="playerblips" startup="1" protected="0"/> 
<resource src="playercolors" startup="1" protected="0"/> 
<resource src="gang" startup="1" protected="0"/> 
     
<!-- play is the default freeroam gamemode. Remove the following line to prevent it from starting. -->        
<resource src="hemengm" startup="1" protected="0"/> 

As you look, there is not freeroam in my server. What about resource "gang" - it's my resource and he doesn't have function onPlayerChat.

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