Jump to content

Chatmessage doesn´t disappear with cancelEvent() in mainchat


Adde

Recommended Posts

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) 

Link to comment

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
Link to comment

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) 
  
Link to comment
  • 2 weeks later...

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