Jump to content

onplayerchat admin msg need help


IIIIlllllIII

Recommended Posts

hi i wanna make some script like when the admin type anything in the chat box all player see the admin

like when i type in chat box i see like this

admin-MOJRM-511

or

modrator-MOJRM-511

i mean in the chat box and i have this code pleez fix it

  
  
function onChat ( message, messageType ) 
    if messageType == 0 then 
        local root = getRootElement() 
        outputChatBox ( getPlayerName ( source ) .. "#ff0000admin: " .. message, getRootElement() ) 
        cancelEvent() 
        outputServerLog( "#ff0000admin: " .. getPlayerName ( source ).. "#ff0000admin: " .. message ) 
    end 
end 
addEventHandler ( "onPlayerChat", getRootElement(), onChat ) 
  

Link to comment
addEventHandler ( "onPlayerChat" , root , 
function ( message , type ) 
if hasObjectPermissionTo ( source , "function.banPlayer" ) then 
cancelEvent ( ) 
outputChatBox ( "#ff0000admin " .. getPlayerName ( source ) .. " : " .. message, getRootElement() ) 
end 
end) 

And yeah, this is not a request forum, I just had time, next time try something yourself.

Link to comment

back

when i try this code

  
  
addEventHandler ( "onPlayerChat" , root , 
function ( message , type ) 
if hasObjectPermissionTo ( source , "function.banPlayer" ) then 
cancelEvent ( ) 
outputChatBox ( "#ff0000admin" .. getPlayerName ( source ) .. ":" .. message, getRootElement() ) 
end 
end) 
  
  
  
  

i dont see the color not working

115793xiqds.JPG

all works great but

i dont see the color when i put #ff0000 red color

the problem with the color not working

fix it pleeez

Link to comment

That's because the color codes aren't enabled.

addEventHandler ( "onPlayerChat" , root , 
function ( message , type ) 
if hasObjectPermissionTo ( source , "function.banPlayer" ) then 
cancelEvent ( ) 
local r, g, b = getPlayerNametagColor(source) 
outputChatBox ( "#ff0000admin" .. getPlayerName ( source ) .. ":" .. message, getRootElement(), r, g, b, true ) 
end 
end) 

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