-.Paradox.- Posted October 29, 2013 Share 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 ) Link to comment
Castillo Posted October 29, 2013 Share Posted October 29, 2013 It should work, do you get the same error at getPlayerName? Link to comment
Castillo Posted October 29, 2013 Share Posted October 29, 2013 I don't see any reason for that, since 'source' is self defined by the event. Link to comment
-.Paradox.- Posted October 29, 2013 Author Share Posted October 29, 2013 So how i can fix it? Link to comment
.:HyPeX:. Posted October 29, 2013 Share 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) Link to comment
xXMADEXx Posted October 29, 2013 Share 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. Link to comment
.:HyPeX:. Posted October 29, 2013 Share 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) Link to comment
-.Paradox.- Posted October 30, 2013 Author Share 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 Link to comment
Castillo Posted October 30, 2013 Share Posted October 30, 2013 There's no reason for it to don't work. Link to comment
.:HyPeX:. Posted October 30, 2013 Share 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) Link to comment
3NAD Posted November 1, 2013 Share Posted November 1, 2013 Put your meta.xml of 'Class' resource ? Link to comment
-.Paradox.- Posted November 3, 2013 Author Share Posted November 3, 2013 It's server side Link to comment
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