Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Action que ativa o double bonus ao usar o item]]--
- -- Tag: Colocar em action.xml
- <action itemid="ID_DO_ITEM" script="doubleExpAndLoot.lua"/>
- -- Criar arquivo em actions/scripts/ chamado doubleExpAndLoot.lua e colocar:
- local storage = 7718
- local bonusExp = 2 -- VOCÊ DEVE EDITAR AQUI PARA O BONUS EXP QUE DESEJA
- function onUse(cid, item, frompos, item2, topos)
- if not isPlayer(cid) then return false end
- if (getPlayerStorageValue(cid, storage) == -1) then
- doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus started.")
- doPlayerSetRate(cid, SKILL__LEVEL, bonusExp*getExperienceStage(getPlayerLevel(cid)))
- registerCreatureEvent(cid, "doubleBonusRegister")
- setPlayerStorageValue(cid, storage, os.time())
- doBroadcastMessage(getPlayerStorageValue(cid, storage))
- else
- setPlayerStorageValue(cid, storage, -1)
- doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "You can only use one bonus per time.")
- end
- end
- ----------------------------------------------------------------------------
- --[[Creature Script que registra o double bonus sempre que ataca uma criatura]]--
- -- Tag: Colocar em creaturescripts.xml
- <event type="target" name="doubleBonusRegister" event="script" value="doubleBonusRegister.lua"/>
- -- Criar arquivo em creaturescripts/scripts/ chamado doubleBonusRegister.lua e colocar:
- local storage = 7718
- local bonusTime = 10*24*60*60
- function registerDoubleBonus (cid, target)
- if getPlayerStorageValue(cid, storage) == -1 then return true end
- if os.time() - bonusTime >= getPlayerStorageValue(cid, storage) then
- doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
- doPlayerSetRate(cid, SKILL__LEVEL, getExperienceStage(getPlayerLevel(cid)))
- unregisterCreatureEvent(cid, "doubleBonusRegister")
- setPlayerStorageValue(cid, storage, -1)
- return true
- end
- if isMonster(target) then
- registerCreatureEvent(target, "doubleBonus")
- end
- return true
- end
- function onCombat(cid, target)
- registerDoubleBonus (cid, target)
- return true
- end
- ----------------------------------------------------------------------------
- --[[Creature Script que executa o double bonus sempre que a criatura registrada morre]]--
- -- Tag: Colocar em creaturescripts.xml
- <event type="death" name="doubleBonus" event="script" value="doubleBonus.lua"/>
- -- Criar arquivo em creaturescripts/scripts/ chamado doubleBonus.lua e colocar:
- local storage = 7718
- local bonusTime = 10*24*60*60
- local serverDropRate = 1000 -- VOCÊ DEVE EDITAR AQUI PARA O DROP RATE DO SEU SERVIDOR
- local bonusLoot = 2 -- VOCÊ DEVE EDITAR AQUI PARA O BONUS LOOT QUE DESEJA
- local bp_id = 1987
- function bonusCreatureLoot(pos, monsterName)
- local corpse = getTileThingByPos(pos)
- if not isCorpse(corpse.uid) then return false end
- doAddContainerItem(corpse.uid, 1988, 1)
- local bp = getContainerItem(corpse.uid, getContainerItem(corpse.uid, getContainerSize(corpse.uid)))
- local lootList = getMonsterLootList(monsterName)
- for _, loot in pairs(lootList) do
- local randomizedChance = math.random (1, 100000)
- if randomizedChance <= bonusLoot * loot.chance * serverDropRate then
- doAddContainerItem(bp.uid, loot.id, loot.countmax and math.random(1,loot.countmax) or 1)
- end
- end
- end
- function onDeath(cid, corpse, deathList)
- local killer = #deathList > 1 and deathList[2] or deathList[1]
- if not isPlayer(killer) then return true end
- if not isMonster(cid) then return true end
- if getPlayerStorageValue(killer, storage) == -1 then return true end
- if os.time() - bonusTime >= getPlayerStorageValue(killer, storage) then
- doPlayerSendTextMessage(killer, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
- doPlayerSetRate(killer, SKILL__LEVEL, getExperienceStage(getPlayerLevel(killer)))
- unregisterCreatureEvent(killer, "doubleBonusRegister")
- unregisterCreatureEvent(cid, "bonusRegister")
- setPlayerStorageValue(killer, storage, -1)
- return true
- end
- if not isContainer(corpse.uid) then return true end
- addEvent(bonusCreatureLoot, 100, getCreaturePosition(cid), getCreatureName(cid))
- return true
- end
- -- colocar dentro de creaturescripts/scripts/login.lua colocar as seguintes linhas de código (dentro da função onLogin fora de qualquer if ou iteração):
- local bonusTime = 10*24*60*60
- local bonusStorage = 7718
- doBroadcastMessage(os.time() .. " " .. getPlayerStorageValue(cid, bonusStorage))
- if os.time() - bonusTime < getPlayerStorageValue(cid, bonusStorage) then
- local remainingTime = (bonusTime - (os.time()-getPlayerStorageValue(cid, bonusStorage)))/(60*60)
- if remainingTime >= 1 then
- doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus re-started. You have: less than " .. math.ceil(remainingTime) .. " hours")
- else
- doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus re-started. You have: less than " .. math.ceil(remainingTime) .. " hour")
- end
- registerCreatureEvent(cid, "doubleBonusRegister")
- else
- doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
- doPlayerSetRate(cid, SKILL__LEVEL, getExperienceStage(getPlayerLevel(cid)))
- setPlayerStorageValue(cid, bonusStorage, -1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement