Advertisement
Alscara

Untitled

Oct 8th, 2015
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. local config = {
  2.     summonName = "Orc",
  3.     cost = 10000, -- in gp, put 0 to disable
  4.     remove = "yes" -- should egg by removed after use?
  5. }
  6.  
  7. config.remove = (config.remove == "yes" and true or false)
  8. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  9.     local pos = player:getPosition()
  10.     if(pos.x == CONTAINER_POSITION) then
  11.         player:sendCancelMessage("Put item on the floor first.")
  12.         return true
  13.     end
  14.  
  15.     if(config.cost > 0 and player:getMoney() < config.cost) then
  16.         player:sendCancelMessage("Not enought money, trainer cost " .. config.cost .. " gp's.")
  17.         return true
  18.     end
  19.  
  20.     effect = CONST_ME_MAGIC_RED
  21.    
  22.     Game.createMonster(config.summonName, pos)
  23.     ret:setMaster(player)
  24.     if(config.cost > 0) then
  25.             player:removeMoney(config.cost)
  26.     end
  27.     if(config.remove == true) then
  28.         item:remove(1)
  29.     end
  30.    
  31.     Position(pos):sendMagicEffect(effect)
  32.     return true
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement