Postado Agosto 6, 2019 5 anos Olá TK, procurei no fórum mais não encontrei um Script de Npc, que ao falar com ele você ganharia uma quantidade x de Hp e também haveria uma Storage para não pegar novamente. +Rep ! > 0.4 * 8.6 <
Postado Agosto 6, 2019 5 anos Solução Boa Tarde @leozincorsair , segue o script. Crie um NPC.xml <npc name="Iruka Sensei" script="data/npc/scripts/bonus.lua" walkinterval="2000" speed="0" floorchange="0"> <health now="1000" max="1000"/> <look type="215" head="0" body="86" legs="0" feet="38" addons="1"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME| voce deseja receber um {bonus} de vida e experiencia ?." /> </parameters> </npc> Crie um arquivo bonus.lua em npc/scripts 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 local XP = 100 -- Quantidade de Exp a receber local HP = 100 -- Quantidade de Vida a receber local stor = 11001 -- Storage if(msgcontains(msg, 'bonus') or msgcontains(msg, 'Bonus')) then selfSay('Deseja receber um bonus de Experiencia e Pontos de Vida?.{yes}', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerStorageValue(cid, stor) < 1 then doPlayerAddExp(cid, XP) setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+HP) doCreatureAddHealth(cid, getCreatureMaxHealth(cid)) selfSay('Parabens, voce recebeu um bonus de Experiencia e Vida.', cid) setPlayerStorageValue(cid, stor, 1) else selfSay('Voce ja pegou seu bonus.', cid) end talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Agosto 7, 2019 5 anos 11 horas atrás, r0bert0lol disse: Boa Tarde @leozincorsair , segue o script. Crie um NPC.xml <npc name="Iruka Sensei" script="data/npc/scripts/bonus.lua" walkinterval="2000" speed="0" floorchange="0"> <health now="1000" max="1000"/> <look type="215" head="0" body="86" legs="0" feet="38" addons="1"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME| voce deseja receber um {bonus} de vida e experiencia ?." /> </parameters> </npc> Crie um arquivo bonus.lua em npc/scripts 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 local XP = 100 -- Quantidade de Exp a receber local HP = 100 -- Quantidade de Vida a receber local stor = 11001 -- Storage if(msgcontains(msg, 'bonus') or msgcontains(msg, 'Bonus')) then selfSay('Deseja receber um bonus de Experiencia e Pontos de Vida?.{yes}', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerStorageValue(cid, stor) < 1 then doPlayerAddExp(cid, XP) setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+HP) doCreatureAddHealth(cid, getCreatureMaxHealth(cid)) selfSay('Parabens, voce recebeu um bonus de Experiencia e Vida.', cid) setPlayerStorageValue(cid, stor, 1) else selfSay('Voce ja pegou seu bonus.', cid) end talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Como faco pra adicionar um item a ser trocado pela vida e xp?
Postado Agosto 7, 2019 5 anos @Jensen O Script fica assim : 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 local XP = 100 -- Quantidade de Exp a receber local HP = 100 -- Quantidade de Vida a receber local stor = 11001 -- Storage local r_item = 100 -- ITEM NECESSARIO local qtd = 100 -- QUANTIDADE DE ITEM NECESSARIO if(msgcontains(msg, 'bonus') or msgcontains(msg, 'Bonus')) then selfSay('Deseja receber um bonus de Experiencia e Pontos de Vida?.{yes}', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerStorageValue(cid, stor) < 1 then if getPlayerItemCount(cid, item) >= qtd then doPlayerAddExp(cid, XP) setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+HP) doCreatureAddHealth(cid, getCreatureMaxHealth(cid)) selfSay('Parabens, voce recebeu um bonus de Experiencia e Vida.', cid) setPlayerStorageValue(cid, stor, 1) doPlayerRemoveItem(cid, r_item, qtd) else selfSay('Voce nao tem os items necessarios.', cid) else selfSay('Voce ja pegou seu bonus.', cid) end talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
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.