Jump to content

cancelEvent in onPlayerChat


hemen

Recommended Posts

Posted

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 ) 

Posted

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 ) 

Posted

freeroam resource is coloring the chat (canceling original one and creating outputChatBox) - disable freeroam or remove these parts about chat coloring. some other resource can do it too - check them all if you are not using freeroam.

Posted

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

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

i tryed to put function in other places, but it doesn't change the situation.

Posted
hemen, moving function through resource won't help you. stop all resources, then start them one by one, searching for this one that is causing troubles. easy.

thank you for help. it was in the resource "playercolors" :)

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