Ir para conteúdo
  • 0

Como colocar para dar item Random nesse script?


TiagoBordin1988

Pergunta

Queria ao invés de os itens recebidos fossem fixo, queria que desse ele no sistema de Random para cada hora que um vencer ganhar diferentes itens aleatoriamente.

SCRIPT

 

function loseOnZombieArena(cid)

kickPlayerFromZombiesArea(cid)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! Você está morto.")

local players = getZombiesEventPlayers()

if(#players <= 1) then

local winner = players[1]

if(winner) then

doPlayerAddItem(winner, 2160, 100, true)

doPlayerAddItem(winner, 7958, 100, true)

doPlayerAddItem(winner, 2352, 100, true)

doPlayerAddItem(winner, 12610, 100, true)

doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Você Ganhou o Evento Zombie !!! Parabéns.")

doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos de evento " .. getCreatureName(winner) .. " você ganhou o Evento Zombie contra " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies !!!")

kickPlayerFromZombiesArea(winner)

else

doBroadcastMessage("Zombie Evento Acabou !!! Não teve vencedor ?!?!?! Como Assim ?")

end

doSetStorage(ZE_STATUS, 0)

doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)

doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)

doSetStorage(ZE_ZOMBIES_SPAWNED, 0)

local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1

local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1

local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}

for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do

centerPos.z = z

for i, uid in pairs(getSpectators(centerPos, width, height, false)) do

if(isMonster(uid)) then

doRemoveCreature(uid)

end

end

end

end

end

function onStatsChange(target, cid, changetype, combat, value)

if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then

doCreatureAddHealth(target, getCreatureMaxHealth(target))

loseOnZombieArena(target)

return false

end

return true

end

 

 

Link para o comentário
Compartilhar em outros sites

9 respostass a esta questão

Posts Recomendados

  • 0

Testa ai manolo:

 

function loseOnZombieArena(cid)
kickPlayerFromZombiesArea(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! Você está morto.")
local players = getZombiesEventPlayers()
if(#players <= 1) then
local winner = players[1]
local items = {2160, 7958, 2352, 12610}
if(winner) then
doPlayerAddItem(cid,items[math.random(1,#items)], math.random(1, 100))
doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Você Ganhou o Evento Zombie !!! Parabéns.")
doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos de evento " .. getCreatureName(winner) .. " você ganhou o Evento Zombie contra " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies !!!")
kickPlayerFromZombiesArea(winner)
else
doBroadcastMessage("Zombie Evento Acabou !!! Não teve vencedor ?!?!?! Como Assim ?")
end
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
centerPos.z = z
for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
if(isMonster(uid)) then
doRemoveCreature(uid)
end
end
end
end
end
function onStatsChange(target, cid, changetype, combat, value)
if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
doCreatureAddHealth(target, getCreatureMaxHealth(target))
loseOnZombieArena(target)
return false
end
return true
end

Editado por PsyMcKenzie
Link para o comentário
Compartilhar em outros sites

  • 0

Testa ai manolo:

 

function loseOnZombieArena(cid)
kickPlayerFromZombiesArea(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! Você está morto.")
local players = getZombiesEventPlayers()
if(#players <= 1) then
local winner = players[1]
local items = {2160, 7958, 2352, 12610}
if(winner) then
doPlayerAddItem(cid,items[math.random(1,#items)], math.random(1, 100))
doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Você Ganhou o Evento Zombie !!! Parabéns.")
doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos de evento " .. getCreatureName(winner) .. " você ganhou o Evento Zombie contra " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies !!!")
kickPlayerFromZombiesArea(winner)
else
doBroadcastMessage("Zombie Evento Acabou !!! Não teve vencedor ?!?!?! Como Assim ?")
end
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
centerPos.z = z
for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
if(isMonster(uid)) then
doRemoveCreature(uid)
end
end
end
end
end
function onStatsChange(target, cid, changetype, combat, value)
if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
doCreatureAddHealth(target, getCreatureMaxHealth(target))
loseOnZombieArena(target)
return false
end
return true
end

ta quase certo, os itens está indo pra quem perde o evento e não pra quem vence !!!!

Link para o comentário
Compartilhar em outros sites

  • 0

Thiago, troque por:

 

 

 

function loseOnZombieArena(cid)

kickPlayerFromZombiesArea(cid)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! Você está morto.")

local players = getZombiesEventPlayers()

if(#players <= 1) then

local winner = players[1]

local items = {2160, 7958, 2352, 12610}

if(winner) then

doPlayerAddItem(winner,items[math.random(1,#items)], math.random(1, 100))

doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Você Ganhou o Evento Zombie !!! Parabéns.")

doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos de evento " .. getCreatureName(winner) .. " você ganhou o Evento Zombie contra " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies !!!")

kickPlayerFromZombiesArea(winner)

else

doBroadcastMessage("Zombie Evento Acabou !!! Não teve vencedor ?!?!?! Como Assim ?")

end

doSetStorage(ZE_STATUS, 0)

doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)

doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)

doSetStorage(ZE_ZOMBIES_SPAWNED, 0)

local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1

local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1

local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}

for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do

centerPos.z = z

for i, uid in pairs(getSpectators(centerPos, width, height, false)) do

if(isMonster(uid)) then

doRemoveCreature(uid)

end

end

end

end

end

function onStatsChange(target, cid, changetype, combat, value)

if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then

doCreatureAddHealth(target, getCreatureMaxHealth(target))

loseOnZombieArena(target)

return false

end

return true

end

 

Link para o comentário
Compartilhar em outros sites

  • 0

function loseOnZombieArena(cid)
kickPlayerFromZombiesArea(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! Você está morto.")
local players = getZombiesEventPlayers()
if(#players <= 1) then
local winner = players[1]
local items = {2160, 7958, 2352, 12610}
if(winner) then
doPlayerAddItem(winner,items[math.random(1,#items)], math.random(1, 100))
doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Você Ganhou o Evento Zombie !!! Parabéns.")
doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos de evento " .. getCreatureName(winner) .. " você ganhou o Evento Zombie contra " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies !!!")
kickPlayerFromZombiesArea(winner)
else
doBroadcastMessage("Zombie Evento Acabou !!! Não teve vencedor ?!?!?! Como Assim ?")
end
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
centerPos.z = z
for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
if(isMonster(uid)) then
doRemoveCreature(uid)
end
end
end
end
end
function onStatsChange(target, cid, changetype, combat, value)
if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
doCreatureAddHealth(target, getCreatureMaxHealth(target))
loseOnZombieArena(target)
return false
end
return true
end

Link para o comentário
Compartilhar em outros sites

  • 0

Thiago, troque por:

 

 

 

function loseOnZombieArena(cid)

kickPlayerFromZombiesArea(cid)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! Você está morto.")

local players = getZombiesEventPlayers()

if(#players <= 1) then

local winner = players[1]

local items = {2160, 7958, 2352, 12610}

if(winner) then

doPlayerAddItem(winner,items[math.random(1,#items)], math.random(1, 100))

doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Você Ganhou o Evento Zombie !!! Parabéns.")

doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos de evento " .. getCreatureName(winner) .. " você ganhou o Evento Zombie contra " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies !!!")

kickPlayerFromZombiesArea(winner)

else

doBroadcastMessage("Zombie Evento Acabou !!! Não teve vencedor ?!?!?! Como Assim ?")

end

doSetStorage(ZE_STATUS, 0)

doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)

doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)

doSetStorage(ZE_ZOMBIES_SPAWNED, 0)

local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1

local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1

local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}

for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do

centerPos.z = z

for i, uid in pairs(getSpectators(centerPos, width, height, false)) do

if(isMonster(uid)) then

doRemoveCreature(uid)

end

end

end

end

end

function onStatsChange(target, cid, changetype, combat, value)

if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then

doCreatureAddHealth(target, getCreatureMaxHealth(target))

loseOnZombieArena(target)

return false

end

return true

end

 

 

Funfo certinho agora obrigadão !!!

 

Dúvida Resolvida

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...