Jump to content

Chatmessage doesn´t disappear with cancelEvent() in mainchat


Adde

Recommended Posts

Posted

Hello, I have this function to set (Staff) infront of the name everytime a HeadAdmin ( atm ) write in chat. The message disappears in teamchat and shows (Staff)NameTag: message, but in mainchat the original and this chat message appears. Why doesn´t cancelEvent() work in mainchat? :/

function staffchat(message, messageType) 
if messageType == 0 or messageType == 2  then 
if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("HeadAdmin")) then 
cancelEvent() 
local red, green, blue = getPlayerNametagColor(source) 
        outputChatBox("(Staff)"..getPlayerName(source)..": "..message, root, red, green, blue, true ) 
end 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), staffchat) 

Posted (edited)

Nope

I changed it so (TEAM) is visible in team chat, and it is still same problem. I can´t find out what´s the problem. The script is perfect and no resource that manage chatBox anyway is running..

function staffchat(message, messageType) 
if messageType == 0  then 
if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("HeadAdmin")) then 
cancelEvent() 
local red, green, blue = getPlayerNametagColor(source) 
outputChatBox("*Staff*"..getPlayerName(source)..": #FFFFFF"..message, root, red, green, blue, true ) 
end 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), staffchat) 
  
function staffchat2(message, messageType) 
if messageType == 2  then 
if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("HeadAdmin")) then 
cancelEvent() 
local red, green, blue = getPlayerNametagColor(source) 
outputChatBox("(TEAM)*Staff*"..getPlayerName(source)..": #FFFFFF"..message, root, red, green, blue, true ) 
end 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), staffchat2) 

Edited by Guest
Posted

I am using zombie resource, but I changed gametype myself to "Zombiehunt 2.3". But can´t be that.

Tested stop zombie resource and write in chat, didn´t help.

Posted

try this .. :roll:

function staffchat(message, messageType) 
  if messageType == 0 then 
       if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("HeadAdmin")) then 
       cancelEvent() 
       local red, green, blue = getPlayerNametagColor(source) 
       outputChatBox("*Staff*"..getPlayerName(source)..": "..message, root, red, green, blue, true ) 
       end 
  elseif messageType == 2  then 
       if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("HeadAdmin")) then 
       cancelEvent() 
       local red, green, blue = getPlayerNametagColor(source) 
       outputChatBox("(TEAM)*Staff*"..getPlayerName(source)..": "..message, root, red, green, blue, true ) 
       end 
   end 
end 
addEventHandler("onPlayerChat",root, staffchat) 
  
  • 2 weeks later...
  • Moderators
Posted

Just to let you know because no one mentioned this:

You could set an high priority on your addEventHandler so that your function would be call before all others.

Posted
Just to let you know because no one mentioned this:

You could set an high priority on your addEventHandler so that your function would be call before all others.

offtopic; That's realy good to know, I think alot of people doesn't know this! Neither do I. :roll:

Posted

That´s true Citizen, but didn´t know I could do that :/

tosfera, yes and that was just a random resource I looked in.

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