naldo ghost
Radagast
- Joined
- Jul 1, 2012
- Messages
- 2
- Reaction score
- 0
The code works fine, but when i say "Hi" to NPC appears an error on console:
The code:
Code:
[15:44:53.603] [Error - NpcScript Interface]
[15:44:53.603] data/npc/scripts/desertArena.lua:OnCreatureSay
[15:44:53.603] Description:
[15:44:53.603] (internalGetPlayerInfo) Player not found when requesting player info #26
The code:
Code:
local npcGen = newNpc("Turing")
npcGen:setHiMsg("Greetings %s, I am the master of Arenas, I could HELP you if you want to participate.", "Olá %s, eu sou o mestre das Arenas, eu posso te AJUDAR se você desejar participar.")
npcGen:needPremium(false)
local function checkRoom(posRoom)
for y = posRoom[1].y, posRoom[2].y do
for x = posRoom[1].x, posRoom[2].x do
local creature = getThingfromPos({x = x, y = y, z = posRoom[1].z, stackpos = 255})
if creature.uid > 0 then
if isPlayer(creature.uid) then
return true
elseif isMonster(creature.uid) then
doRemoveCreature(creature.uid)
end
end
end
end
return false
end
function onCreatureSay(cid, type, msg)
local firstRoom = {{x = 712, y = 429, z = 7}, {x = 718, y = 435, z = 7}, {x = 715, y = 432, z = 7}} -- room1: top-left, bottom-right, center
local creatures = {"Slicefang Scorpion", "Orc Berserker", "Baby Dragon"}
local values = {
[0] = {20, 1000, "easy arena", "arena fácil"},
[1] = {50, 5000, "medium arena", "arena média"},
[2] = {80, 10000, "hard arena", "arena difícil"}
}
local crPos = firstRoom[3]
if isPlayerPzLocked(cid) then
npcGen:say('Não posso falar com você agora.', 'Não posso falar com você agora.')
return false
end
local msg = msg:lower()
npcGen:onSay(cid, type, msg,
function(stage)
if stage == 1 then
if msgcontains(msg, "help") or msgcontains(msg, "ajudar") or msgcontais(msg, "ajuda") then
npcGen:say("You can try entering the arena, if you win won an award for each type of difficulty: easy (level 20), medium (level 50) and hard (level 80). Do you want to enter?", "Você pode tentar entrar na arena, se vencer você ganha um prêmio para cada tipo de dificuldade: fácil (nível 20), médio (nível 50) e difícil (nível 80). Você quer entrar?")
npcGen:setStage(2)
end
elseif stage == 2 then
if msgcontains(msg, "sim") or msgcontains(msg, "yes") or msgcontais(msg, "yep") then
if getPlayerStorageValue(cid, "arenaChest") == -1 then
setPlayerStorageValue(cid, "arenaChest", 0)
end
local atualChest = getPlayerStorageValue(cid, "arenaChest")
if atualChest >= 3 then -- get OUT
npcGen:say("You already completed all arenas.", "Você já completou todas as arenas.")
return false
end
if getPlayerLevel(cid) < values[atualChest][1] then
npcGen:say("You need level ".. values[atualChest][1] .." to enter in " .. values[atualChest][3] .. ".", "Você precisa de nível " .. values[atualChest][1] .. " para entrar na " .. values[atualChest][4] .. ".")
return false
end
if checkRoom(firstRoom) then
npcGen:say("Already have a player in the first room, wait some time please.", "Tem um jogador na primeira sala, aguarde um pouquinho e quando ele for para a próxima sala você poderá entrar.")
return false
end
if doPlayerRemoveMoney(cid, values[atualChest][2]) == false then
npcGen:say("You need " .. values[atualChest][2] .. " gold coins to enter in " .. values[atualChest][3] .. ".", "Você precisa de " .. values[atualChest][2] .. " gold coins para entrar na " .. values[atualChest][4] .. ".")
return false
end
npcGen:say("Good luck, and may the Gods of Desert bless you!!!", "Boa sorte! Que os Deuses da Areia estejam com você!!!")
registerPlayerInQuest({player = cid, posExit = {x = 712, y = 414, z = 7}, globalStorage = "desertArena", cannotMoveItems = true, blockDeath = false})
doTeleportThing(cid, firstRoom[3])
doSendMagicEffect(getThingPos(cid), 10)
setPlayerStorageValue(cid, "arenaRoom", 1)
setPlayerStorageValue(cid, "arenaDifficult", atualChest + 1)
doSummonCreature(creatures[atualChest + 1], {x = crPos.x, y = crPos.y - 2, z = crPos.z})
elseif msgcontains(msg, "no") or msgcontains(msg, "não") or msgcontais(msg, "nao") then
npcGen:say("Okay then, see ya.", "Tudo bem então, até logo.")
npcGen:setStage(1)
return false
end
end
return true
end)
end
function onThink()
npcGen:onThink(false)
end
function onCreatureDisappear(cid, pos)
npcGen:onDisappear(cid, pos)
end
Last edited by a moderator: