TI
dúvida

Como colocar para dar item Random nesse script?

Por TiagoBordin1988, 06 de abr. de 2013 em Scripts

resolvido
script
10
1k
06 de abril de 2013 às 04:41

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

 

 

PsyMcKenzieP
06 de abril de 2013 às 04:56

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 Abril 6 por PsyMcKenzie

06 de abril de 2013 às 06:19

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 !!!!

RoksasR
06 de abril de 2013 às 10:45

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

 

VincV
06 de abril de 2013 às 10:45

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

06 de abril de 2013 às 11:00

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

RoksasR
06 de abril de 2013 às 11:04

Tópico movido para a seção de dúvidas e pedidos resolvidos.

PsyMcKenzieP
06 de abril de 2013 às 13:47

Coloquei na linha errada --' affz

06 de abril de 2013 às 22:57

Coloquei na linha errada --' affz

dei Rep + pra vc tb !!!
PsyMcKenzieP
06 de abril de 2013 às 22:58

Ah, obrigado mano ^^