Forum

> > CS2D > Scripts > Marking player that shot another.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Marking player that shot another.

2 replies
To the start Previous 1 Next To the start

old Marking player that shot another.

Grimm
User Off Offline

Quote
Hey,
I've been trying to learn a little lua in order to make a real simple mod for 'jail/prison' servers. The idea with this script would be to mark the player from the terrorist team that attacks a CT opponent. I have the actual 'marking' technique done, but I just can't figure out how it will determine if it was a terrorist attacking a ct member. I have been trying to test the mechanism using just a simple message in this code:

1
2
3
4
5
addhook("hit","Hit")
function Hit(victim,id,wpn,hpdmg,apdmg,rawdmg)
     if player(id,"team") ~= player(victim,"team") then
		msg("Potato")
end

Yeah so basically line 3 is absolutely screwed. Could someone with a little more knowledge help me out? I would be forever in your debt.
Thank you for your time,
Grimm

old Re: Marking player that shot another.

EngiN33R
Moderator Off Offline

Quote
You're actually much closer than you think. Let me help out:
1
2
3
4
5
6
addhook("hit","Hit")
function Hit(victim, id) -- Unlike in C or Java, you can drop the arguments you don't use.
	if player(id,"team") == 1 and player(id,"team") ~= player(victim,"team") then
		msg("Potato")
 	end
end

player(id, "team") returns 0 when the player is a spectator, 1 when they're a terrorist, 2 when they're a counter-terrorist and 3 when they're a VIP (in as_ maps only).

Pleasure to see someone with some manners on this site, and good luck!

old Re: Marking player that shot another.

Grimm
User Off Offline

Quote
Thanks EngiN33R, it works like a dream! I really appreciated the comments you added in the code too. Really helpful for any other scripts I have to write. If I ever complete this humble 'mod' of mine I will be sure to give you credit for these lines you have written.
Thanks again for your time,
Grimm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview