bom dia, galera é o seguinte eu gostaria que a primeiro uso na alavanca, ela já fosse bloqueada para 5 minutos depois, desde a primeira, o script está bloqueando só da segunda adiante.. obrigado
Spoiler
function getPlayersInRange(position, radiusx, radiusy)
local creaturesList = {}
for x = -radiusx, radiusx do
for y = -radiusy, radiusy do
if not (x == 0 and y == 0) then
local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
if creature.type == 1 then
table.insert(creaturesList, creature.uid)
end
end
end
end
local creature = getTopCreature(position)
if creature.type == 1 then
if not(table.find(creaturesList, creature.uid)) then
table.insert(creaturesList, creature.uid)
end
end
return creaturesList
end
local t, n, storage = {
{x=915, y=1447, z=13},
{x=915, y=1448, z=13},
{x=915, y=1449, z=13},
{x=915, y=1450, z=13},
{x=913, y=1450, z=13},
{x=914, y=1450, z=13},
{x=916, y=1450, z=13},
{x=917, y=1450, z=13}
}, {
{x=896, y=1434, z=14},
{x=930, y=1434, z=14},
{x=930, y=1464, z=14},
{x=896, y=1464, z=14},
{x=921, y=1454, z=14},
{x=905, y=1444, z=14},
{x=921, y=1444, z=14},
{x=905, y=1454, z=14},
{x=921, y=1454, z=14}
}, {
placed = 101,
max = 102,
radius = 103
}
local chupa = {
storage = 15011, -----> storage a verificar
time = 5 -------> minutes
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 10030 then
return doTransformItem(item.uid, item.itemid - 1)
end
local v = getPlayersInRange({x=913,y=1449,z=14}, 34, 30)
if #v > 1 then
return doPlayerSendCancel(cid, "Please wait for the current match to end.")
end
local players = {}
for i = 1, #t do
local v = getTopCreature(t[i]).uid
players[i] = isPlayer(v) and v or nil
end
if #players < 2 then
return doPlayerSendCancel(cid, "You need at least 2 players to enter.")
end
if getGlobalStorageValue(cid,chupa.storage) > os.time() then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"espere ".. getGlobalStorageValue(cid, chupa.storage) - os.time() .." segundos.")
else
local first = players[1] and 1 or players[2] and 2 or players[3] and 3 or players[4] and 4 or players[5] and 5 and 6 or players[6] and 7 or players[7] and 7 and 8 or players[8] and 8
for i = 1, 8 do
if players[i] then
getGlobalStorageValue(players[i], storage.placed, 0)
getGlobalStorageValue(players[i], storage.max, 1)
getGlobalStorageValue(players[i], storage.radius, 1)
doSendMagicEffect(t[i], CONST_ME_TELEPORT)
doTeleportThing(players[i], n[i])
setGlobalStorageValue(players[i],chupa.storage, os.time() + chupa.time * 60)
doSendMagicEffect(n[i], CONST_ME_TELEPORT)
end
end
end
doTransformItem(item.uid, item.itemid + 1)
return true
end
bom dia, galera é o seguinte eu gostaria que a primeiro uso na alavanca, ela já fosse bloqueada para 5 minutos depois, desde a primeira, o script está bloqueando só da segunda adiante.. obrigado
function getPlayersInRange(position, radiusx, radiusy) local creaturesList = {} for x = -radiusx, radiusx do for y = -radiusy, radiusy do if not (x == 0 and y == 0) then local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z}) if creature.type == 1 then table.insert(creaturesList, creature.uid) end end end end local creature = getTopCreature(position) if creature.type == 1 then if not(table.find(creaturesList, creature.uid)) then table.insert(creaturesList, creature.uid) end end return creaturesList end local t, n, storage = { {x=915, y=1447, z=13}, {x=915, y=1448, z=13}, {x=915, y=1449, z=13}, {x=915, y=1450, z=13}, {x=913, y=1450, z=13}, {x=914, y=1450, z=13}, {x=916, y=1450, z=13}, {x=917, y=1450, z=13} }, { {x=896, y=1434, z=14}, {x=930, y=1434, z=14}, {x=930, y=1464, z=14}, {x=896, y=1464, z=14}, {x=921, y=1454, z=14}, {x=905, y=1444, z=14}, {x=921, y=1444, z=14}, {x=905, y=1454, z=14}, {x=921, y=1454, z=14} }, { placed = 101, max = 102, radius = 103 } local chupa = { storage = 15011, -----> storage a verificar time = 5 -------> minutes } function onUse(cid, item, fromPosition, itemEx, toPosition) if item.itemid == 10030 then return doTransformItem(item.uid, item.itemid - 1) end local v = getPlayersInRange({x=913,y=1449,z=14}, 34, 30) if #v > 1 then return doPlayerSendCancel(cid, "Please wait for the current match to end.") end local players = {} for i = 1, #t do local v = getTopCreature(t[i]).uid players[i] = isPlayer(v) and v or nil end if #players < 2 then return doPlayerSendCancel(cid, "You need at least 2 players to enter.") end if getGlobalStorageValue(cid,chupa.storage) > os.time() then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"espere ".. getGlobalStorageValue(cid, chupa.storage) - os.time() .." segundos.") else local first = players[1] and 1 or players[2] and 2 or players[3] and 3 or players[4] and 4 or players[5] and 5 and 6 or players[6] and 7 or players[7] and 7 and 8 or players[8] and 8 for i = 1, 8 do if players[i] then getGlobalStorageValue(players[i], storage.placed, 0) getGlobalStorageValue(players[i], storage.max, 1) getGlobalStorageValue(players[i], storage.radius, 1) doSendMagicEffect(t[i], CONST_ME_TELEPORT) doTeleportThing(players[i], n[i]) setGlobalStorageValue(players[i],chupa.storage, os.time() + chupa.time * 60) doSendMagicEffect(n[i], CONST_ME_TELEPORT) end end end doTransformItem(item.uid, item.itemid + 1) return true end
Compartilhar este post
Link para o post
Compartilhar em outros sites