Wumbaloo Posted July 22, 2015 Share Posted July 22, 2015 Hi! I have a mystery error in the console, here's the error: "script.lua:5: attempt to concatenate local 'sourcePlayer' (a userdata value) but no error in my code I think.. function setHP(sourcePlayer, command, targetPlayerName, value) targetPlayer = getPlayerFromName (targetPlayerName) setElementHealth (targetPlayer, value) outputChatBox("Vous avez mis " .. value .. " HP à " .. targetPlayerName, sourcePlayer) outputChatBox("L'Admin: " .. sourcePlayer " vous à mis votre HP à " .. value .. ".", targetPlayer) end addCommandHandler("setHP", setHP) addCommandHandler("sethp", setHP) Can you help me? Thanks! Link to comment
Addlibs Posted July 22, 2015 Share Posted July 22, 2015 script.lua:5: attempt to concatenate local 'sourcePlayer' (a userdata value) means that you tried to join a string with a userdata (more specifically, userdata:element:player) value. You tried to embed the memory address for a player instead of his nickname (getPlayerName) outputChatBox("L'Admin: " .. sourcePlayer " vous à mis votre HP à " .. value .. ".", targetPlayer) should be outputChatBox("L'Admin: " .. getPlayerName(sourcePlayer) .." vous à mis votre HP à " .. value .. ".", targetPlayer) Link to comment
Wumbaloo Posted July 22, 2015 Author Share Posted July 22, 2015 Thanks! It work! And another question, can I set different color in one outputChatBox? Link to comment
MTA Team 0xCiBeR Posted July 22, 2015 MTA Team Share Posted July 22, 2015 outputChatBox("L'Admin: " .. getPlayerName(sourcePlayer) .." vous à mis votre HP à " .. value .. ".", targetPlayer,RED,GREEN,BLUE) Replace "RED,GREEN,BLUE" with color values 0-255 Link to comment
Wumbaloo Posted July 22, 2015 Author Share Posted July 22, 2015 I know, but if I want to put "HP" in red and the other in green, how can I do? Link to comment
LabiVila Posted July 22, 2015 Share Posted July 22, 2015 outputChatBox ("#ffff00H#ff0000P", sourcePlayer, 255, 255, 255, true) this would do a yellow H and a red P Link to comment
Wumbaloo Posted July 22, 2015 Author Share Posted July 22, 2015 Thanks, it's the html color code ? (http://html-color-codes.info/) Link to comment
xXMADEXx Posted July 22, 2015 Share Posted July 22, 2015 Thanks, it's the html color code ?(http://html-color-codes.info/) It's HEX color codes, not HTML, but yes. 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