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 
) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

It should work, do you get the same error at getPlayerName?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I don't see any reason for that, since 'source' is self defined by the event.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

So how i can fix it?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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) 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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) 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

There's no reason for it to don't work.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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) 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

It's server side

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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