VEILUS Posted April 11, 2018 Posted April 11, 2018 --Where is the error? function getAllPlayerInDimension ( dimension ) local rValue = { }; for i, v in ipairs ( getElementsByType ( "player" ) ) do if ( getElementDimension ( v ) == dimension ) then table.insert ( rValue, v ); end end return rValue; end function SetDimensionLobby() getAllPlayerInDimension (0) outputChatBox ("all players in Dimension 0"..table.concat(rValue)) end addCommandHandler ("s",SetDimensionLobby,false) I want to check if Dimension 0 has a player, if true, then check Dimension 1, if true, then the next dimension, until Dimension (n) == 0 players, if dimension (n) == 0 players then setElementDimension (source , Dimension (n)), how to do this? (Sorry, I'm brasilian and my English is low level).
Moderators Patrick Posted April 12, 2018 Moderators Posted April 12, 2018 function SetDimensionLobby() local returned_rValue = getAllPlayerInDimension(0) outputChatBox ("all players in Dimension 0 "..table.concat(returned_rValue)) end addCommandHandler ("s",SetDimensionLobby,false)
LLCoolJ Posted April 12, 2018 Posted April 12, 2018 function getAllPlayerInDimension(dimension) local rValue = {} for i,v in ipairs(getElementsByType("player")) do if ( getElementDimension ( v ) == dimension ) then table.insert(rValue,getPlayerName(v)) end end return rValue end function SetDimensionLobby() outputChatBox("all players in Dimension 0:"..table.concat(getAllPlayerInDimension(0),",")) end addCommandHandler ("s",SetDimensionLobby)
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