Postado Maio 9, 2015 10 anos Você pode fazer o seguinte: elseif msgcontains(msg, 'team red') then if getPlayerItemCount(cid ,2160) >= 20 then npcHandler:say('Did you bring me the 20 crystal coins?', cid) npcHandler.topic[cid] = 1 else npcHandler:say('I need a {20 crystal coins}. Please come back when you have them.', cid) npcHandler.topic[cid] = 0 end elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then npcHandler.topic[cid] = 0 if getPlayerItemCount(cid,2160) >= 20 then if doPlayerRemoveItem(cid,2160, 20) == TRUE then if getGlobalStorageValue(34577) < 20 then npcHandler:say(done, cid) else return doPlayerSendCancel(cid, "Os tickets esgotaram.") end else npcHandler:say(item, cid) end ➥ Regras | Seções OTServ | Seções BOT
Postado Maio 9, 2015 10 anos posta o npc inteiro que a gente edita [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Maio 9, 2015 10 anos Autor 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 item = 'I\'m sorry, but you do not have the required items for this trade.' local done = 'Here you are, thank you for your business.' function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'tickets') then npcHandler:say('I sell tickets for the event.', cid) elseif msgcontains(msg, 'blue') then if getPlayerItemCount(cid ,2160) >= 20 then npcHandler:say('Did you bring me the 20 crystal coins?', cid) npcHandler.topic[cid] = 1 else npcHandler:say('I need a {20 crystal coins}. Please come back when you have them.', cid) npcHandler.topic[cid] = 0 end elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then npcHandler.topic[cid] = 0 if getPlayerItemCount(cid,2160) >= 20 then if doPlayerRemoveItem(cid,2160, 20) == TRUE then npcHandler:say(done, cid) if getGlobalStorageValue(34577) >= 20 then return doPlayerSendCancel(cid, "Os tickets esgotaram.") end else npcHandler:say(item, cid) end elseif msgcontains(msg, 'green') then if getPlayerItemCount(cid ,2160) >= 20 then npcHandler:say('Did you bring me the 20 crystal coins?', cid) npcHandler.topic[cid] = 1 else npcHandler:say('I need a {20 crystal coins}. Please come back when you have them.', cid) npcHandler.topic[cid] = 0 end elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then npcHandler.topic[cid] = 0 if getPlayerItemCount(cid,2160) >= 20 then if doPlayerRemoveItem(cid,2160, 20) == TRUE then npcHandler:say(done, cid) if getGlobalStorageValue(34578) >= 20 then return doPlayerSendCancel(cid, "Os tickets esgotaram.") end else npcHandler:say(item, cid) end elseif msgcontains(msg, 'no') and npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 90 then npcHandler:say('Well, then leave.') npcHandler.topic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Maio 9, 2015 10 anos por arthur122222 (veja o histórico de edições)
Postado Maio 9, 2015 10 anos Testa ai: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 storage = 23844 -- Storage do player ao comprar para ter acesso ao evento. local gstorage = 34577 -- Storage global do evento. local done = 'Here you are, thank you for your business.' function creatureSayCallback(cid, type, msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local msg = msg:lower(); if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'tickets') then if getGlobalStorageValue(gstorage) < 20 then npcHandler:say('I sell tickets for the event.', cid) talkState[talkUser] = 1 else npcHandler:say('There are no more tickets.', cid) talkState[talkUser] = 0 end elseif msgcontains(msg, 'blue') then if talkState[talkUser] == 1 then npcHandler:say('Did you bring me the 20 crystal coins?', cid) talkState[talkUser] = 2 end elseif msgcontains(msg, 'green') then if talkState[talkUser] == 1 then npcHandler:say('Did you bring me the 20 crystal coins?', cid) talkState[talkUser] = 2 elseif msgcontains(msg, 'yes') then if talkState[talkUser] == 2 then if doPlayerRemoveItem(cid, 2160, 20) == TRUE then npcHandler:say(done, cid) setPlayerStorageValue(cid, storage, 1) else npcHandler:say("You do not have 20 crystal coins.") end end elseif msgcontains(msg, 'no') then if talkState[talkUser] = 2 then npcHandler:say("Okay...") talkState[talkUser] = 0 end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) ➥ Regras | Seções OTServ | Seções BOT
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.