Postado Julho 24, 2016 8 anos Olá pessoal, Uma dúvida... Quero que quando eu mate o monstro 'raging halcrof' o player ganhe a storage 3877. Eu coloquei o creature script registrei no login, mas não funcionou, segue abaixo os scripts. creaturescripts/scripts/halcrofkill.lua local monster = 'raging halcrof' -- coloque o nome todo minusculo local storage = 3877 -- valor da Storage local msg = 'Congratulations take the blue tome and enjoy at Draenor Quests.' -- Configure a gosto function onKill(cid, target, lastHit) if(isMonster(cid)) and getCreatureName(cid):lower() == monster then setPlayerStorageValue(lastHit, storage, 1) doPlayerSendTextMessage(lastHit, 22, msg) end return true end login.lua registerCreatureEvent(cid, "Halcrofkill") creaturescripts.xml <event type="kill" name="Halcrofkill" script="halcrofkill.lua"/> monsters/raging halcrof.xml <?xml version="1.0" encoding="UTF-8"?> <monster name="Raging Halcrof" nameDescription="a raging halcrof" race="blood" experience="8000" speed="280" manacost="0"> <health now="8500" max="8500"/> <look type="130" head="38" body="39" legs="23" feet="50" addons="1" corpse="6080"/> <targetchange interval="5000" chance="30"/> <strategy attack="100" defense="0"/> <flags> <flag summonable="0"/> <flag attackable="1"/> <flag hostile="1"/> <flag illusionable="0"/> <flag convinceable="0"/> <flag pushable="0"/> <flag canpushitems="1"/> <flag canpushcreatures="1"/> <flag targetdistance="4"/> <flag staticattack="90"/> <flag runonhealth="1000"/> </flags> <script> <event name="Inquisition"/> <event name="Halcrofkill"/> </script> <attacks> <attack name="melee" interval="2000" skill="70" attack="60"/> <attack name="physical" interval="1000" chance="35" range="7" min="-265" max="-485"> <attribute key="shootEffect" value="energy"/> </attack> <attack name="manadrain" interval="1000" chance="17" range="7" min="-90" max="-160"/> <attack name="speed" interval="1000" chance="12" range="7" speedchange="-600" duration="40000"> <attribute key="areaEffect" value="redshimmer"/> </attack> <attack name="fire" interval="2000" chance="45" range="7" radius="3" target="1" min="-350" max="-420"> <attribute key="shootEffect" value="burstarrow"/> <attribute key="areaEffect" value="firearea"/> </attack> <attack name="firefield" interval="1000" chance="20" range="7" radius="2" target="1"> <attribute key="shootEffect" value="fire"/> </attack> <attack name="energy" interval="2000" chance="25" length="8" spread="0" min="-265" max="-345"> <attribute key="areaEffect" value="energy"/> </attack> <attack name="speed" interval="6000" chance="10" range="5" speedchange="-600" duration="20000"> <attribute key="areaEffect" value="redshimmer"/> </attack> </attacks> <defenses armor="25" defense="30"> <defense name="healing" interval="1000" chance="25" min="50" max="100"> <attribute key="areaEffect" value="blueshimmer"/> </defense> <defense name="invisible" interval="5000" chance="10" duration="5000"> <attribute key="areaEffect" value="redshimmer"/> </defense> </defenses> <elements> <element firePercent="100"/> <element energyPercent="100"/> <element icePercent="100"/> <element earthPercent="70"/> <element holyPercent="20"/> <element physicalPercent="-30"/> </elements> <immunities> <immunity paralyze="1"/> <immunity invisible="1"/> </immunities> <voices interval="5000" chance="50"> <voice sentence="Get out my face apprentice useless!"/> <voice sentence="You are not prepared for the Draenor missions!"/> <voice sentence="Do not let me escape!"/> </voices> <loot> <item id="2148" countmax="80" chance="36500"/><!-- gold coin --> <item id="2148" countmax="70" chance="3t6500"/><!-- gold coin --> <item id="2792" countmax="5" chance="5000"/><!-- dark mushroom --> <item id="2167" chance="3000"/><!-- energy ring --> <item id="2600" chance="10000"/><!-- inkwell --> <item id="2178" chance="2500"/><!-- mind stone --> <item id="1987" chance="100000"><!-- bag --> <inside> <item id="2436" chance="3000"/><!-- skull staff --> <item id="2151" chance="5500"/><!-- talon --> <item id="7591" chance="12500"/><!-- great health potion --> <item id="7590" chance="10000"/><!-- great mana potion --> <item id="1984" chance="100000"/><!-- blue robe --> <item id="7368" countmax="4" chance="1200"/><!-- assassin star --> <item id="2146" chance="1400"/><!-- small sapphire --> <item id="1986" chance="800"/><!-- red tome --> <item id="2123" chance="850"/><!-- ring of the sky --> <item id="2197" chance="750"/><!-- stone skin amulet --> <item id="7898" chance="450"/><!-- lightning robe --> <item id="7895" chance="450"/><!-- lightning legs --> <item id="2466" chance="375"/><!-- golden armor --> <item id="2114" chance="100"/><!-- piggy bank --> </inside> </item> </loot> </monster> npc que faz o check da storage: local tab = { level = 100, pos = {x = 1071, y = 1135, z = 10}, storage = 3877 -- Storage } 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, 'challenge')) then talkState[talkUser] = 1 selfSay('You are sure you want to go? You can not return.', cid) elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerLevel(cid) >= tab.level) and getPlayerStorageValue(cid, tab.storage) < 1 then talkState[talkUser] = 0 doTeleportThing(cid, tab.pos) --setPlayerStorageValue(cid, tab.storage, 1) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) elseif getPlayerStorageValue(cid, tab.storage) == 1 then selfSay('You already have proved me your strength! And I have given you the Blue Tome...', cid) elseif (getPlayerLevel(cid) < tab.level) then talkState[talkUser] = 0 selfSay('I can only challenge players with level '..tab.level..' or more.', cid) end elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then talkState[talkUser] = 0 selfSay('Come back when you are ready learner.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Eu tirei o setstorage do NPC, porque justamente quero que o player ganhe a storage matando o boss e não falando com o NPC uma vez apenas. Pra que caso o player morra pro boss ele possa tentar de novo. mas o problema em sí é que o monstro quando morto não da a storage... Editado Julho 24, 2016 8 anos por Felipe Lotz (veja o histórico de edições) Atenciosamente, Felipe Lotz.
Postado Julho 24, 2016 8 anos 16 minutos atrás, Felipe Lotz disse: Olá pessoal, Uma dúvida... Quero que quando eu mate o monstro 'raging halcrof' o player ganhe a storage 3877. Eu coloquei o creature script registrei no login, mas não funcionou, segue abaixo os scripts. creaturescripts/scripts/halcrofkill.lua local monster = 'raging halcrof' -- coloque o nome todo minusculo local storage = 3877 -- valor da Storage local msg = 'Congratulations take the blue tome and enjoy at Draenor Quests.' -- Configure a gosto function onKill(cid, target, lastHit) if(isMonster(cid)) and getCreatureName(cid):lower() == monster then setPlayerStorageValue(lastHit, storage, 1) doPlayerSendTextMessage(lastHit, 22, msg) end return true end login.lua registerCreatureEvent(cid, "Halcrofkill") creaturescripts.xml <event type="kill" name="Halcrofkill" script="halcrofkill.lua"/> monsters/raging halcrof.xml <?xml version="1.0" encoding="UTF-8"?> <monster name="Raging Halcrof" nameDescription="a raging halcrof" race="blood" experience="8000" speed="280" manacost="0"> <health now="8500" max="8500"/> <look type="130" head="38" body="39" legs="23" feet="50" addons="1" corpse="6080"/> <targetchange interval="5000" chance="30"/> <strategy attack="100" defense="0"/> <flags> <flag summonable="0"/> <flag attackable="1"/> <flag hostile="1"/> <flag illusionable="0"/> <flag convinceable="0"/> <flag pushable="0"/> <flag canpushitems="1"/> <flag canpushcreatures="1"/> <flag targetdistance="4"/> <flag staticattack="90"/> <flag runonhealth="1000"/> </flags> <script> <event name="Inquisition"/> <event name="Halcrofkill"/> </script> <attacks> <attack name="melee" interval="2000" skill="70" attack="60"/> <attack name="physical" interval="1000" chance="35" range="7" min="-265" max="-485"> <attribute key="shootEffect" value="energy"/> </attack> <attack name="manadrain" interval="1000" chance="17" range="7" min="-90" max="-160"/> <attack name="speed" interval="1000" chance="12" range="7" speedchange="-600" duration="40000"> <attribute key="areaEffect" value="redshimmer"/> </attack> <attack name="fire" interval="2000" chance="45" range="7" radius="3" target="1" min="-350" max="-420"> <attribute key="shootEffect" value="burstarrow"/> <attribute key="areaEffect" value="firearea"/> </attack> <attack name="firefield" interval="1000" chance="20" range="7" radius="2" target="1"> <attribute key="shootEffect" value="fire"/> </attack> <attack name="energy" interval="2000" chance="25" length="8" spread="0" min="-265" max="-345"> <attribute key="areaEffect" value="energy"/> </attack> <attack name="speed" interval="6000" chance="10" range="5" speedchange="-600" duration="20000"> <attribute key="areaEffect" value="redshimmer"/> </attack> </attacks> <defenses armor="25" defense="30"> <defense name="healing" interval="1000" chance="25" min="50" max="100"> <attribute key="areaEffect" value="blueshimmer"/> </defense> <defense name="invisible" interval="5000" chance="10" duration="5000"> <attribute key="areaEffect" value="redshimmer"/> </defense> </defenses> <elements> <element firePercent="100"/> <element energyPercent="100"/> <element icePercent="100"/> <element earthPercent="70"/> <element holyPercent="20"/> <element physicalPercent="-30"/> </elements> <immunities> <immunity paralyze="1"/> <immunity invisible="1"/> </immunities> <voices interval="5000" chance="50"> <voice sentence="Get out my face apprentice useless!"/> <voice sentence="You are not prepared for the Draenor missions!"/> <voice sentence="Do not let me escape!"/> </voices> <loot> <item id="2148" countmax="80" chance="36500"/><!-- gold coin --> <item id="2148" countmax="70" chance="3t6500"/><!-- gold coin --> <item id="2792" countmax="5" chance="5000"/><!-- dark mushroom --> <item id="2167" chance="3000"/><!-- energy ring --> <item id="2600" chance="10000"/><!-- inkwell --> <item id="2178" chance="2500"/><!-- mind stone --> <item id="1987" chance="100000"><!-- bag --> <inside> <item id="2436" chance="3000"/><!-- skull staff --> <item id="2151" chance="5500"/><!-- talon --> <item id="7591" chance="12500"/><!-- great health potion --> <item id="7590" chance="10000"/><!-- great mana potion --> <item id="1984" chance="100000"/><!-- blue robe --> <item id="7368" countmax="4" chance="1200"/><!-- assassin star --> <item id="2146" chance="1400"/><!-- small sapphire --> <item id="1986" chance="800"/><!-- red tome --> <item id="2123" chance="850"/><!-- ring of the sky --> <item id="2197" chance="750"/><!-- stone skin amulet --> <item id="7898" chance="450"/><!-- lightning robe --> <item id="7895" chance="450"/><!-- lightning legs --> <item id="2466" chance="375"/><!-- golden armor --> <item id="2114" chance="100"/><!-- piggy bank --> </inside> </item> </loot> </monster> npc que faz o check da storage: local tab = { level = 100, pos = {x = 1071, y = 1135, z = 10}, storage = 3877 -- Storage } 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, 'challenge')) then talkState[talkUser] = 1 selfSay('You are sure you want to go? You can not return.', cid) elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerLevel(cid) >= tab.level) and getPlayerStorageValue(cid, tab.storage) < 1 then talkState[talkUser] = 0 doTeleportThing(cid, tab.pos) --setPlayerStorageValue(cid, tab.storage, 1) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) elseif getPlayerStorageValue(cid, tab.storage) == 1 then selfSay('You already have proved me your strength! And I have given you the Blue Tome...', cid) elseif (getPlayerLevel(cid) < tab.level) then talkState[talkUser] = 0 selfSay('I can only challenge players with level '..tab.level..' or more.', cid) end elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then talkState[talkUser] = 0 selfSay('Come back when you are ready learner.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Eu tirei o setstorage do NPC, porque justamente quero que o player ganhe a storage matando o boss e não falando com o NPC uma vez apenas. Pra que caso o player morra pro boss ele possa tentar de novo. mas o problema em sí é que o monstro quando morto não da a storage... Tente um onDeath: function onDeath(cid, corpse, deathList, target) local storage = 656565 if getPlayerStorageValue(deathList[1], storage) < 1 then if isPlayer(deathList[1]) then setPlayerStorageValue(deathList[1], storage, 1) doSendMagicEffect(getPlayerPosition(deathList[1]), 12) end else return true end return true end Lembre de mudar de KILL para DEATH no creaturescripts.xml
Postado Julho 24, 2016 8 anos Autor @Kemmlly Deu certo camarada, muito obrigado! Atenciosamente, Felipe Lotz.
Postado Setembro 28, 2023 1 ano Estava precisando dessa mesma função e tomei a liberdade de melhorá-la e poder adicionar novos monstros ao script e até mesmo executar novas funções ao derrotar um monstro, como abrir uma porta da sala, criar baus de recompensa, etc. Em data/creaturescripts/scripts crie um arquivo lua kill_boss.lua function onDeath(cid, corpse, deathList, target) -- Lista de monstros e storages local tab = { ["Monstro1"] = 35000, ["Monstro2"] = 35001, ["Monstro3"] = 35002 } local effectMagic = CONST_ME_FIREWORK_YELLOW -- Efeito magico que será executado no player local consoleTypeText = MESSAGE_STATUS_CONSOLE_BLUE -- Tipo de texto que sera ilustrado no chat local storage = tab[getCreatureName(cid)] -- Verifica se monstro está na e obtem seu respectivo storage local playerID = deathList[1] -- ID do player primeiro player da lista de player que matou a criatura if isPlayer(cid) then return true end if storage ~= nil and storage > 1 then if getPlayerStorageValue(playerID, storage) > 0 then return true end doSendMagicEffect(getThingPos(playerID), effectMagic) doPlayerSendTextMessage(playerID, consoleTypeText, "[PT] Parabens, voce derrotou " .. getCreatureName(cid)) setPlayerStorageValue(playerID, storage, 1) end return true end Em data/creaturescripts/creaturescripts.xml edite esse arquivo XML adicionando a seguinte tag: <event type="death" name="killBoss" script="kill_boss.lua"/> Em data/creaturescripts/scripts/login.lua registerCreatureEvent(cid, "killBoss") No arquivo XML do monstro desejado adicione a seguinte tag para apontar nosso script: <script> <event name="killBoss" /> </script> OBS: Notei que ao declarar return false ou haver qualquer erro no script kill_boss.lua o corpo do monstro sumia quando o mesmo era morto, isso causava vários problemas em outros scripts que estava utilizando em meu TFS como de autoLoot, apenas compartilhando os problemas que tive. Editado Setembro 28, 2023 1 ano por Doria Louro (veja o histórico de edições)
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.