Postado Fevereiro 8, 2015 10 anos oi gente estou com erro e um bug no comando de !rankclan do meu server - Motivo do Erro: o Jogador que nao tem Clan digita !rankclan 1 - e causa esse Erro: [08/02/2015 13:09:31] [Error - TalkAction Interface] [08/02/2015 13:09:31] data/talkactions/scripts/cl.lua:onSay [08/02/2015 13:09:31] Description: [08/02/2015 13:09:31] data/talkactions/scripts/cl.lua:52: attempt to index local 'levels' (a nil value) [08/02/2015 13:09:31] stack traceback: [08/02/2015 13:09:31] data/talkactions/scripts/cl.lua:52: in function - Motivo do Bug : Funciona em todos os Clans , Menos em Clan [Voulcanic]. e fala a seguinte msg: 13:10 [Clan] Você nao tem Clan! - Script do Comando: function onSay(cid, words, param) local clans = {"Volcanic", "Seavell", "Orebound", "Wingeon", "Malefic", "Gardestrike", "Psycraft", "Naturia", "Raibolt"} local t = string.explode(param, ",") if words == "!entrarclan" then if param == "" then return doPlayerSendCancel(cid, "Estão faltando os parâmetros!") end local clan = t[1] if getPlayerLevel(cid) < 80 then return doPlayerSendCancel(cid, "Você precisa ser level 80 para entrar em um clan.") end if not isInArray(clans, t[1]) then return doPlayerSendCancel(cid, ""..clan.." não é um clan válido.") end if getPlayerStorageValue(cid, 86228) >= 1 then return doPlayerSendCancel(cid, "Você já está em um clan.") end setPlayerClan(cid, clan) doPlayerSendTextMessage(cid, 19, "Agora você pertence ao Clan ["..clan.."], rank: 1") setPlayerClanRank(cid, 1) elseif words == "!rankclan" then if param == "" then return doPlayerSendTextMessage(cid, 19, "[Clan] Digita o Numero ex: !rankclan 1!") end local ta = { [2] = {level = 100}, [3] = {level = 125}, [4] = {level = 150}, [5] = {level = 200}, } local money = 2160 local qntt = 5 local levels = ta[(getPlayerStorageValue(cid, 862281) + 1)] local lv = levels.level if getPlayerStorageValue(cid, 862281) >= tonumber(t[1]) then return doPlayerSendTextMessage(cid, 19, "[Clan] Você já passou desse rank.") end if tonumber(t[1]) >= tonumber((getPlayerStorageValue(cid, 862281)) + 2) then return doPlayerSendTextMessage(cid, 19, "[Clan] Você não pode fazer isso!") end if getPlayerStorageValue(cid, 86228) == 1 then return doPlayerSendTextMessage(cid, 27, "[Clan] Você nao tem Clan!") end if getPlayerLevel(cid) < lv then return doPlayerSendTextMessage(cid, 19,"[Clan] Você não possui o level necessário.") end if getPlayerItemCount(cid, money) >= qntt then doPlayerRemoveItem(cid, money, qntt) else return doPlayerSendTextMessage(cid, 19,"[Clan] Você não Tem [5] Thousand Dollars Para Avançar de Rank!.") end setPlayerClanRank(cid, getPlayerStorageValue(cid, 862281) + 1) doPlayerSendTextMessage(cid, 27, "[Clan] Você avançou de rank! Rank atual: ["..getPlayerStorageValue(cid, 862281).."].") elseif words == "!trocarclan" then local item = 2160 --ID do item. local qnt = 1 --Quantidade do item. local to_go = t[1] if param == "" then return doPlayerSendCancel(cid, "Estão faltando os parâmetros!") end if not isInArray(clans, t[1]) then return doPlayerSendCancel(cid, ""..t[1].." não é um clan válido.") end if getPlayerStorageValue(cid, 86228) < 1 then return doPlayerSendCancel(cid, "Você não pertence a clan algum!") end if getPlayerItemCount(cid, item) >= qnt then doPlayerRemoveItem(cid, item, qnt) doPlayerSendTextMessage(cid, 27, "Você trocou de clan, pertencendo agora ao clan: "..t[1]..".") setPlayerClan(cid, to_go) setPlayerClanRank(cid, 1) else return doPlayerSendCancel(cid, "Você não tem o item necessário! ITEM: "..item.." QUANTIDADE: "..qnt..".") end end return true end Obrigado Desde Ja e Rep++ Para quem Ajudar! =) Editado Fevereiro 8, 2015 10 anos por Rodrigo Augusto (veja o histórico de edições)
Postado Fevereiro 8, 2015 10 anos Faz o seguinte: acima de: local levels = ta[(getPlayerStorageValue(cid, 862281) + 1)] coloca: print(getPlayerStorageValue(cid, 862281)) E envia o que for imprimido na distro. Ah, também coloca isso: if getPlayerStorageValue(cid, 86228) == 1 then return doPlayerSendTextMessage(cid, 27, "[Clan] Você nao tem Clan!") end acima disso: if param == "" then return doPlayerSendTextMessage(cid, 19, "[Clan] Digita o Numero ex: !rankclan 1!") end Editado Fevereiro 8, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Postado Fevereiro 9, 2015 10 anos Autor Faz o seguinte: acima de: local levels = ta[(getPlayerStorageValue(cid, 862281) + 1)] coloca: print(getPlayerStorageValue(cid, 862281)) E envia o que for imprimido na distro. Ah, também coloca isso: if getPlayerStorageValue(cid, 86228) == 1 then return doPlayerSendTextMessage(cid, 27, "[Clan] Você nao tem Clan!") end acima disso: if param == "" then return doPlayerSendTextMessage(cid, 19, "[Clan] Digita o Numero ex: !rankclan 1!") end Aparece o valor [1] no executavel: [09/02/2015 12:42:11] 1 - O Erro que tinha quando digitava o comando !rankclan sem ter Clan : Arrumado - So Falta agora arrumar o Bug (Clan Vulcanic nao Sobe de Rank) =s Tem a Lib tambem do clan system é o seguinte o Print que da no Console é o valor da Storage quando nao tenhu nenhuma clan o Valor fica [-1] Foi eu que coloquei esse valor no script . - Quando eu entro em uma clan e digito !rankclan "Numero" o valor da storage é pego dessa tabela do 1 ao 9 : local clansName = { --[num do clan] = {nome do clan, storage outfit normal, storage outfit rank5}, [1] = {'Volcanic', 181613, 181625}, [2] = {'Seavell', 181619, 181622}, [3] = {'Orebound', 181620, 181627}, [4] = {'Wingeon', 181616, 181626}, [5] = {'Malefic', 181615, 181624}, [6] = {'Gardestrike', 181614, 181628}, [7] = {'Psycraft', 181618, 181629}, [8] = {'Naturia', 181612, 181623}, [9] = {'Raibolt', 181617, 181621}, } - o do Volcanic continua normal porem nao esta querendo aumentar (acumular) a storage assim: setPlayerClanRank(cid, getPlayerStorageValue(cid, 862281) + 1) ------ +1 - Esta aki o script da Lib Caso eu esteja Errado : local clansAtk = { [1] = { [FIREDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, ["null"] = { }, }, [2] = { [WATERDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, [iCEDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, }, [3] = { [ROCKDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, [GROUNDDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, }, [4] = { [FLYDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, [DRAGONDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, }, [5] = { [GHOSTDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, [POISONDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, }, [6] = { [FIGHTDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, [NORMALDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, }, [7] = { [PSYCHICDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, ["null"] = { }, }, [8] = { [GRASSDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, [bUGDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, }, [9] = { [ELECTRICDAMAGE] = { [1] = {atk = 1}, [2] = {atk = 1.2}, [3] = {atk = 1.8}, [4] = {atk = 2.5}, [5] = {atk = 3.5}, }, ["null"] = { }, } } local clansDef = { [1] = { ["fire"] = { [1] = {def = 0.17}, [2] = {def = 0.22}, [3] = {def = 0.27}, [4] = {def = 0.32}, [5] = {def = 0.37}, }, ["null"] = { }, }, [2] = { ["water"] = { [1] = {def = 0.05}, [2] = {def = 0.10}, [3] = {def = 0.15}, [4] = {def = 0.20}, [5] = {def = 0.25}, }, ["ice"] = { [1] = {def = 0.10}, [2] = {def = 0.15}, [3] = {def = 0.20}, [4] = {def = 0.25}, [5] = {def = 0.30}, }, }, [3] = { ["rock"] = { [1] = {def = 0.05}, [2] = {def = 0.10}, [3] = {def = 0.15}, [4] = {def = 0.20}, [5] = {def = 0.25}, }, ["ground"] = { [1] = {def = 0.10}, [2] = {def = 0.15}, [3] = {def = 0.20}, [4] = {def = 0.25}, [5] = {def = 0.30}, }, }, [4] = { ["flying"] = { [1] = {def = 0.15}, [2] = {def = 0.20}, [3] = {def = 0.25}, [4] = {def = 0.30}, [5] = {def = 0.35}, }, ["dragon"] = { [1] = {def = 0.10}, [2] = {def = 0.15}, [3] = {def = 0.20}, [4] = {def = 0.25}, [5] = {def = 0.30}, }, }, [5] = { ["ghost"] = { [1] = {def = 0.05}, [2] = {def = 0.10}, [3] = {def = 0.15}, [4] = {def = 0.20}, [5] = {def = 0.25}, }, ["poison"] = { [1] = {def = 0.08}, [2] = {def = 0.13}, [3] = {def = 0.18}, [4] = {def = 0.23}, [5] = {def = 0.28}, }, }, [6] = { ["fighting"] = { [1] = {def = 0.05}, [2] = {def = 0.10}, [3] = {def = 0.15}, [4] = {def = 0.20}, [5] = {def = 0.25}, }, ["normal"] = { [1] = {def = 0.05}, [2] = {def = 0.10}, [3] = {def = 0.15}, [4] = {def = 0.20}, [5] = {def = 0.25}, }, }, [7] = { ["psychic"] = { [1] = {def = 0.10}, [2] = {def = 0.15}, [3] = {def = 0.20}, [4] = {def = 0.25}, [5] = {def = 0.30}, }, ["null"] = { }, }, [8] = { ["grass"] = { [1] = {def = 0.05}, [2] = {def = 0.10}, [3] = {def = 0.15}, [4] = {def = 0.20}, [5] = {def = 0.25}, }, ["bug"] = { [1] = {def = 0.05}, [2] = {def = 0.10}, [3] = {def = 0.15}, [4] = {def = 0.20}, [5] = {def = 0.25}, }, }, [9] = { ["electric"] = { [1] = {def = 0.12}, [2] = {def = 0.17}, [3] = {def = 0.22}, [4] = {def = 0.27}, [5] = {def = 0.32}, }, } } function getClanPorcent(master, combat, option, type, type2) --alterado v2.9 \/ if getPlayerClanNum(master) >= 1 then local clanAtk = clansAtk[getPlayerClanNum(master)] local clanDef = clansDef[getPlayerClanNum(master)] if option == "atk" and clanAtk[combat] then return clanAtk[combat][getPlayerClanRank(master)].atk else if option == "def" and clanDef[type] then return clanDef[type][getPlayerClanRank(master)].def elseif option == "def" and clanDef[type2] then return clanDef[type2][getPlayerClanRank(master)].def end end end return option == "atk" and 1 or 0 end --alterado v2.7 \/\/ local clansName = { --[num do clan] = {nome do clan, storage outfit normal, storage outfit rank5}, [1] = {'Volcanic', 181613, 181625}, [2] = {'Seavell', 181619, 181622}, [3] = {'Orebound', 181620, 181627}, [4] = {'Wingeon', 181616, 181626}, [5] = {'Malefic', 181615, 181624}, [6] = {'Gardestrike', 181614, 181628}, [7] = {'Psycraft', 181618, 181629}, [8] = {'Naturia', 181612, 181623}, [9] = {'Raibolt', 181617, 181621}, } function getPlayerClanName(cid) if not isCreature(cid) then return 'No Clan!' end return clansName[getPlayerStorageValue(cid, 86228)] and clansName[getPlayerStorageValue(cid, 86228)][1] or 'No Clan!' end function getPlayerClanNum(cid) if not isCreature(cid) then return 0 end return getPlayerStorageValue(cid, 86228) end function getPlayerClanRank(cid) if not isCreature(cid) then return -1 end return getPlayerStorageValue(cid, 862281) end function setPlayerClan(cid, clan) if not isCreature(cid) or not clan then return false end if removePlayerClan(cid) then --para evitar possiveis problemas! if type(clan) == "number" and (clan >= 1 and clan <= 9) then setPlayerStorageValue(cid, 86228, clan) --sto clan setPlayerClanRank(cid, 1) --set rank 1 setPlayerStorageValue(cid, clansName[clan][2], 1) --sto roupa return true elseif type(clan) == "string" then clan = string.lower(clan) for e, f in pairs(clansName) do local clan2 = string.lower(f[1]) if clan == clan2 then setPlayerStorageValue(cid, 86228, e) --sto clan setPlayerClanRank(cid, 1) --set rank 1 setPlayerStorageValue(cid, clansName[e][2], 1) --sto roupa return true end end end else return false end return false end function setPlayerClanRank(cid, rank) if not isCreature(cid) or not rank then return false end if type(rank) == "number" and (rank >= 1 and rank <= 5) then setPlayerStorageValue(cid, 862281, rank) if rank == 5 then setPlayerStorageValue(cid, clansName[getPlayerClanNum(cid)][3], 1) end return true end return false end function removePlayerClan(cid) if not isCreature(cid) then return false end if getPlayerStorageValue(cid, 854789) >= 1 then return false end --nao pode remover o clan se o player tiver fazendo missoes de rank! setPlayerStorageValue(cid, 86228, -1) --sto do clan setPlayerStorageValue(cid, 862281, -1) --sto do rank setPlayerStorageValue(cid, 854789, -1) --sto da quest de rank setPlayerStorageValue(cid, 854788, -1) --sto catch, quest de rank setPlayerStorageValue(cid, 854787, -1) --sto task, quest de rank for i = 181612, 181638 do setPlayerStorageValue(cid, i, -1) --sto das roupas de clan end return true end function checkItensForTask(cid, itens) local check = 0 local array = {} local missing = "Are missing: " local c = 0 for i = 1, #itens do if getPlayerItemCount(cid, itens[1]) >= itens[2] then check = check + 1 else table.insert(array, {itens[1], (itens[2]-getPlayerItemCount(cid, itens[1]))}) end end if check == #itens then for b = 1, #itens do doPlayerRemoveItem(cid, itens[1], itens[2]) end return 0 else for a = 1, #array do missing = missing..((a == #array and c ~= 0) and " and " or a ~= 1 and ", " or "{")..(array[a][2]).." "..(getItemNameById(array[a][1])) c = c+1 end return missing.."} yet." end end function checkPokemonForTask(cid, poke) local pbs = getPokeballsInContainer(getPlayerSlotItem(cid, 3).uid) local slot = getPlayerSlotItem(cid, 8) if slot.itemid > 0 and isPokeball(slot.itemid) then if getItemAttribute(slot.uid, "poke") == poke and getItemAttribute(slot.uid, "task") and getItemAttribute(slot.uid, "task") >= 1 then doRemoveItem(slot.uid, 1) doTransformItem(getPlayerSlotItem(cid, CONST_SLOT_LEGS).uid, 2395) return true end end for i = 1, #pbs do if getItemAttribute(pbs, "poke") == poke and getItemAttribute(pbs, "task") and getItemAttribute(pbs, "task") >= 1 then doRemoveItem(pbs, 1) return true end end return false end Editado Fevereiro 9, 2015 10 anos por Rodrigo Augusto (veja o histórico de edições)
Postado Fevereiro 10, 2015 10 anos Solução Calma aí, se o jogador for Volcanic e digitar o comando, aparece a mensagem [Clan] Você nao tem Clan!? Se for isso, basta mudar: if getPlayerStorageValue(cid, 86228) == 1 then return doPlayerSendTextMessage(cid, 27, "[Clan] Você nao tem Clan!") end para: if getPlayerStorageValue(cid, 86228) < 1 then return doPlayerSendTextMessage(cid, 27, "[Clan] Você nao tem Clan!") end Já que o valor da storage 86228 referente ao clan Volcanic é 1, a checagem de o jogador ter ou não clan está sendo feita de maneira errada. Editado Fevereiro 10, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.