Postado Outubro 24, 2014 10 anos Gostaria de um script de npc que só mude a vocação se o player tiver tal storage e o item necessário. Storage: qualquer uma depois mudo Item: qualquer um depois mudo.
Postado Outubro 25, 2014 10 anos exchanger.lua (data/npc/scripts): local tab = { [1] = {voc = 5, item = {1234, 5}, sto = {12345, 1}, -- [paraqualvocID] = {voc = novavocID, item {itemID, count}, sto = {storage, valordastorage}}, [2] = {voc = 6, item = {1234, 5}, sto = {12345, 1}, [3] = {voc = 7, item = {1234, 5}, sto = {12345, 1}, [4] = {voc = 8, item = {1234, 5}, sto = {12345, 1} } 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 local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'favor')) then talkState[talkUser] = 1 selfSay('You need to bring me '..tab[getPlayerVocation].item[2]..' '..getItemNameById(tab[getPlayerVocation].item[1])..' and then I can {change} your vocation.', cid) elseif(msgcontains(msg, 'change') and talkState[talkUser] == 1) then talkState[talkUser] = 2 selfSay('Are you sure you want to do this change?', cid) elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getPlayerVocation(cid) ~= tab[getPlayerVocation(cid)].voc) then if(tab[getPlayerVocation(cid)] and getPlayerStorageValue(cid, tab[getPlayerVocation(cid)].sto[1]) > tab[getPlayerVocation(cid)].sto[2]) then if(doPlayerRemoveItem(cid, tab[getPlayerVocation(cid)].item[1], tab[getPlayerVocation(cid)].item[2]) == true) then talkState[talkUser] = 0 doPlayerSetVocation(cid, tab[getPlayerVocation(cid)].voc) doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS) else talkState[talkUser] = 0 selfSay('You do not have the required items.', cid) end else talkState[talkUser] = 0 selfSay('You can not change your vocation.', cid) end else talkState[talkUser] = 0 selfSay('You already have changed your vocation.', cid) end elseif(msgcontains(msg, 'no')) then talkState[talkUser] = 0 selfSay('Sure. Goodbye!', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Exchanger.xml (data/npc): <npc name="Exchanger" script="data/npc/scripts/exchanger.lua" access="5" lookdir="1"> <health now="1000" max="1000"/> <look type="133" head="39" body="113" legs="38" feet="0" addons="3"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|. I can change your vocation but before I need a {favor}." /> </parameters> </npc> The corrupt fear us. The honest support us. The heroic join us.
Postado Setembro 16, 2022 3 anos Em 25/10/2014 em 03:35, Wise disse: selfSay('You need to bring me '..tab[getPlayerVocation].item[2]..' '..getItemNameById(tab[getPlayerVocation].item[1])..' and then I can {change} your vocation.', cid) creio que o unico erro desse script seja essa linha troca os "getPlayerVocation" pra getPlayerVocation(cid) que ja vai funcionar @matheuspeixoto12
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.