Ir para conteúdo

ydri

Membro
  • Registro em

  • Última visita

Tudo que ydri postou

  1. Em vez de contar a exp quando a pessoa morrer e depois novamente quando logar, usando 3 storages pra isso, acredito que seria melhor anotar o level na morte e simplesmente o npc conferir se o level atual é menor que o anterior salvo. Ainda dá pra melhorar algumas coisas, mas isso aqui funcionou pra mim: creaturescripts.xml: <event type="preparedeath" name="Exp_P" event="script" value="exp_buy.lua"/> login.lua: registerCreatureEvent(cid, "Exp_P") exp_buy.lua function onPrepareDeath(cid, lastHitKiller, mostDamageKiller) setPlayerStorageValue(cid, 135215, getPlayerExperience(cid)) return true end e nos npcs, expbuy.lua: 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 config = { itemid = 9020, count = 300, past_level = getPlayerStorageValue(cid, 135215) } if isInArray({"recover", "recuperar", "exp", "experience"}, string.lower(msg)) then npcHandler:say("Do you wish to recover the lost experience after your death for "..config.count.." "..getItemNameById(config.itemid).."? {yes}", cid) talkState[talkUser] = 1 elseif (msgcontains(string.lower(msg), 'yes') and talkState[talkUser] == 1) then if config.past_level ~= -1 and getPlayerLevel(cid) < config.past_level then if doPlayerRemoveItem(cid, config.itemid, config.count) then doPlayerAddExperience(cid, getExperienceForLevel(config.past_level) - getExperienceForLevel(getPlayerLevel(cid))) npcHandler:say("Thank you! Here is your experience.", cid) setPlayerStorageValue(cid, 135215, -1) else npcHandler:say("Sorry, you don't have enough "..getItemNameById(config.itemid).."!", cid) talkState[talkUser] = 0 end else npcHandler:say("Sorry, you have not died or have already recovered your lost experience!", cid) talkState[talkUser] = 0 end elseif string.lower(msg) == "no" then npcHandler:say("Then not", cid) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())

Informação Importante

Confirmação de Termo