Jump to content

getPlayerNametagColor


-.Paradox.-

Recommended Posts

Posted

Hello, i need help here, can't getPlayerNametagColor

WARNING: Class/basic.lua:4: Bad argument @ 'getPlayerNameTagColor'

addEventHandler ( "onPlayerChat", root, 
    function ( msg, msgType ) 
    local name = getPlayerName(source) 
    local r,g,b = getPlayerNametagColor (source) 
        if ( msgType == 1 ) then 
            cancelEvent ( ) 
            outputChatBox ( "* " ..name.. "#006400 ".. msg, root, 0, 100, 0, true ) 
        end 
    end 
) 

Posted

try like this

  
    function onchat( playerSource, msg, msgType ) 
    local name = getPlayerName(playerSource) 
    local r,g,b = getPlayerNametagColor (playersource) 
        if ( msgType == 1 ) then 
            cancelEvent ( ) 
            outputChatBox ( "* " ..name.. "#006400 ".. msg, root, 0, 100, 0, true ) 
        end 
    end 
addEventHandler ( "onPlayerChat", root, onchat) 

Posted
try like this
  
    function onchat( playerSource, msg, msgType ) 
    local name = getPlayerName(playerSource) 
    local r,g,b = getPlayerNametagColor (playersource) 
        if ( msgType == 1 ) then 
            cancelEvent ( ) 
            outputChatBox ( "* " ..name.. "#006400 ".. msg, root, 0, 100, 0, true ) 
        end 
    end 
addEventHandler ( "onPlayerChat", root, onchat) 

That wouldn't work because 'playerSource' would return a string. Please read the arguments first.

https://wiki.multitheftauto.com/wiki/OnPlayerChat

@StevyDK: Is this your entire script? If not, post the rest.

Posted

Ooops sorry didnt readed.

The idea is to get out of handler-based functions and make a standaole one, it may work better.

  
    function onchat( msg, msgType ) 
    local name = getPlayerName(source) 
    local r,g,b = getPlayerNametagColor (source) 
        if ( msgType == 1 ) then 
            cancelEvent ( ) 
            outputChatBox ( "* " ..name.. "#006400 ".. msg, root, 0, 100, 0, true ) 
        end 
    end 
addEventHandler ( "onPlayerChat", getRootElement(), onchat) 

Posted
Ooops sorry didnt readed.

The idea is to get out of handler-based functions and make a standaole one, it may work better.

  
    function onchat( msg, msgType ) 
    local name = getPlayerName(source) 
    local r,g,b = getPlayerNametagColor (source) 
        if ( msgType == 1 ) then 
            cancelEvent ( ) 
            outputChatBox ( "* " ..name.. "#006400 ".. msg, root, 0, 100, 0, true ) 
        end 
    end 
addEventHandler ( "onPlayerChat", getRootElement(), onchat) 

Don't work

@xXMadeXx it's the entire script

Posted

try the exact code from the wiki, if it doesnt works, then its something related to your meta/other stuff configs.

  
local function playerJoin() 
    local red, green, blue = math.random (50, 255), math.random (50, 255), math.random (50, 255) 
        setPlayerNametagColor(source, red, green, blue) 
end 
addEventHandler ("onPlayerJoin", root, playerJoin) 
  
local function playerChat(message, messageType) 
    if messageType == 0 then --Global (main) chat 
                cancelEvent() 
                local red, green, blue = getPlayerNametagColor(source) 
        outputChatBox(getPlayerName(source)..": #FFFFFF"..message, root, red, green, blue, true ) 
        outputServerLog("CHAT: "..getPlayerName(source)..": "..message)--NOTE: Beacuse we cancelled the onPlayerChat event, we need to log chat manually. 
    end 
end 
addEventHandler("onPlayerChat", root, playerChat) 

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