I'm making an instance script, but nothing happens when I join queue with 2 characters (just to test, should be 8 later). can anyone help me fix it?:
Code:
playerinstance = {0, 0, 0, 0, 0, 0, 0, 0}
function tpcheck(cid)
a = 0
b = 0
h = 0
c = 0
for _, pid in ipairs(getPlayersOnline()) do
if(isPlayer(getPlayerByName(getPlayerName(pid)))) then
if(getPlayerStorageValue(getPlayerByName(getPlayerName(pid)), 12399)==1) then
playerinstance[a] = getPlayerByName(getPlayerName(pid))
a = a + 1
end
end
end
if(a == 2) then
while b < 2 do
if(isPlayer(playerinstance[b])) then
doTeleportThing(playerinstance[b], {x = 517, y = 2190, z = 7}, false)
end
b = b + 1
end
end
while(h < 2) do
if(isPlayer(playerinstance[h])) then
if(getPlayerStorageValue(playerinstance[h], 12388)==1) then
while(c < 2) do
doTeleportThing(playerinstance[c], getTownTemplePosition(5), false)
setPlayerStorageValue(playerinstance[c], 12388, 0)
setPlayerStorageValue(playerinstance[c], 12399, 0)
c = c + 1
end
end
end
h = h + 1
end
return true
end
function onThink(interval, lastExecution, thinkInterval)
addEvent(tpcheck, 20000)
return true
end