Da forma que o script está ele apenas da o item aleatoriamente pro player.
You see!~
info
Grupo: Conde
Registrado: 07/04/15
Posts: 962
Reputação: +258
Gênero: Masculino

Da forma que o script está ele apenas da o item aleatoriamente pro player.
You see!~
Editado Maio 23 por ScreaM
info
Grupo: Visconde
Registrado: 02/10/13
Posts: 320
Reputação: +22
Gênero: Masculino

teria como colocar para ele dar o item aleatoriamente, mas por exemplo, com chance, um item seria mais dificil que o outro por exemplo
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

local query = db.query or db.executeQuery
local premios = { -- [chance] -- itemid,amount
[{1, 3}] = {2390, 1}, -- por exmeplo de 1 a 3 porcento de vim 1 item com id 2390
[{4, 15}] = {2469, 1},
[{16, 25}] = {2646, 1},
[{25, 40}] = {8306, 1},
[{41, 55}] = {2408, 1},
[{56, 65}] = {10020, 1},
[{66, 75}] = {5804, 1},
[{76, 86}] = {5809, 1},
[{86, 100}] = {5937, 1}
}
local function getGuildNameById(id)
local name = ""
local query = db.getResult('SELECT `name` FROM `guilds` WHERE `id` = "'.. id ..'"')
if query:getID() == -1 then
return true
end
name = query:getDataString("name")
query:free()
return name
end
function pointNumber(number)
if not tonumber(number) then
return false
end
local str = ""
number = tostring(number):reverse()
local count = 0
for i = 1, number:len() do
count = count + 1
if count <= 3 then
if str == "" then
str = number:sub(i, i)
else
str = str..number:sub(i, i)
end
else
count = 1
str = str.."."..number:sub(i, i)
end
end
return str:reverse()
end
function onStatsChange(cid, attacker, type, combat, value)
if isMonster(cid) and isPlayer(attacker) and type == STATSCHANGE_HEALTHLOSS then
if isInArray({"Castle Guardian I", "Castle Guardian II", "Castle Guardian III", "Castle Guardian IV", "Castle Generator", "Ice Crystal"}, getCreatureName(cid)) then
doPlayerSetStorageValue(attacker, 1827311, getPlayerStorageValue(attacker, 1827311) + value)
local quant = guild_hit_count[getPlayerGuildId(attacker)] and guild_hit_count[getPlayerGuildId(attacker)] or 0
guild_hit_count[getPlayerGuildId(attacker)] = quant + value
end
end
return true
end
function onDeath(cid, corpse, deathList)
local gid = 0
local winner = 0
if isMonster(cid) and getCreatureName(cid) == "Ice Crystal" then
if not getPlayingGuilds() then
return true
end
local guilds = getPlayingGuilds()
local max = 0
for index, var in pairs(guild_hit_count) do
if var > max then
max = var
gid = index
end
end
setGlobalStorageValue(1823999, gid)
query("UPDATE `castle_dono` SET `guild_id` = '"..gid.."' WHERE `guild_id` > 0")
doBroadcastMessage("{Castle War} O evento acabou, a guild com maior desempenho foi "..getGuildNameById(gid)..", com "..pointNumber(max).." pontos sobre o castelo.")
updateCastleData()
setGlobalStorageValue(18219113, -1)
if gid > 0 then
local mx = 0
for _, pid in pairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == gid then
local st = getPlayerStorageValue(pid, 1827311)
if st > mx then
mx = st
winner = pid
end
end
end
if isPlayer(winner) then
local r = math.random(1,100)
for v, k in pairs(premios) do
if r >= v[1] and r <= v[2] then
local itemr, amountr = k[1], k[2]
local recompensa = doPlayerAddItem(winner, itemr, amountr)
doBroadcastMessage("{Castle War} O jogador com maior desempenho foi "..getCreatureName(winner)..", com "..pointNumber(mx).." pontos sobre o castelo. Ele recebeu "..amountr.."x "..getItemNameById(itemr).." como premio.")
doItemSetAttribute(recompensa, 'description', "Premio do jogador "..getCreatureName(winner).." ganho no evento castle war do dia "..os.date("%d/%m/%y")..".")
end
end
local medal = doPlayerAddItem(winner, 10127, 1)
doItemSetAttribute(medal, 'description', "Trofeu ganho pelo jogador "..getCreatureName(winner).." no evento castle war do dia "..os.date("%d/%m/%y")..".")
end
end
for _, pid in pairs(getPlayersOnline()) do
if isInArea(getThingPos(pid), {x = 500, y = 574, z = 6}, {x = 575, y = 620, z = 6}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 5}, {x = 556, y = 607, z = 5}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 4}, {x = 556, y = 607, z = 4}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 3}, {x = 556, y = 607, z = 3}) or isInArea(getThingPos(pid), {x = 481, y = 580, z = 7}, {x = 683, y = 798, z = 7}) then
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
end
end
guild_hit_count = {}
end
return true
end
info
Grupo: Visconde
Registrado: 02/10/13
Posts: 320
Reputação: +22
Gênero: Masculino

Não sei porque, mas ta acontecendo isso
18:22 {Castle War} O evento acabou, a guild com maior desempenho foi Eduardo Rodrigues, com 2.810 pontos sobre o castelo.
18:22 {Castle War} O jogador com maior desempenho foi GOD Farathor, com 57.396.246 pontos sobre o castelo. Ele recebeu 1x golden boots como premio.
18:22 {Castle War} O jogador com maior desempenho foi GOD Farathor, com 57.396.246 pontos sobre o castelo. Ele recebeu 5x pure energy como premio.
18:22 {Castle War} O jogador com maior desempenho foi GOD Farathor, com 57.396.246 pontos sobre o castelo. Ele recebeu 1x warlord sword como premio.
18:22 {Castle War} O jogador com maior desempenho foi GOD Farathor, com 57.396.246 pontos sobre o castelo. Ele recebeu 1x magic longsword como premio.
18:22 {Castle War} O jogador com maior desempenho foi GOD Farathor, com 57.396.246 pontos sobre o castelo. Ele recebeu 1x dragon scale legs como premio.[{10, 30}] = {2390, 1}, -- por exmeplo de 1 a 3 porcento de vim 1 item com id 2390
[{10, 30}] = {2469, 1},
[{10, 30}] = {2646, 1},
[{20, 50}] = {8306, 5},
[{10, 30}] = {2408, 1},
[{1, 5}] = {10020, 1},
[{1, 5}] = {5804, 1},
[{1, 5}] = {5809, 1},
[{1, 5}] = {5937, 1}18:30 {Castle War} O evento acabou, a guild com maior desempenho foi Eduardo Rodrigues, com 12.083 pontos sobre o castelo.
18:30 {Castle War} O jogador com maior desempenho foi GOD Farathor, com 57.424.065 pontos sobre o castelo. Ele recebeu 1x pure energy como premio.
18:31 A ice crystal loses 281 hitpoints due to your attack.
18:31 {Castle War} O evento acabou, a guild com maior desempenho foi Eduardo Rodrigues, com 281 pontos sobre o castelo.
Editado Maio 24 por Farathor
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

claro vc duplico as chance de porcentagem... vc quer colocar mais de um item pra vir entre 10 e 30 porcento de chance é isso?
vo fazer pra vc e dps vc edita, mas n pode duplicar as chances
---------------------
local query = db.query or db.executeQuery
local premios = { -- -- [chance] -- itemid,amount
[{1, 5}] = {{2493}, {2494}}, -- por exmeplo de 1 a 3 porcento de vim 1 item com id 2390 ou 2494
[{6, 30}] = {{2646}, {2471}, {2466}, {2130}},
[{31, 50}] = {{2191}, {2201}},
[{51, 80}] = {{2339}, {2342}},
[{81, 100}] = {{6500,100}, {6500,50}}
}
local function getGuildNameById(id)
local name = ""
local query = db.getResult('SELECT `name` FROM `guilds` WHERE `id` = "'.. id ..'"')
if query:getID() == -1 then
return true
end
name = query:getDataString("name")
query:free()
return name
end
function pointNumber(number)
if not tonumber(number) then
return false
end
local str = ""
number = tostring(number):reverse()
local count = 0
for i = 1, number:len() do
count = count + 1
if count <= 3 then
if str == "" then
str = number:sub(i, i)
else
str = str..number:sub(i, i)
end
else
count = 1
str = str.."."..number:sub(i, i)
end
end
return str:reverse()
end
function onStatsChange(cid, attacker, type, combat, value)
if isMonster(cid) and isPlayer(attacker) and type == STATSCHANGE_HEALTHLOSS then
if isInArray({"Castle Guardian I", "Castle Guardian II", "Castle Guardian III", "Castle Guardian IV", "Castle Generator", "Ice Crystal"}, getCreatureName(cid)) then
doPlayerSetStorageValue(attacker, 1827311, getPlayerStorageValue(attacker, 1827311) + value)
local quant = guild_hit_count[getPlayerGuildId(attacker)] and guild_hit_count[getPlayerGuildId(attacker)] or 0
guild_hit_count[getPlayerGuildId(attacker)] = quant + value
end
end
return true
end
function onDeath(cid, corpse, deathList)
local gid = 0
local winner = 0
if isMonster(cid) and getCreatureName(cid) == "Ice Crystal" then
if not getPlayingGuilds() then
return true
end
local guilds = getPlayingGuilds()
local max = 0
for index, var in pairs(guild_hit_count) do
if var > max then
max = var
gid = index
end
end
setGlobalStorageValue(1823999, gid)
query("UPDATE `castle_dono` SET `guild_id` = '"..gid.."' WHERE `guild_id` > 0")
doBroadcastMessage("{Castle War} O evento acabou, a guild com maior desempenho foi "..getGuildNameById(gid)..", com "..pointNumber(max).." pontos sobre o castelo.")
updateCastleData()
setGlobalStorageValue(18219113, -1)
if gid > 0 then
local mx = 0
for _, pid in pairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == gid then
local st = getPlayerStorageValue(pid, 1827311)
if st > mx then
mx = st
winner = pid
end
end
end
if isPlayer(winner) then
local r = math.random(1,100)
for v, k in pairs(premios) do
if r >= v[1] and r <= v[2] then
local rand = k[math.random(#k)]
itemr, amountr = rand[1], (not rand[2] and 1 or isItemStackable(rand[1]) and rand[2] or 1)
end
end
local recompensa = doPlayerAddItem(winner, itemr, amountr)
doBroadcastMessage("{Castle War} O jogador com maior desempenho foi "..getCreatureName(winner)..", com "..pointNumber(mx).." pontos sobre o castelo. Ele recebeu "..amountr.."x "..getItemNameById(itemr).." como premio.")
doItemSetAttribute(recompensa, 'description', "Premio do jogador "..getCreatureName(winner).." ganho no evento castle war do dia "..os.date("%d/%m/%y")..".")
local medal = doPlayerAddItem(winner, 10127, 1)
doItemSetAttribute(medal, 'description', "Trofeu ganho pelo jogador "..getCreatureName(winner).." no evento castle war do dia "..os.date("%d/%m/%y")..".")
end
end
for _, pid in pairs(getPlayersOnline()) do
if isInArea(getThingPos(pid), {x = 500, y = 574, z = 6}, {x = 575, y = 620, z = 6}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 5}, {x = 556, y = 607, z = 5}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 4}, {x = 556, y = 607, z = 4}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 3}, {x = 556, y = 607, z = 3}) or isInArea(getThingPos(pid), {x = 481, y = 580, z = 7}, {x = 683, y = 798, z = 7}) then
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
end
end
guild_hit_count = {}
end
return true
end
------------------------- explicação
se n entendeu me adc skype
thiago.vodkart
Editado Maio 24 por Vodkart
info
Grupo: Visconde
Registrado: 02/10/13
Posts: 320
Reputação: +22
Gênero: Masculino

Mais uma coisinha, teria como, invés dele enviar os items para o personagem, ele poderia enviar para o depot?
GOD Farathor has logged in.
> Broadcasted message: "{Castle War} O evento acabou, a guild com maior desempenho foi Eduardo Rodrigues, com 13 pontos sobre o castelo.".
[Error - CreatureScript Interface]
data/creaturescripts/scripts/CastleWar/CastleWar.lua:onDeath
Description:
(luaDoPlayerAddItem) Item not found
[Error - CreatureScript Interface]
data/creaturescripts/scripts/CastleWar/CastleWar.lua:onDeath
Description:
data/lib/100-shortcut.lua:260: attempt to index a boolean value
stack traceback:
data/lib/100-shortcut.lua:260: in function 'getItemNameById'
data/creaturescripts/scripts/CastleWar/CastleWar.lua:92: in function <data/creaturescripts/scripts/CastleWar/CastleWar.lua:52>vod?
up
Editado Maio 26 por Farathor
info
Grupo: Visconde
Registrado: 02/10/13
Posts: 320
Reputação: +22
Gênero: Masculino

Vodkart?
info
Grupo: Visconde
Registrado: 02/10/13
Posts: 320
Reputação: +22
Gênero: Masculino
Pessoal, gostaria de saber, se nesse script, os prêmios, estão com uma certa chance de vir.
local query = db.query or db.executeQuery local premios = {{2390, 1, 200}, {2469, 1, 200}, {2646, 1, 200}, {8306, 1, 200}, {2408, 1, 200}, {10020, 1, 1}, {5804, 1, 1}, {5809, 1, 1}, {5937, 1, 1}} local function getGuildNameById(id) local name = "" local query = db.getResult('SELECT `name` FROM `guilds` WHERE `id` = "'.. id ..'"') if query:getID() == -1 then return true end name = query:getDataString("name") query:free() return name end function pointNumber(number) if not tonumber(number) then return false end local str = "" number = tostring(number):reverse() local count = 0 for i = 1, number:len() do count = count + 1 if count <= 3 then if str == "" then str = number:sub(i, i) else str = str..number:sub(i, i) end else count = 1 str = str.."."..number:sub(i, i) end end return str:reverse() end function onStatsChange(cid, attacker, type, combat, value) if isMonster(cid) and isPlayer(attacker) and type == STATSCHANGE_HEALTHLOSS then if isInArray({"Castle Guardian I", "Castle Guardian II", "Castle Guardian III", "Castle Guardian IV", "Castle Generator", "Ice Crystal"}, getCreatureName(cid)) then doPlayerSetStorageValue(attacker, 1827311, getPlayerStorageValue(attacker, 1827311) + value) local quant = guild_hit_count[getPlayerGuildId(attacker)] and guild_hit_count[getPlayerGuildId(attacker)] or 0 guild_hit_count[getPlayerGuildId(attacker)] = quant + value end end return true end function onDeath(cid, corpse, deathList) local gid = 0 local winner = 0 if isMonster(cid) and getCreatureName(cid) == "Ice Crystal" then if not getPlayingGuilds() then return true end local guilds = getPlayingGuilds() local max = 0 for index, var in pairs(guild_hit_count) do if var > max then max = var gid = index end end setGlobalStorageValue(1823999, gid) query("UPDATE `castle_dono` SET `guild_id` = '"..gid.."' WHERE `guild_id` > 0") doBroadcastMessage("{Castle War} O evento acabou, a guild com maior desempenho foi "..getGuildNameById(gid)..", com "..pointNumber(max).." pontos sobre o castelo.") updateCastleData() setGlobalStorageValue(18219113, -1) if gid > 0 then local mx = 0 for _, pid in pairs(getPlayersOnline()) do if getPlayerGuildId(pid) == gid then local st = getPlayerStorageValue(pid, 1827311) if st > mx then mx = st winner = pid end end end if isPlayer(winner) then local rand = math.random(1, #premios) local itemr,amountr = premios[rand][1], premios[rand][2] local recompensa = doPlayerAddItem(winner, itemr, amountr) doBroadcastMessage("{Castle War} O jogador com maior desempenho foi "..getCreatureName(winner)..", com "..pointNumber(mx).." pontos sobre o castelo. Ele recebeu "..pointNumber(amountr).."x "..getItemNameById(itemr).." como premio.") doItemSetAttribute(recompensa, 'description', "Premio do jogador "..getCreatureName(winner).." ganho no evento castle war do dia "..os.date("%d/%m/%y")..".") local medal = doPlayerAddItem(winner, 10127, 1) doItemSetAttribute(medal, 'description', "Trofeu ganho pelo jogador "..getCreatureName(winner).." no evento castle war do dia "..os.date("%d/%m/%y")..".") end end for _, pid in pairs(getPlayersOnline()) do if isInArea(getThingPos(pid), {x = 500, y = 574, z = 6}, {x = 575, y = 620, z = 6}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 5}, {x = 556, y = 607, z = 5}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 4}, {x = 556, y = 607, z = 4}) or isInArea(getThingPos(pid), {x = 511, y = 588, z = 3}, {x = 556, y = 607, z = 3}) or isInArea(getThingPos(pid), {x = 481, y = 580, z = 7}, {x = 683, y = 798, z = 7}) then doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid))) end end guild_hit_count = {} end return true endlocal premios = {{2390, 1, 200}} Aqui Seria assim. ID,Quantidade,Chance. gostaria de saber se isso está acontecendo realmente.
Editado Maio 23 por Farathor