Jump to content

What's wrong with this code?


Recommended Posts

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

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