Forum

> > CS2D > Scripts > Money Drop on Death
Forums overviewCS2D overview Scripts overviewLog in to reply

English Money Drop on Death

5 replies
To the start Previous 1 Next To the start

old Money Drop on Death

Computerguy419
User Off Offline

Quote
I have look and looked for this script, but the closest I could find was a drop on command. I want all of the money the player that dies, has to drop for all the other players to pick up. Could I have a little help on this one?

√ Computerguy419

old Re: Money Drop on Death

KenVo
User Off Offline

Quote
There must be a faster way, but whatever this should work
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function drop_all_money(id)
	local tilex = player(id,"tilex")
	local tiley = player(id,"tiley")
	if player(id,"exists") and player(id,"money") > 0 then
		while player(id,"money") >= 1000 do
			local money = player(id,"money") - 1000
			parse("setmoney ".. id .. " " ..money)
			parse("spawnitem".. " 68 " .. tilex .. " " .. tiley)
		end
		while player(id,"money") >= 500 do
			local money = player(id,"money") - 500
			parse("setmoney ".. id .. " " ..money)
			parse("spawnitem".. " 67 " .. tilex .. " " .. tiley)
		end
		while player(id,"money") >= 100 do
			local money = player(id,"money") - 100
			parse("setmoney ".. id .. " " ..money)
			parse("spawnitem".. " 66 " .. tilex .. " " .. tiley)
		end
	end
end

addhook("die","_die")
function _die(victim,killer,weapon,x,y)	
	drop_all_money(victim)
end

old Re: Money Drop on Death

Anders4000
User Off Offline

Quote
user KenVo has written
There must be a faster way, but whatever this should work
Code: >


I guess that's somewhat the fastest way. Can't really think of any faster.
Looks pretty solid, good work! (:

EDIT: Well I just found one:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function drop_money(id,amount,iid)
	while player(id,"money") >= amount do
		local money = player(id,"money") - amount
		parse("setmoney "..id.." "..money)
		parse("spawnitem".." "..iid.." "..tilex.." "..tiley)
	end
end

function drop_all_money(id)
	local tilex = player(id,"tilex")
	local tiley = player(id,"tiley")
	if player(id,"exists") and player(id,"money") > 99 then
		drop_money(id,1000,68)
		drop_money(id,500,67)
		drop_money(id,100,66)
	end
end

addhook("die","_die")
function _die(victim,killer,weapon,x,y)	
	drop_all_money(victim)
end

It's not a big improvement, but it's shorter.

old Re: Money Drop on Death

KenVo
User Off Offline

Quote
Mistakes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function drop_money(id,amount,iid)
	while player(id,"money") >= amount do
		local money = player(id,"money") - amount
		parse("setmoney "..id.. " " ..money)
		parse("spawnitem ".. iid .." " ..player(id,"tilex").. " " ..player(id,"tiley"))
	end
end

function drop_all_money(id)
	if player(id,"exists") and player(id,"money") > 0 then
		drop_money(id,1000,68)
		drop_money(id,500,67)
		drop_money(id,100,66)
	end
end

addhook("die","_die")
function _die(victim,killer,weapon,x,y)     
	drop_all_money(victim)
	parse("setmoney "..victim.. " " ..0)
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview