De fato, esta mensagem é muito grande para um FYI.
Troque:
doPlayerPopupFYI(cid, str)
por:
doShowTextDialog(cid, 2160, str)
Por kaleudd, 05 de dez. de 2016 em Resolvidos
De fato, esta mensagem é muito grande para um FYI.
Troque:
doPlayerPopupFYI(cid, str)
por:
doShowTextDialog(cid, 2160, str)
3 minutos atrás, zipter98 disse:De fato, esta mensagem é muito grande para um FYI.
Troque:
doPlayerPopupFYI(cid, str)por:
doShowTextDialog(cid, 2160, str)
a janela fico esquesita e desajeitada,não teria como fazer como eu pedi será?,tipo /shop lista2
Editado Dezembro 5 por kaleudd
Para evitar que a ordem dos pokémon na lista seja aleatória (ou seja, para que seja mostrada exatamente na ordenação que você configurou), é melhor estruturar a tabela de outra forma:
local pokemon = { {name = "nome_do_pokémon", price = xxx, boost = xxx}, --etc}
Depois, troque:
if p == "lista" then local str = "******** You can buy: ********" for p_name, info in pairs(pokemon) do str = str.."\n-"..p_name.." [+"..info.boost.."] for "..info.price.." premium point(s)." end doPlayerPopupFYI(cid, str)
por:
if p:find("lista") then local str, n = "******** You can buy: ********", tonumber(p:explode(" ")[2]) if n > math.ceil(#pokemon / 15) then doPlayerSendCancel(cid, "There are only lists from 1 to "..math.ceil(#pokemon / 15)..".") return true end for i = (15 * (n - 1)) + 1, 15 * n do local poke = pokemon[i] if not poke then break end str = str.."\n-"..poke.name.." [+"..poke.boost.."] for "..poke.price.." premium point(s)." end doPlayerPopupFYI(cid, str)
O comando para mostrar a lista será o seguinte:
/comando lista n --Sendo n o número da lista. Cada lista contém 15 pokémon.
Editado Dezembro 5 por zipter98
erro ao iniciar servidor distro,e com isso o sistema do shop inteiro comando não funfa
[05/12/2016 20:34:56] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/shop.lua:63: '<eof>' expected near 'end'
[05/12/2016 20:34:56] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/shop.lua)
[05/12/2016 20:34:56] data/talkactions/scripts/shop.lua:63: '<eof>' expected near 'end'
script:
local pokemon = {
{name = "Groudon", price = 100, boost = 100},
{name = "Kyogre", price = 100, boost = 100},
{name = "Abra", price = 100, boost = 100},
{name = "Aerodactyl", price = 100, boost = 100},
{name = "Alakazam", price = 100, boost = 100},
{name = "Arbok", price = 100, boost = 100},
{name = "Arcanine", price = 100, boost = 100},
{name = "Articuno", price = 100, boost = 100},
{name = "Beedrill", price = 100, boost = 100},
{name = "Bellsprout", price = 100, boost = 100},
{name = "Blastoise", price = 100, boost = 100},
{name = "Bulbasaur", price = 100, boost = 100},
{name = "Cubone", price = 100, boost = 100},
{name = "Dugtrio", price = 100, boost = 100},
{name = "Fearow", price = 100, boost = 100},
{name = "Charmander", price = 100, boost = 100},
{name = "Gloom", price = 100, boost = 100},
--etc
}
function doCorrectString(str) --Slicer
local name = str:explode(" ")
local final = {}
for _, s in ipairs(name) do
table.insert(final, s:sub(1, 1):upper()..s:sub(2, #s):lower())
end
return table.concat(final, (name[2] and " " or ""))
end
if p:find() == "lista" then
local str, n = "******** You can buy: ********", tonumber(p:explode(" ")[2])
if n > math.ceil(#pokemon / 15) then
doPlayerSendCancel(cid, "There are only lists from 1 to "..math.ceil(#pokemon / 15)..".")
return true
end
for i = (15 * (n - 1)) + 1, 15 * n do
local poke = pokemon
if not poke then break end
str = str.."\n-"..poke.name.." [+"..poke.boost.."] for "..poke.price.." premium point(s)."
end
doPlayerPopupFYI(cid, str)
elseif pokemon[doCorrectString(p)] then
local poke = pokemon[doCorrectString(p)]
if getAccountPoints(cid) < poke.price then
doPlayerSendCancel(cid, "Sorry, you do not have enough points. ["..poke.price.." premium points]")
return true
end
doPlayerSendTextMessage(cid, 27, "You successfully bought a "..doCorrectString(p).." [+"..poke.boost.."] for "..poke.price.." premium point(s).")
doAccountRemovePoints(cid, poke.price)
addPokeToPlayer(cid, doCorrectString(p), poke.boost, nil, "normal")
else
doPlayerSendCancel(cid, "Invalid parameter. Type 'list' to see a list of pokemon you can buy, or type the name of the wished pokemon.")
end
return true
end
Você esqueceu do callback.
local pokemon = { {name = "Groudon", price = 100, boost = 100}, {name = "Kyogre", price = 100, boost = 100}, {name = "Abra", price = 100, boost = 100}, {name = "Aerodactyl", price = 100, boost = 100}, {name = "Alakazam", price = 100, boost = 100}, {name = "Arbok", price = 100, boost = 100}, {name = "Arcanine", price = 100, boost = 100}, {name = "Articuno", price = 100, boost = 100}, {name = "Beedrill", price = 100, boost = 100}, {name = "Bellsprout", price = 100, boost = 100}, {name = "Blastoise", price = 100, boost = 100}, {name = "Bulbasaur", price = 100, boost = 100}, {name = "Cubone", price = 100, boost = 100}, {name = "Dugtrio", price = 100, boost = 100}, {name = "Fearow", price = 100, boost = 100}, {name = "Charmander", price = 100, boost = 100}, {name = "Gloom", price = 100, boost = 100}, --etc}function doCorrectString(str) --Slicer local name = str:explode(" ") local final = {} for _, s in ipairs(name) do table.insert(final, s:sub(1, 1):upper()..s:sub(2, #s):lower()) end return table.concat(final, (name[2] and " " or ""))endfunction onSay(cid, words, param) local p = param:lower() if p:find("lista") then local str, n = "******** You can buy: ********", tonumber(p:explode(" ")[2]) if n > math.ceil(#pokemon / 15) then doPlayerSendCancel(cid, "There are only lists from 1 to "..math.ceil(#pokemon / 15)..".") return true end for i = (15 * (n - 1)) + 1, 15 * n do local poke = pokemon if not poke then break end str = str.."\n-"..poke.name.." [+"..poke.boost.."] for "..poke.price.." premium point(s)." end doPlayerPopupFYI(cid, str) elseif pokemon[doCorrectString(p)] then local poke = pokemon[doCorrectString(p)] if getAccountPoints(cid) < poke.price then doPlayerSendCancel(cid, "Sorry, you do not have enough points. ["..poke.price.." premium points]") return true end doPlayerSendTextMessage(cid, 27, "You successfully bought a "..doCorrectString(p).." [+"..poke.boost.."] for "..poke.price.." premium point(s).") doAccountRemovePoints(cid, poke.price) addPokeToPlayer(cid, doCorrectString(p), poke.boost, nil, "normal") else doPlayerSendCancel(cid, "Invalid parameter. Type 'list' to see a list of pokemon you can buy, or type the name of the wished pokemon.") end return trueend
Editado Dezembro 5 por zipter98
isso corrigiu agr deu outro,ao digitar o /comando lista 2 ou outra pagina
apareçe na distro
[05/12/2016 21:10:03] [Error - TalkAction Interface]
[05/12/2016 21:10:03] data/talkactions/scripts/shop.lua:onSay
[05/12/2016 21:10:03] Description:
[05/12/2016 21:10:03] data/talkactions/scripts/shop.lua:35: bad argument #1 to 'find' (string expected, got no value)
[05/12/2016 21:10:03] stack traceback:
[05/12/2016 21:10:03] [C]: in function 'find'
[05/12/2016 21:10:03] data/talkactions/scripts/shop.lua:35: in function <data/talkactions/scripts/shop.lua:32>
Wow, tanto tempo sem scriptear me fez esquecer como funcionava o string.find.
Troque:
if p:find() == "lista" then
por:
if p:find("lista") then
agora ao digitar comando lista 2
apareçe
[05/12/2016 21:35:06] [Error - TalkAction Interface]
[05/12/2016 21:35:06] data/talkactions/scripts/shop.lua:onSay
[05/12/2016 21:35:06] Description:
[05/12/2016 21:35:06] data/talkactions/scripts/shop.lua:47: attempt to concatenate field 'price' (a nil value)
[05/12/2016 21:35:06] stack traceback:
[05/12/2016 21:35:06] data/talkactions/scripts/shop.lua:47: in function <data/talkactions/scripts/shop.lua:32>
script:
local pokemon = {
{name = "Groudon", price = 100, boost = 100},
{name = "Kyogre", price = 100, boost = 100},
{name = "Abra", price = 100, boost = 100},
{name = "Aerodactyl", price = 100, boost = 100},
{name = "Alakazam", price = 100, boost = 100},
{name = "Arbok", price = 100, boost = 100},
{name = "Arcanine", price = 100, boost = 100},
{name = "Articuno", price = 100, boost = 100},
{name = "Beedrill", price = 100, boost = 100},
{name = "Bellsprout", price = 100, boost = 100},
{name = "Blastoise", price = 100, boost = 100},
{name = "Bulbasaur", price = 100, boost = 100},
{name = "Cubone", price = 100, boost = 100},
{name = "Dugtrio", price = 100, boost = 100},
{name = "Fearow", price = 100, boost = 100},
{name = "Charmander", price = 100, boost = 100},
{name = "Gloom", price = 100, boost = 100},
--etc
}
function doCorrectString(str) --Slicer
local name = str:explode(" ")
local final = {}
for _, s in ipairs(name) do
table.insert(final, s:sub(1, 1):upper()..s:sub(2, #s):lower())
end
return table.concat(final, (name[2] and " " or ""))
end
function onSay(cid, words, param)
local p = param:lower()
if p:find("lista") then
local str, n = "******** You can buy: ********", tonumber(p:explode(" ")[2])
if n > math.ceil(#pokemon / 15) then
doPlayerSendCancel(cid, "There are only lists from 1 to "..math.ceil(#pokemon / 15)..".")
return true
end
for i = (15 * (n - 1)) + 1, 15 * n do
local poke = pokemon
if not poke then break end
str = str.."\n-"..poke.name.." [+"..poke.boost.."] for "..poke.price.." premium point(s)."
end
doPlayerPopupFYI(cid, str)
elseif pokemon[doCorrectString(p)] then
local poke = pokemon[doCorrectString(p)]
if getAccountPoints(cid) < poke.price then
doPlayerSendCancel(cid, "Sorry, you do not have enough points. ["..poke.price.." premium points]")
return true
end
doPlayerSendTextMessage(cid, 27, "You successfully bought a "..doCorrectString(p).." [+"..poke.boost.."] for "..poke.price.." premium point(s).")
doAccountRemovePoints(cid, poke.price)
addPokeToPlayer(cid, doCorrectString(p), poke.boost, nil, "normal")
else
doPlayerSendCancel(cid, "Invalid parameter. Type 'list' to see a list of pokemon you can buy, or type the name of the wished pokemon.")
end
return true
end
Editado Dezembro 5 por kaleudd
Ugh, esqueci de reescrever a parte de baixo do código com base na nova estrutura da tabela. Estou meio enferrujado, desculpe-me.
local pokemon = { {name = "Groudon", price = 100, boost = 100}, {name = "Kyogre", price = 100, boost = 100}, {name = "Abra", price = 100, boost = 100}, {name = "Aerodactyl", price = 100, boost = 100}, {name = "Alakazam", price = 100, boost = 100}, {name = "Arbok", price = 100, boost = 100}, {name = "Arcanine", price = 100, boost = 100}, {name = "Articuno", price = 100, boost = 100}, {name = "Beedrill", price = 100, boost = 100}, {name = "Bellsprout", price = 100, boost = 100}, {name = "Blastoise", price = 100, boost = 100}, {name = "Bulbasaur", price = 100, boost = 100}, {name = "Cubone", price = 100, boost = 100}, {name = "Dugtrio", price = 100, boost = 100}, {name = "Fearow", price = 100, boost = 100}, {name = "Charmander", price = 100, boost = 100}, {name = "Gloom", price = 100, boost = 100}, --etc}function doCorrectString(str) --Slicer local name = str:explode(" ") local final = {} for _, s in ipairs(name) do table.insert(final, s:sub(1, 1):upper()..s:sub(2, #s):lower()) end return table.concat(final, (name[2] and " " or ""))endfunction onSay(cid, words, param) local p, poke = param:lower(), {} if p:find("lista") then local str, n = "******** You can buy: ********", tonumber(p:explode(" ")[2]) if n > math.ceil(#pokemon / 15) then doPlayerSendCancel(cid, "There are only lists from 1 to "..math.ceil(#pokemon / 15)..".") return true end for i = (15 * (n - 1)) + 1, 15 * n do local poke = pokemon if not poke then break end str = str.."\n-"..poke.name.." [+"..poke.boost.."] for "..poke.price.." premium point(s)." end doPlayerPopupFYI(cid, str) else local poke for i = 1, #pokemon do if pokemon[i].name == doCorrectString(p) then poke = pokemon[i] break end end if poke then if getAccountPoints(cid) < poke.price then doPlayerSendCancel(cid, "Sorry, you do not have enough points. ["..poke.price.." premium points]") return true end doPlayerSendTextMessage(cid, 27, "You successfully bought a "..poke.name.." [+"..poke.boost.."] for "..poke.price.." premium point(s).") doAccountRemovePoints(cid, poke.price) addPokeToPlayer(cid, poke.name, poke.boost, nil, "normal") else doPlayerSendCancel(cid, "Invalid parameter. Type 'list' to see a list of pokemon you can buy, or type the name of the wished pokemon.") end end return trueend
Editado Dezembro 5 por zipter98
hehe de boas,deu mais 2 erros,mais agora é pessivel comprar o pokémon normalmente,mais o /comando lista não funciona,após digitalo da o seguinte erro:
[05/12/2016 21:46:54] [Error - TalkAction Interface]
[05/12/2016 21:46:54] data/talkactions/scripts/shop.lua:onSay
[05/12/2016 21:46:54] Description:
[05/12/2016 21:46:54] data/talkactions/scripts/shop.lua:38: attempt to compare number with nil
[05/12/2016 21:46:54] stack traceback:
[05/12/2016 21:48:47] [Error - TalkAction Interface]
[05/12/2016 21:48:47] data/talkactions/scripts/shop.lua:onSay
[05/12/2016 21:48:47] Description:
[05/12/2016 21:48:47] data/talkactions/scripts/shop.lua:47: attempt to concatenate field 'price' (a nil value)
[05/12/2016 21:48:47] stack traceback:
Editado Dezembro 5 por kaleudd
Up
info
Grupo: Herói
Registrado: 07/03/16
Posts: 1.4k
Reputação: +385
Gênero: Masculino

Substitui isto:
Citarfor i = (15 * (n - 1)) + 1, 15 * n do local poke = pokemon if not poke then break end str = str.."\n-"..poke.name.." [+"..poke.boost.."] for "..poke.price.." premium point(s)." end
Por isso:
Citarfor index = (15 * (n - 1)) + 1, 15 * n do
local poke = pokemon[index]
if not poke then break end
str = str.."\n-"..poke.name.." [+"..poke.boost.."] for "..poke.price.." premium point(s)."
end
Parece que eu tinha feito isso no primeiro código que postei, mas o autor copiou errado, e, como copiei o dele para corrigir, acabei deixando isso passar. lol
Obrigado, mesmo assim.
Editado Dezembro 6 por zipter98
info
Grupo: Conde
Registrado: 15/06/15
Posts: 729
Reputação: +200
estou com um problema eu um script criado pelo @zipter98,que consiste e comprar um pokémon por x pokémon,até ai tudo bem,mais ao usar /shop list acontece o seguinte erro:
[Warning - ProtocolGame::sendFYIBox] Trying to send an empty or too huge message.
creio que seja que adicionei muitos pokemon na lista,segue script:
local pokemon = {
["Groudon"] = {price = 50, boost = 100},
["Kyogre"] = {price = 55, boost = 100},
["Abra"] = {price = 55, boost = 100},
["Aerodactyl"] = {price = 55, boost = 100},
["Alakazam"] = {price = 55, boost = 100},
["Arbok"] = {price = 55, boost = 100},
["Arcanine"] = {price = 55, boost = 100},
["Articuno"] = {price = 55, boost = 100},
["Beedrill"] = {price = 55, boost = 100},
["Bellsprout"] = {price = 55, boost = 100},
["Blastoise"] = {price = 55, boost = 100},
["Bulbasaur"] = {price = 55, boost = 100},
["Butterfree"] = {price = 55, boost = 100},
["Caterpie"] = {price = 55, boost = 100},
["Chansey"] = {price = 55, boost = 100},
["Charizard"] = {price = 55, boost = 100},
["Charmander"] = {price = 55, boost = 100},
["Charmeleon"] = {price = 55, boost = 100},
["Clefable"] = {price = 55, boost = 100},
["Clefairy"] = {price = 55, boost = 100},
["Cloyster"] = {price = 55, boost = 100},
["Cubone"] = {price = 55, boost = 100},
["Dodrio"] = {price = 55, boost = 100},
["Doduo"] = {price = 55, boost = 100},
["Dragonair"] = {price = 55, boost = 100},
["Dugtrio"] = {price = 55, boost = 100},
["Electabuzz"] = {price = 55, boost = 100},
["Electrode"] = {price = 55, boost = 100},
["Fearow"] = {price = 55, boost = 100},
["Gengar"] = {price = 55, boost = 100},
["Gloom"] = {price = 55, boost = 100},
--etc
}
function doCorrectString(str) --Slicer
local name = str:explode(" ")
local final = {}
for _, s in ipairs(name) do
table.insert(final, s:sub(1, 1):upper()..s:sub(2, #s):lower())
end
return table.concat(final, (name[2] and " " or ""))
end
function onSay(cid, words, param)
local p = param:lower()
if p == "lista" then
local str = "******** You can buy: ********"
for p_name, info in pairs(pokemon) do
str = str.."\n-"..p_name.." [+"..info.boost.."] for "..info.price.." premium point(s)."
end
doPlayerPopupFYI(cid, str)
elseif pokemon[doCorrectString(p)] then
local poke = pokemon[doCorrectString(p)]
if getAccountPoints(cid) < poke.price then
doPlayerSendCancel(cid, "Sorry, you do not have enough points. ["..poke.price.." premium points]")
return true
end
doPlayerSendTextMessage(cid, 27, "You successfully bought a "..doCorrectString(p).." [+"..poke.boost.."] for "..poke.price.." premium point(s).")
doAccountRemovePoints(cid, poke.price)
addPokeToPlayer(cid, doCorrectString(p), poke.boost, nil, "normal")
else
doPlayerSendCancel(cid, "Invalid parameter. Type 'list' to see a list of pokemon you can buy, or type the name of the wished pokemon.")
end
return true
end
gostaria de saber se teria como fazer a lista em duas partes,por exemplo o player digita /shop lista,apareçe um popup com os pokémon daquela lista,depois ele digita /shop lista2 e apareçe da lista 2,assim creio que arrumaria o erro,pois aconteçe ao adicionar muitos pokémon em uma só lista,obrigado!