beeki

[event surprise] action

Jan 19th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1.  function onUse(cid, item, fromPosition, itemEx, toPosition)
  2.             local q = {
  3.                 a = {1111, 2222, 3333, 4444, 5555, 6666, 0}, -- Id of items which surprise package can create (0 means nothing).
  4.                 b = {1, 2} -- Amount of create items (random).
  5.             }
  6.             local r, s, t, u = q.a[math.random(1, #q.a)], getItemNameById(r), amount[math.random(1, #q.b)], getCreaturePosition(cid)
  7.  
  8.             if(r == 0) then
  9.                 doCreatureAddHealth(cid, -(math.random(20,100)))
  10.                 doSendMagicEffect(u, CONST_ME_EXPLOSIONHIT)
  11.                 doPlayerSendTextMessage(cid, 4, "It was a trap! Surprise package burned you!")
  12.             else
  13.                 doPlayerAddItem(cid, r, t)
  14.                 doSendMagicEffect(u, CONST_ME_GIFT_WRAPS)
  15.                 doPlayerSendTextMessage(cid, 4, "Surprise package gave you ".. t .."x of ".. s ..".")
  16.             end
  17.             return true
  18.         end
Advertisement
Add Comment
Please, Sign In to add comment