-.Paradox.- Posted October 29, 2013 Posted October 29, 2013 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 )
Castillo Posted October 29, 2013 Posted October 29, 2013 It should work, do you get the same error at getPlayerName?
Castillo Posted October 29, 2013 Posted October 29, 2013 I don't see any reason for that, since 'source' is self defined by the event.
.:HyPeX:. Posted October 29, 2013 Posted October 29, 2013 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)
xXMADEXx Posted October 29, 2013 Posted October 29, 2013 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.
.:HyPeX:. Posted October 29, 2013 Posted October 29, 2013 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)
-.Paradox.- Posted October 30, 2013 Author Posted October 30, 2013 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
.:HyPeX:. Posted October 30, 2013 Posted October 30, 2013 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now