FA
pedido

[Pedido] Modificação em Script de Prêmio

Por Farathor, 06 de fev. de 2016 em Scripts

59
5.7k
SkullsS
14 de fevereiro de 2016 às 23:11

Deixa

FarathorF
14 de fevereiro de 2016 às 23:20

matei, só com o Knight e deu isso

 

[14/2/2016 23:19:30] [Error - CreatureScript Interface]
[14/2/2016 23:19:30] data/creaturescripts/scripts/CastleWar/CastleWar.lua:onDeath
[14/2/2016 23:19:30] Description:
[14/2/2016 23:19:30] data/creaturescripts/scripts/CastleWar/CastleWar.lua:87: attempt to compare nil with number
[14/2/2016 23:19:30] stack traceback:
[14/2/2016 23:19:30] data/creaturescripts/scripts/CastleWar/CastleWar.lua:87: in function <data/creaturescripts/scripts/CastleWar/CastleWar.lua:58>
eu modifiquei o que vc pediu,mas deixei assim, ve se esta certo
local st = getPlayerStorageValue(pid, 1827311)
local i = getPlayerVocation(pid)
local index = i%4
if index == 0 then index = 4 end
if not mx[i%4] then mx[i%4] = 0 end
if st > mx[index] then

 

SkullsS
14 de fevereiro de 2016 às 23:22

Manda o script novamente pra mim? valeu!

FarathorF
14 de fevereiro de 2016 às 23:24


local query = db.query or db.executeQuery

local premios = { -- -- [chance] -- itemid,amount

[{1, 5}] = {{12674}, {11754}},

[{10, 30}] = {{2390}, {2469}, {2646}, {8306,5}, {2408}},

[{80, 100}] = {{2160,1000}}

}

 

 

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

 

 

local vocation = {

"sorcerer",

"druid",

"paladin",

"knight"

}

 

 

function onDeath(cid, corpse, deathList)

local gid = 0

local winner = {}

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 = {}

for _, pid in pairs(getPlayersOnline()) do

if getPlayerGuildId(pid) == gid then

local st = getPlayerStorageValue(pid, 1827311)

local i = getPlayerVocation(pid)

local index = i%4

if index == 0 then index = 4 end

if not mx[i%4] then mx[i%4] = 0 end

if st > mx[index] then

mx[i%4] = st

winner[i%4] = pid

end

end

end

for i = 1, #winner do

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 rand[1] and rand[2] or 1)

end

end

local recompensa = doPlayerAddItem(winner, itemr, amountr)

doBroadcastMessage("{Castle War} O jogador com maior desempenho da vocação " ..vocation.." 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

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

SkullsS
14 de fevereiro de 2016 às 23:29

 

local query = db.query or db.executeQuery

local premios = { -- -- [chance] -- itemid,amount
[{1, 5}] = {{12674}, {11754}},
[{10, 30}] = {{2390}, {2469}, {2646}, {8306,5}, {2408}},
[{80, 100}] = {{2160,1000}}
}
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
local vocation = {
"sorcerer",
"druid",
"paladin",
"knight"
}
function onDeath(cid, corpse, deathList)
local gid = 0
local winner = {}
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 = {}
for _, pid in pairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == gid then
local st = getPlayerStorageValue(pid, 1827311)
local i = getPlayerVocation(pid)
local index = i%4
if index == 0 then index = 4 end
if not mx[index] then mx[index] = 0 end
if st > mx[index] then
mx[index] = st
winner[index] = pid
end
end
end
for i = 1, #winner do
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 rand[1] and rand[2] or 1)
end
end
local recompensa = doPlayerAddItem(winner, itemr, amountr)
doBroadcastMessage("{Castle War} O jogador com maior desempenho da vocação " ..vocation.." 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
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

 

 

 

Tente assim.

FarathorF
14 de fevereiro de 2016 às 23:42

o knight ainda nao consegue ganhar


acho que está com um problema olh,a acho que os hits nao estao sendo resetados, os hit dos players

 

23:40 {Castle War} O evento acabou, a guild com maior desempenho foi Infinity Alliance, com 100 pontos sobre o castelo.
23:40 {Castle War} O jogador com maior desempenho da vocação sorcerer foi Sorcerer, com 3.308 pontos sobre o castelo. Ele recebeu 1x ferumbras doll como premio.
SkullsS
14 de fevereiro de 2016 às 23:42

 

local query = db.query or db.executeQuery

local premios = { -- -- [chance] -- itemid,amount
[{1, 5}] = {{12674}, {11754}},
[{10, 30}] = {{2390}, {2469}, {2646}, {8306,5}, {2408}},
[{80, 100}] = {{2160,1000}}
}
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
local vocation = {
"sorcerer",
"druid",
"paladin",
"knight"
}
function onDeath(cid, corpse, deathList)
local gid = 0
local winner = {}
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 = {}
for _, pid in pairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == gid then
local st = getPlayerStorageValue(pid, 1827311)
local i = getPlayerVocation(pid)
local index = i%4
if i == 4 or i == 8 then index = 4 end
if not mx[index] then mx[index] = 0 end
if st > mx[index] then
mx[index] = st
winner[index] = pid
end
end
end
for i = 1, #winner do
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 rand[1] and rand[2] or 1)
end
end
local recompensa = doPlayerAddItem(winner, itemr, amountr)
doBroadcastMessage("{Castle War} O jogador com maior desempenho da vocação " ..vocation.." 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
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

 

 

FarathorF
15 de fevereiro de 2016 às 00:01
[14/2/2016 23:58:36] Knight has logged in.

[14/2/2016 23:59:7] > Broadcasted message: "{Castle War} O evento acabou, a guild com maior desempenho foi Infinity Alliance, com 553 pontos sobre o castelo.".


O Knight parece que nao ganha, e as outras vocações parece que não resetam os hit, vc deu uma olhada no arquivo da LIB q eu postei ?


00:01 {Castle War} O jogador com maior desempenho da vocação sorcerer foi Sorcerer, com 3.365 pontos sobre o castelo. Ele recebeu 1x ferumbras doll como premio.

viu

SkullsS
15 de fevereiro de 2016 às 00:34

Pra zerar você pode mudar o for do final:

 

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
setPlayerStorageValue(pid, 1827311, 0)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
end
end
Agora o knight eu nao estou entendendo .-.
FarathorF
15 de fevereiro de 2016 às 01:12

esse de resetar os pontos funcionou, mas tem um problema por exemplo, se o jogador não estiver dentro do castelo quando o evento acabar, ele vai acumular os pontos nao vai ?

SkullsS
15 de fevereiro de 2016 às 01:13

É mesmo, troque pra isso então:

 

for _, pid in pairs(getPlayersOnline()) do
setPlayerStorageValue(pid, 1827311, 0)
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

 

FarathorF
15 de fevereiro de 2016 às 01:28

Obrigado por tudo então cara, esse do knight ferrou em, rs


se tiver como, teria como ele mandar o prêmio, para o depot do jogador ?

 

vc nao tem ideia do que pode estar causadno o erro no knight?

 

vou testar com Elite knight para ver

SkullsS
15 de fevereiro de 2016 às 01:29

Ou então, coloca um doBroadcastMessage(index) depois de

if i == 4 or i == 8 then index = 4 end
if not mx[index] then mx[index] = 0 end
e me manda o que ele printou

 

FarathorF
15 de fevereiro de 2016 às 01:32

cara, acho que descobri o problema, as vocações promote não ganham também, ou seja, 4 ou maior que 4 não ganham

SkullsS
15 de fevereiro de 2016 às 01:34

Ah, então troca a porra toda ali de index por isso aqui, vê se da:

 

local st = getPlayerStorageValue(pid, 1827311)
local i = getPlayerVocation(pid)
local index = i
if index > 4 then index = index - 4 end
if st > mx[index] then