Forum

> > CS2D > Scripts > Lua Request - No money loss on teamkill
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Request - No money loss on teamkill

11 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Lua Request - No money loss on teamkill

MAfia Pro
User Off Offline

Zitieren
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.
2× editiert, zuletzt 17.12.13 20:38:02

alt Re: Lua Request - No money loss on teamkill

Rainoth
Moderator Off Offline

Zitieren
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.

alt Re: Lua Request - No money loss on teamkill

Avo
User Off Offline

Zitieren
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).

alt Re: Lua Request - No money loss on teamkill

Rainoth
Moderator Off Offline

Zitieren
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

alt Re: Lua Request - No money loss on teamkill

Rainoth
Moderator Off Offline

Zitieren
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.

alt Re: Lua Request - No money loss on teamkill

Rainoth
Moderator Off Offline

Zitieren
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 ._.

alt Re: Lua Request - No money loss on teamkill

Avo
User Off Offline

Zitieren
@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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht