Why is my mod setting the dimension for all players?
function joinHandler()
fadeCamera(source, true)
setCameraTarget(source)
spawnPlayer(source, 0, 0, 5)
end
addEventHandler("onPlayerLogin", getRootElement(), joinHandler)
function playerToLobby()
triggerClientEvent ( "PlayerOnLobby", root )
end
addEventHandler ("onPlayerSpawn",getRootElement(),playerToLobby)
function getAllPlayerInDimension ( dimension )
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(thePlayer)
g_NPlayers = true
g_NState = 0
while g_NPlayers do
getAllPlayerInDimension (g_NState)
if (#rValue>0) then
g_NState = g_NState + 1;
outputChatBox ("O valor é maior que 0")
else
g_NPlayers = false
outputChatBox ("A dimension setada é: "..g_NState)
end
end
local s_PlayerDimension = g_NState
setElementDimension (source,s_PlayerDimension)
end
addEvent ("onCommand", true)
addEventHandler ("onCommand",getRootElement(),SetDimensionLobby)