Postado Julho 23, 2015 9 anos To com problema com 2 scripts de troca de itens, que estão me faltando funções certas para adaptar eles Eles funcionam assim vc tem X item Y quantidades e troca por um item Z Script 1- Problema- Ele troca o item direitinho, mas ele só checa se removeu ou não o item, o que acontece? Se o cara só tiver um dos itens, não tiver os dois ele remove um e não entrega o item, por isso teria que checar antes de remover! Codigo- if msgcontains(msg, "change") then selfSay("You want to exchange 100 behemoth claws and 1 skull helmet for a damaged steel helmet?", cid) talkState[talkUser] = 1 elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, t.item[1], t.item[2]) and doPlayerRemoveItem(cid, t.segitem[1], t.segitem[2]) then doPlayerAddItem(cid, t.reward, 1) selfSay("Here it is.", cid) talkState[talkUser] = 0 else selfSay("You don't have 100 behemoth claws and 1 skull helmet.", cid) talkState[talkUser] = 0 end end Script 2- Problema- Esse aqui não está funcionando mesmo, deve ser pq botei 2500 itens em vez de 100-, mas alguem pode me ajduar? Codigo- local t = { item = {7636, 2500}, -- ID do item e quantidade necessária. reward = 5957 -- Item que irá ganhar. } 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 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, "change") then selfSay("You want to exchange 2500 power bolts for a crossbow?", cid) talkState[talkUser] = 1 elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, t.item[1], t.item[2]) then doPlayerAddItem(cid, t.reward, 1) selfSay("Here it is.", cid) talkState[talkUser] = 0 else selfSay("You don't have 2500 power bolts.", cid) talkState[talkUser] = 0 end end elseif msgcontains(msg, "no") then if talkState[talkUser] == 1 then selfSay("Okay...") talkState[talkUser] = 0 end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Julho 23, 2015 9 anos Solução if msgcontains(msg, "change") then selfSay("You want to exchange 100 behemoth claws and 1 skull helmet for a damaged steel helmet?", cid) talkState[talkUser] = 1 elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if getPlayerItemCount(cid, t.item[1]) >= t.item[2] and getPlayerItemCount(cid, t.segitem[1]) >= t.segitem[2] then doPlayerRemoveItem(cid, t.item[1], t.item[2]) doPlayerRemoveItem(cid, t.segitem[1], t.segitem[2]) doPlayerAddItem(cid, t.reward, 1) selfSay("Here it is.", cid) talkState[talkUser] = 0 else selfSay("You don't have 100 behemoth claws and 1 skull helmet.", cid) talkState[talkUser] = 0 end end end Editado Julho 23, 2015 9 anos por Rusherzin (veja o histórico de edições) Ajudei? De nada \o/ Att Rusherzin
Postado Julho 23, 2015 9 anos Em 23/07/2015 em 03:50, Rusherzin disse: if msgcontains(msg, "change") then selfSay("You want to exchange 100 behemoth claws and 1 skull helmet for a damaged steel helmet?", cid) talkState[talkUser] = 1 elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if getPlayerItemCount(cid, t.item[1]) >= t.item[2] and getPlayerItemCount(cid, t.segitem[1]) >= t.segitem[2] then doPlayerRemoveItem(cid, t.item[1], t.item[2]) doPlayerRemoveItem(cid, t.segitem[1], t.segitem[2]) doPlayerAddItem(cid, t.reward, 1) selfSay("Here it is.", cid) talkState[talkUser] = 0 else selfSay("You don't have 100 behemoth claws and 1 skull helmet.", cid) talkState[talkUser] = 0 end end end Esse rusherzin é moh bostão euaheuauehaeuh brinks <3 - Projetando sua diversão ! - Minha Steam, adiciona lá
Postado Julho 24, 2015 9 anos Autor Em 23/07/2015 em 03:50, Rusherzin disse: if msgcontains(msg, "change") then selfSay("You want to exchange 100 behemoth claws and 1 skull helmet for a damaged steel helmet?", cid) talkState[talkUser] = 1 elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if getPlayerItemCount(cid, t.item[1]) >= t.item[2] and getPlayerItemCount(cid, t.segitem[1]) >= t.segitem[2] then doPlayerRemoveItem(cid, t.item[1], t.item[2]) doPlayerRemoveItem(cid, t.segitem[1], t.segitem[2]) doPlayerAddItem(cid, t.reward, 1) selfSay("Here it is.", cid) talkState[talkUser] = 0 else selfSay("You don't have 100 behemoth claws and 1 skull helmet.", cid) talkState[talkUser] = 0 end end end Obrigado!
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.