So I am working on a pickpocket swep right now for a dark rp server, and I am having trouble figuring out how to make it so it REFUNDS the money to the players that I stole, when I die, whether that be suicide or that player killing me. Also how would I make it so that would only be true for lets say 1 minute then if they kill me after 1 minute, they don’t get a refund. Of course I need it so I can keep pickpocketing money from people and they only have a minute to get it back or else its mine forever. here is the pastebin to the script, note I don’t want it to refund weapons if stolen, that is also part of the swep that I have disabled. http://pastebin.com/GaUEJU2u
target:addMoney( -money ) self.Owner:addMoney( money )
Everything you need right there
I’m pretty sure that’s scriptfodder script.
I still have no idea what to do, I feel like ive tried everything
Create a function and connect it to a gm playerdeath hook
after pickpocket create a minute timer on the player
if the player’s timer still exists on death, give back the money
I made this code but it isnt working right, please tell me if somethings wrong
local refundMoney = hook.Call( “PlayerDeath” )
if refundMoney then
target:addMoney( money )
self.Owner:addMoney( -money )
target:AddMoney( money )
self.Owner:AddMoney( -money )
function playerDies( victim, inflictor, killer ) if ( victim == killer ) then killer:MultiversionNotify(NOTIFY_ERROR, "Your money was refunded!") end end hook.Add( "PlayerDeath", "Death Test", playerDies ) Refund()
Are there any errors?
[ERROR] lua/ulx/modules/sh/fun.lua:160: attempt to index local ‘ply’ (a nil value)
- fn - lua/ulx/modules/sh/fun.lua:160
- Call - lua/ulib/shared/hook.lua:110
3. Refund - addons/pickpocket swep/lua/weapons/swep_pickpocket.lua:246
4. unknown - addons/pickpocket swep/lua/weapons/swep_pickpocket.lua:265
but when I remove the code i made that error goes away
Of course because ply isnt defined
where would I define ply ?
Woo just got on my computer sorry, dont use that.
ok thank you! where would I put this in regards to my actual code, right now its at very bottom and I get no errors but nothing really happens, and do I use my code from above? sorry for me being so difficult
didnt realise what i wrote yeah dont use my code… just got on my computer ill test something now
add my steam if u want it might make things easier to send me http://steamcommunity.com/profiles/76561198041387148/