Forum

> > CS2D > Scripts > Lua Request - No money loss on teamkill
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Request - No money loss on teamkill

11 replies
To the start Previous 1 Next To the start

old Lua Request - No money loss on teamkill

MAfia Pro
User Off Offline

Quote
Hello again. I'm here because i need a script which disables money loss on teamkills (as in title). I searched for it for long, i couldn't find it. I might just be really bad at looking for things. Thanks for any help.
edited 2×, last 17.12.13 08:38:02 pm

old Re: Lua Request - No money loss on teamkill

Rainoth
Moderator Off Offline

Quote
I think it's possible to change settings so it doesn't take your money.

P.S. The title is wrong. It shows that you request a lua that will make a person lose money when he kills a teammate, not vice-versa.

old Re: Lua Request - No money loss on teamkill

Avo
User Off Offline

Quote
Changing the title? It's surely possible.

@topic: even if it's not possible to change in settings you can always give money to player when he's losing it (kill hook).

old Re: Lua Request - No money loss on teamkill

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
money = 0
addhook("kill","compensate")
function compensate(k,v)
local cash = player(k,"money")
	if player(k,"team")==player(v,"team") then
		parse("setmoney "..k.." "..cash+money)
	end
end

There. When you kill a person of same team, it'll add "money" money to your character. You should change it to 300 or whatever so whenever you kill you would lose AND get the same amount of money and therefore your money balance wouldn't change

old Re: Lua Request - No money loss on teamkill

Rainoth
Moderator Off Offline

Quote
No that's not right. It doesn't set your money value to something. It ADDS a certain amount of cash for you.

Say you got 2000$.
You lose 500$ when you kill somebody.
You use this script and change
"money = 0" into "money = 500" which is how much you want to compensate.

You kill a teammate.
The cs2d takes away 500$ from you. Now you have 1500$ and that's not good, right ? That's where my script works.
It adds the "money" to your current cash.
Set money to Current Cash + "Money" variable
Set Money to 1500 + 500

Money before kill : 2000
During kill : 2000 - 500 + 500
After Kill : 2000

The money doesn't change. You just replace the "0" to whatever money value you want. I made it because I was too lazy to check how much money a person loses when he kills a teammate.

old Re: Lua Request - No money loss on teamkill

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
tbl = {}
money = 3300
addhook("kill","compensate")
function compensate(k,v)
local cash = player(k,"money")
     if player(k,"team")==player(v,"team") then
    	 if cash < 3301 then
       	   tbl[k] = money - cash
        	parse("setmoney "..k.." "..tbl[k])
  	   else
    	      parse("setmoney "..k.." "..cash+money)
  	   end
     end
end

I hate editing code in this site... So inconvenient ._.

old Re: Lua Request - No money loss on teamkill

Avo
User Off Offline

Quote
@user MAfia Pro: So you have to change
money = 0
to
money = 3300
in Rainy's script.
---
@user Rainoth:
If you're to lazy to check how much money player loses on team kill you could also use other, a little longer method:
1
2
3
4
5
6
7
8
9
10
11
TempMoney = {}
addhook("hit", "HookHit")
HookHit = function(id, src)
	TempMoney[src] = player(src, "money")
end
addhook("kill", "HookKill")
HookKill = function(k, v)
	if player(k, "team") == player(v, "team") then
		parse("setmoney "..k.." "..TempMoney[k])
	end
end
which would work even if loss were customisable.

Edit: damn, ninja'd.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview