henoireil

Untitled

Jan 24th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 KB | None | 0 0
  1. SWEP.Base = "progressweapon_base_v1"
  2. if CLIENT then
  3.     SWEP.PrintName = "Pickpocket"
  4.     SWEP.Instructions = "Steal money from inconsiderate fools.\nCome close to your victim and press left mouse button."
  5. else
  6.     AddCSLuaFile("shared.lua")
  7. end
  8.  
  9. /*
  10.     Configuration
  11. */
  12. SWEP.CheckTime = 2 // pickpocket time
  13. SWEP.StealDetection = 20 // time required to detect the loss of money (victim will receive a notify about his loss right after this time passed)
  14. SWEP.MoneyToSteal = {200, 400} // you will earn from 20 to 40 $ for every pickpocket
  15. SWEP.StealTreshold = 10000 // you can not pickpocket a player who has less than 200$
  16.  
  17.  
  18. /*
  19.     Do not edit the code below unless you know what you are doing
  20. */
  21. SWEP.Spawnable = true
  22. SWEP.AdminSpawnable = true
  23.  
  24. function SWEP:PlaySound()
  25. end
  26.  
  27. function SWEP:Done(victim)
  28.     local money_to_steal = math.random(self.MoneyToSteal[1], self.MoneyToSteal[2])
  29.     if not victim:MultiversionCanAfford(money_to_steal) or (victim.nextSteal and victim.nextSteal > CurTime()) or !victim:MultiversionCanAfford(self.StealTreshold) then self.Owner:MultiversionNotify(NOTIFY_ERROR, "Have some mercy! This guy already has nothing left!") return end
  30.    
  31.     victim.nextSteal = CurTime() + 30
  32.  
  33.     self.Owner:MultiversionNotify(NOTIFY_GENERIC, "You stole "..tostring(money_to_steal).."$!")
  34.    
  35.     local time = self.StealDetection
  36.     timer.Simple(time, function() if IsValid(victim) then victim:MultiversionNotify(NOTIFY_ERROR, "Someone stole "..money_to_steal.."$ from your pocket!") end end)
  37.    
  38.     victim:MultiversionAddMoney(-money_to_steal)
  39.     self.Owner:MultiversionAddMoney(money_to_steal)
  40.  
  41.     bLogs.Log({
  42.         module = "PickPocket",
  43.         log = self.Owner:Nick() .. " a pickpocket " .. victim:Nick() .. " pour un montant de $" .. money_to_steal,
  44.         involved = {self.Owner},
  45.     })
  46.    
  47.     umsg.Start("anim_keys")
  48.         umsg.Entity(self.Owner)
  49.         umsg.String("usekeys")
  50.     umsg.End()
  51. end
  52.  
  53. if SERVER then
  54.     hook.Add("PlayerInitialSpawn", "PickpocketDelay", function(ply)
  55.         ply.nextSteal = CurTime() + 30 // Prevent recently connected players from pickpocket
  56.     end)
  57. end
Advertisement
Add Comment
Please, Sign In to add comment