Advertisement
LuckOake

Money Steal Item

Jan 23rd, 2013
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. function onUse(cid, item, position, itemEx)
  2.     local chance = 10 -- Porcentagem de chance de conseguir roubar alguém
  3.     local count = 10 -- Porcentagem do dinheiro total da pessoa que será roubado
  4.    
  5.     if not isPlayer(itemEx.uid) then
  6.         doPlayerSendCancel(cid, "You can only steal from players.")
  7.         return true
  8.     elseif getPlayerLevel(cid) < getPlayerLevel(itemEx.uid) then
  9.         doPlayerSendCancel(cid, "You can only steal items from players with lower level than you.")
  10.         return true
  11.     elseif itemEx.uid == cid then
  12.         doPlayerSendCancel(cid, "You can't steal money from yourself!")
  13.         return true
  14.     elseif getPlayerMoney(itemEx.uid) <= 0 then
  15.         doPlayerSendCancel(cid, "This player hasn't money.")
  16.         return true
  17.     elseif math.random(1, 100) > chance then
  18.         doPlayerSendTextMessage(itemEx.uid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..getCreatureName(cid).." tried to steal money from you and failed.")
  19.         doSendMagicEffect(getCreaturePosition(cid), 2)
  20.         doPlayerSendCancel(cid, "You failed in stealing.")
  21.         return true
  22.     end
  23.        
  24.     doRemoveItem(item.uid, 1)
  25.     doPlayerRemoveMoney(itemEx.uid, math.ceil(getPlayerMoney(itemEx.uid)*(count/100)))
  26.     doPlayerAddMoney(cid, math.ceil(getPlayerMoney(itemEx.uid)*(count/100)))
  27.     doPlayerSendTextMessage(itemEx.uid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..getCreatureName(cid).." stole "..math.ceil(getPlayerMoney(itemEx.uid)*(count/100)).." gold coins from you successfully.")
  28.     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You stole "..math.ceil(getPlayerMoney(itemEx.uid)*(count/100)).." gold coins from "..getCreatureName(itemEx.uid).." successfully.")
  29.     doSendMagicEffect(getCreaturePosition(itemEx.uid))
  30.     return true
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement