Advertisement
Guest User

Untitled

a guest
Mar 13th, 2016
1,176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. --[[Action que ativa o double bonus ao usar o item]]--
  2. -- Tag: Colocar em action.xml
  3. <action itemid="ID_DO_ITEM" script="doubleExpAndLoot.lua"/>
  4.  
  5. -- Criar arquivo em actions/scripts/ chamado doubleExpAndLoot.lua e colocar:
  6. local storage = 7718
  7. local bonusExp = 2 -- VOCÊ DEVE EDITAR AQUI PARA O BONUS EXP QUE DESEJA
  8. function onUse(cid, item, frompos, item2, topos)
  9. if not isPlayer(cid) then return false end
  10. if (getPlayerStorageValue(cid, storage) == -1) then
  11. doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus started.")
  12. doPlayerSetRate(cid, SKILL__LEVEL, bonusExp*getExperienceStage(getPlayerLevel(cid)))
  13. registerCreatureEvent(cid, "doubleBonusRegister")
  14. setPlayerStorageValue(cid, storage, os.time())
  15. doBroadcastMessage(getPlayerStorageValue(cid, storage))
  16. else
  17. setPlayerStorageValue(cid, storage, -1)
  18. doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "You can only use one bonus per time.")
  19. end
  20. end
  21.  
  22.  
  23. ----------------------------------------------------------------------------
  24.  
  25.  
  26. --[[Creature Script que registra o double bonus sempre que ataca uma criatura]]--
  27. -- Tag: Colocar em creaturescripts.xml
  28. <event type="target" name="doubleBonusRegister" event="script" value="doubleBonusRegister.lua"/>
  29.  
  30. -- Criar arquivo em creaturescripts/scripts/ chamado doubleBonusRegister.lua e colocar:
  31. local storage = 7718
  32. local bonusTime = 10*24*60*60
  33.  
  34. function registerDoubleBonus (cid, target)
  35. if getPlayerStorageValue(cid, storage) == -1 then return true end
  36. if os.time() - bonusTime >= getPlayerStorageValue(cid, storage) then
  37. doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
  38. doPlayerSetRate(cid, SKILL__LEVEL, getExperienceStage(getPlayerLevel(cid)))
  39. unregisterCreatureEvent(cid, "doubleBonusRegister")
  40. setPlayerStorageValue(cid, storage, -1)
  41. return true
  42. end
  43. if isMonster(target) then
  44. registerCreatureEvent(target, "doubleBonus")
  45. end
  46. return true
  47.  
  48. end
  49.  
  50. function onCombat(cid, target)
  51. registerDoubleBonus (cid, target)
  52. return true
  53. end
  54.  
  55.  
  56. ----------------------------------------------------------------------------
  57.  
  58.  
  59. --[[Creature Script que executa o double bonus sempre que a criatura registrada morre]]--
  60. -- Tag: Colocar em creaturescripts.xml
  61. <event type="death" name="doubleBonus" event="script" value="doubleBonus.lua"/>
  62.  
  63. -- Criar arquivo em creaturescripts/scripts/ chamado doubleBonus.lua e colocar:
  64. local storage = 7718
  65. local bonusTime = 10*24*60*60
  66. local serverDropRate = 1000 -- VOCÊ DEVE EDITAR AQUI PARA O DROP RATE DO SEU SERVIDOR
  67. local bonusLoot = 2 -- VOCÊ DEVE EDITAR AQUI PARA O BONUS LOOT QUE DESEJA
  68. local bp_id = 1987
  69.  
  70. function bonusCreatureLoot(pos, monsterName)
  71. local corpse = getTileThingByPos(pos)
  72.  
  73. if not isCorpse(corpse.uid) then return false end
  74. doAddContainerItem(corpse.uid, 1988, 1)
  75.  
  76. local bp = getContainerItem(corpse.uid, getContainerItem(corpse.uid, getContainerSize(corpse.uid)))
  77.  
  78. local lootList = getMonsterLootList(monsterName)
  79. for _, loot in pairs(lootList) do
  80. local randomizedChance = math.random (1, 100000)
  81. if randomizedChance <= bonusLoot * loot.chance * serverDropRate then
  82. doAddContainerItem(bp.uid, loot.id, loot.countmax and math.random(1,loot.countmax) or 1)
  83. end
  84. end
  85. end
  86.  
  87. function onDeath(cid, corpse, deathList)
  88. local killer = #deathList > 1 and deathList[2] or deathList[1]
  89. if not isPlayer(killer) then return true end
  90. if not isMonster(cid) then return true end
  91. if getPlayerStorageValue(killer, storage) == -1 then return true end
  92. if os.time() - bonusTime >= getPlayerStorageValue(killer, storage) then
  93. doPlayerSendTextMessage(killer, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
  94. doPlayerSetRate(killer, SKILL__LEVEL, getExperienceStage(getPlayerLevel(killer)))
  95. unregisterCreatureEvent(killer, "doubleBonusRegister")
  96. unregisterCreatureEvent(cid, "bonusRegister")
  97. setPlayerStorageValue(killer, storage, -1)
  98. return true
  99. end
  100.  
  101. if not isContainer(corpse.uid) then return true end
  102. addEvent(bonusCreatureLoot, 100, getCreaturePosition(cid), getCreatureName(cid))
  103.  
  104. return true
  105. end
  106.  
  107.  
  108.  
  109. -- 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):
  110.  
  111. local bonusTime = 10*24*60*60
  112. local bonusStorage = 7718
  113. doBroadcastMessage(os.time() .. " " .. getPlayerStorageValue(cid, bonusStorage))
  114. if os.time() - bonusTime < getPlayerStorageValue(cid, bonusStorage) then
  115. local remainingTime = (bonusTime - (os.time()-getPlayerStorageValue(cid, bonusStorage)))/(60*60)
  116. if remainingTime >= 1 then
  117. doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus re-started. You have: less than " .. math.ceil(remainingTime) .. " hours")
  118. else
  119. doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus re-started. You have: less than " .. math.ceil(remainingTime) .. " hour")
  120. end
  121. registerCreatureEvent(cid, "doubleBonusRegister")
  122. else
  123. doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
  124. doPlayerSetRate(cid, SKILL__LEVEL, getExperienceStage(getPlayerLevel(cid)))
  125. setPlayerStorageValue(cid, bonusStorage, -1)
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement