Postado Abril 6, 2015 10 anos Autor Não testei: local money = xxxx -- Quanto vai custar local storage = 14542 -- Não mexer local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if player:getStorageValue(storage) == 1 then npcHandler:say('you have already received the promotion', cid) return true end if msgcontains(msg:lower(), 'promotion') then npcHandler:say('you are sure?', cid) npcHandler.topic[cid] = 1 end if msgcontains(msg:lower(), 'yes') and npcHandler.topic[cid] == 1 then if player:getPromotion() == 1 then if player:getVipDays() >= 1 then if player:removeMoney(money) then npcHandler:say('you just received a new promotion', cid) player:setVocation(player:getVocation() + 4) player:setStorageValue(storage, 1) npcHandler.topic[cid] = 0 else npcHandler:say('you no have money', cid) npcHandler.topic[cid] = 0 end else npcHandler:say('You do not have any vip days.', cid) npcHandler.topic[cid] = 0 end else npcHandler:say('you no have first promotion', cid) npcHandler.topic[cid] = 0 end elseif msgcontains(msg:lower(), 'no') and npcHandler.topic[cid] == 1 then npcHandler:say('Bye!!', cid) npcHandler.topic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Opa amigo testei aqui, quando fala promotion, o npc responde are you sure ai vc fala "yes" ela não responde, e aparece isso no distro: Lua Script Error: [Npc interface] data/npc/scripts/Queen Alice.lua:onCreatureSay data/npc/scripts/Queen Alice.lua:31: attempt to call method 'getPromotion' (a nil value) stack traceback: [C]: in function 'getPromotion' data/npc/scripts/Queen Alice.lua:31: in function 'callback' data/npc/lib/npcsystem/npchandler.lua:410: in function 'onCreatureSay' data/npc/scripts/Queen Alice.lua:10: in function <data/npc/scripts/Queen Alice.lua:10> Up Poxa alguem poderia ajudar o summ aqui, o pc dele nao roda tfs 1.0, por favor preciso mto desse script poxa muita gente sabe mas poucos ajudam, complicado..
Postado Abril 6, 2015 10 anos Tenta isso: local money = xxxx -- Quanto vai custar local storage = 14542 -- Não mexer local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if player:getStorageValue(storage) == 1 then npcHandler:say("You have already received the promotion.", cid) return true end if msgcontains(msg:lower(), "promotion") then npcHandler:say("You are sure?", cid) npcHandler.topic[cid] = 1 end if msgcontains(msg:lower(), "yes") and npcHandler.topic[cid] == 1 then if player:getVocation():getPromotion() then if player:getVipDays() >= 1 then if player:removeMoney(money) then npcHandler:say("You just received a new promotion.", cid) player:setVocation(player:getVocation():getPromotion()) player:setStorageValue(storage, 1) npcHandler.topic[cid] = 0 else npcHandler:say("You don't have money.", cid) npcHandler.topic[cid] = 0 end else npcHandler:say("You don't have any vip days.", cid) npcHandler.topic[cid] = 0 end else npcHandler:say("You don't have the first promotion.", cid) npcHandler.topic[cid] = 0 end elseif msgcontains(msg:lower(), "no") and npcHandler.topic[cid] == 1 then npcHandler:say('Bye!', cid) npcHandler.topic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Abril 6, 2015 10 anos por Snowsz (veja o histórico de edições) _ .-'` `} _./) / } .'o \ | } '.___.'`.\ {` /`\_/ , `. } ME DA UMA NOZ! \=' .-' _`\ { `'`;/ `, } _\ @ ; } /__`;-...'--' Cluck!
Postado Abril 7, 2015 10 anos Autor Tenta isso: local money = xxxx -- Quanto vai custar local storage = 14542 -- Não mexer local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if player:getStorageValue(storage) == 1 then npcHandler:say("You have already received the promotion.", cid) return true end if msgcontains(msg:lower(), "promotion") then npcHandler:say("You are sure?", cid) npcHandler.topic[cid] = 1 end if msgcontains(msg:lower(), "yes") and npcHandler.topic[cid] == 1 then if player:getVocation():getPromotion() then if player:getVipDays() >= 1 then if player:removeMoney(money) then npcHandler:say("You just received a new promotion.", cid) player:setVocation(player:getVocation():getPromotion()) player:setStorageValue(storage, 1) npcHandler.topic[cid] = 0 else npcHandler:say("You don't have money.", cid) npcHandler.topic[cid] = 0 end else npcHandler:say("You don't have any vip days.", cid) npcHandler.topic[cid] = 0 end else npcHandler:say("You don't have the first promotion.", cid) npcHandler.topic[cid] = 0 end elseif msgcontains(msg:lower(), "no") and npcHandler.topic[cid] == 1 then npcHandler:say('Bye!', cid) npcHandler.topic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Ola amigo, obrigado pela ajuda, na pratica funcionou sem erros, porem quando da look no personagem pra ver se mudou a promotion aparece "you have no vocation" ou seja o player ficou sem vocaçao hehehe acho que estamos próximos de resolver aguardo respostas!
Postado Abril 7, 2015 10 anos Ola amigo, obrigado pela ajuda, na pratica funcionou sem erros, porem quando da look no personagem pra ver se mudou a promotion aparece "you have no vocation" ou seja o player ficou sem vocaçao hehehe acho que estamos próximos de resolver aguardo respostas! Desculpe, acho que isso resolve: local money = xxxx -- Quanto vai custar local storage = 14542 -- Não mexer local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if player:getStorageValue(storage) == 1 then npcHandler:say("You have already received the promotion.", cid) return true end if msgcontains(msg:lower(), "promotion") then npcHandler:say("You are sure?", cid) npcHandler.topic[cid] = 1 end if msgcontains(msg:lower(), "yes") and npcHandler.topic[cid] == 1 then if player:getVocation():getPromotion() then if player:getVipDays() >= 1 then if player:removeMoney(money) then npcHandler:say("You just received a new promotion.", cid) player:setVocation(player:getVocation():getPromotion():getId()) player:setStorageValue(storage, 1) npcHandler.topic[cid] = 0 else npcHandler:say("You don't have money.", cid) npcHandler.topic[cid] = 0 end else npcHandler:say("You don't have any vip days.", cid) npcHandler.topic[cid] = 0 end else npcHandler:say("You don't have the first promotion.", cid) npcHandler.topic[cid] = 0 end elseif msgcontains(msg:lower(), "no") and npcHandler.topic[cid] == 1 then npcHandler:say('Bye!', cid) npcHandler.topic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) _ .-'` `} _./) / } .'o \ | } '.___.'`.\ {` /`\_/ , `. } ME DA UMA NOZ! \=' .-' _`\ { `'`;/ `, } _\ @ ; } /__`;-...'--' Cluck!
Postado Abril 7, 2015 10 anos Autor Desculpe, acho que isso resolve: local money = xxxx -- Quanto vai custar local storage = 14542 -- Não mexer local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if player:getStorageValue(storage) == 1 then npcHandler:say("You have already received the promotion.", cid) return true end if msgcontains(msg:lower(), "promotion") then npcHandler:say("You are sure?", cid) npcHandler.topic[cid] = 1 end if msgcontains(msg:lower(), "yes") and npcHandler.topic[cid] == 1 then if player:getVocation():getPromotion() then if player:getVipDays() >= 1 then if player:removeMoney(money) then npcHandler:say("You just received a new promotion.", cid) player:setVocation(player:getVocation():getPromotion():getId()) player:setStorageValue(storage, 1) npcHandler.topic[cid] = 0 else npcHandler:say("You don't have money.", cid) npcHandler.topic[cid] = 0 end else npcHandler:say("You don't have any vip days.", cid) npcHandler.topic[cid] = 0 end else npcHandler:say("You don't have the first promotion.", cid) npcHandler.topic[cid] = 0 end elseif msgcontains(msg:lower(), "no") and npcHandler.topic[cid] == 1 then npcHandler:say('Bye!', cid) npcHandler.topic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Que isso cara, o que importa eh vc estar me ajudando hehehe, bom, fiz o teste com 1 sorcerer e um master sorcerer, ambos recebiam a promotion, mas não muda nada.. Continua como sorcerer/master sorcerer, no caso o que eu queria era que so quem tiver a primeira promotion (master sorcerer etc..) possa ter a segunda que seria a promotion vip.. Mas ambos estao recebendo a promotion, porem nao muda nada.. Continua como sorcerer e master sorcerer, mas já é um começo obrigado pela ajuda e aguardo respostas.. up
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.