Forum

> > CS2D > Scripts > Killing a player will result in *something*
Forums overviewCS2D overview Scripts overviewLog in to reply

English Killing a player will result in *something*

2 replies
To the start Previous 1 Next To the start

old Killing a player will result in *something*

Mami Tomoe
User Off Offline

Quote
I have a exp script so that's the *something*.
I don't know yet how to make these kind of scripts because I never saw one (only in servers).
Ill give you example of what I need:

Player1 KILLED Player2
Player1 will gain 5 EXP
Player2 will lose 10 EXP
Here's the command you might need:
1
cs_exp[id]=cs_exp[id]+5
and
1
cs_exp[id]=cs_exp[id]-10

Don't forget to change the 'id' to what you're using o.O

old Re: Killing a player will result in *something*

Nekomata
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
function dieded(id, vid, wep, x, y)
	cs_exp[id]=cs_exp[id]-10
	msg(player(id, "name")..' killed '..player(vid, "name"))
end

-- After the update, the 'victim id' and the 'player id' got switched here for this hook so i've fixed it for now. pay no heed. At the moment, it's like this: killeded(id, vid, wep, x, y)
function killeded(vid, id, wep, x, y)
	cs_exp[vid]=cs_exp[vid]+5
end

addhook("die", "dieded")
addhook("kill", "killeded")

That's one way. You can do it all in one hook if you don't need the extra parameters like 'wep', 'x' & 'y'. For example, I use the top method in doghouse because I need the extra parameters for stuff like effects. You've seen that death ring right? It needs the x and ys of where you died.

1
2
3
4
5
6
function dieded(vid, kid, wep, x, y)
	cs_exp[vid]=cs_exp[vid]-10
	cs_exp[kid]=cs_exp[kid]+5
	msg(player(kid, "name")..' killed '..player(vid, "name"))
end
addhook("die", "dieded")

old Re: Killing a player will result in *something*

Mami Tomoe
User Off Offline

Quote
user Nekomata has written
1
2
3
4
5
6
function dieded(vid, kid, wep, x, y)
	cs_exp[vid]=cs_exp[vid]-10
	cs_exp[kid]=cs_exp[kid]+5
	msg(player(kid, "name")..' killed '..player(vid, "name"))
end
addhook("die", "dieded")

I used this code (second) but I switched the 'vid' with 'id' because it did the opposite (took from the killer and gave to the one who died)

Anyways it worked thanks!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview