Hugo_Almeidowski Posted January 24, 2019 Share Posted January 24, 2019 function setPlayerDimension (source, command, dimension) local dimensaoA = getElementDimension(source) dimensaoB = setElementDimension(source, dimension) outputChatBox(horaJ.. "Foste transferido da dimensão " ..corEspaco.. dimensaoA.. " para a dimensão " ..corEspaco.. dimensaoB, source, isR, isG, isB, true) end addCommandHandler("dimension", setPlayerDimension) I'm trying to set the source to the dimension he writes after /dimension, but the console is returning me this ERROR: attempt to concatenate global 'dimensaoB' (a boolean value) I tried to do it in multiple ways (including with if statements), but it never worked. PS: horaJ and corEspaco are just colors that work fine in every other outputChatBox. Link to comment
DNL291 Posted January 24, 2019 Share Posted January 24, 2019 (edited) That's because setElementDimension returns a boolean value, just use the function parameter: dimension. Also, check if the parameter provided is a valid dimension (0 - 65535). Edited January 24, 2019 by DNL291 Link to comment
Hugo_Almeidowski Posted January 25, 2019 Author Share Posted January 25, 2019 11 hours ago, DNL291 said: That's because setElementDimension returns a boolean value, just use the function parameter: dimension. Also, check if the parameter provided is a valid dimension (0 - 65535). Like this? dimensaoB = setElementDimension(dimension) It still doesn't work. Link to comment
Hugo_Almeidowski Posted January 25, 2019 Author Share Posted January 25, 2019 1 hour ago, Hugo_Almeidowski said: Like this? dimensaoB = setElementDimension(dimension) It still doesn't work. Alright, I've made this: function setPlayerDimension (source, command, dimension) local dimensaoA = getElementDimension(source) local nomeJ = getPlayerName(source) dimensaoB = setElementDimension(source, dimension) if dimensaoB then outputChatBox(horaJ.. "Foste transferido da dimensão " ..corEspaco.. dimensaoA.. " para a dimensão " ..corEspaco.. dimensaoB, source, isR, isG, isB, true) else outputChatBox("Erro") end end addCommandHandler("dimension", setPlayerDimension) But I still get an Error: Bad argument @ 'setElementDimension' Expected element at argument 1, [got string "whatever number I typed After /dimension']. I understand he's telling me to say the element I want to teleport before I say the dimension, but I want it to understand that I want it to teleport whoever type the command. Link to comment
Overkillz Posted January 25, 2019 Share Posted January 25, 2019 56 minutes ago, Hugo_Almeidowski said: Alright, I've made this: But I still get an Error: Bad argument @ 'setElementDimension' Expected element at argument 1, [got string "whatever number I typed After /dimension']. I understand he's telling me to say the element I want to teleport before I say the dimension, but I want it to understand that I want it to teleport whoever type the command. Try this: function setPlayerDimension(thePlayer, cmd, dimension) local dimensaoA = getElementDimension(thePlayer) local nomeJ = getPlayerName(thePlayer) if tonumber(dimension) then local dimensaoB = setElementDimension(thePlayer, dimension) if dimensaoB then outputChatBox(horaJ.. "Foste transferido da dimensão " ..corEspaco.. dimensaoA.. " para a dimensão " ..corEspaco.. tostring(dimension), thePlayer, isR, isG, isB, true) else outputChatBox("Erro") end end end addCommandHandler("dimension", setPlayerDimension) Link to comment
Hugo_Almeidowski Posted January 25, 2019 Author Share Posted January 25, 2019 2 hours ago, Overkillz said: Try this: function setPlayerDimension(thePlayer, cmd, dimension) local dimensaoA = getElementDimension(thePlayer) local nomeJ = getPlayerName(thePlayer) if tonumber(dimension) then local dimensaoB = setElementDimension(thePlayer, dimension) if dimensaoB then outputChatBox(horaJ.. "Foste transferido da dimensão " ..corEspaco.. dimensaoA.. " para a dimensão " ..corEspaco.. tostring(dimension), thePlayer, isR, isG, isB, true) else outputChatBox("Erro") end end end addCommandHandler("dimension", setPlayerDimension) It worked! Thank you very much! I will study it! 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