Forum

> > CS2D > Scripts > 4 sub-teams - Friendly fire
Forums overviewCS2D overview Scripts overviewLog in to reply

English 4 sub-teams - Friendly fire

4 replies
To the start Previous 1 Next To the start

old 4 sub-teams - Friendly fire

Elev3n
User Off Offline

Quote
Hey Guys!

I created 4 sub-teams (rival gangs).
After choosing the character, the player can choose:
(gang name example)

IMG:https://i.imgur.com/wmFui3B.png


Problem:
I do not want that a player kill your own gang friends, but only members of enemy gangs!

Could anyone help me?
edited 1×, last 07.03.15 02:55:34 am

old Re: 4 sub-teams - Friendly fire

Time
User Off Offline

Quote
Jaspion has written
everyone can kill everyone.
I do not want that a player kill your own gang friends, but only members of enemy gangs!

so you basically did nothing

old Re: 4 sub-teams - Friendly fire

Surplus
User Off Offline

Quote
You check if the victims team is the same as the attackers team.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function initArray(count)	--Makes function with parameters
	local array = {}		--Creates an empty array that cant be used outside of this function
	for i = 0, count do		--Loops as many times as parameter tells it to
		array[i]=0 			--Creates an element in the array with value 0
	end 					--Ends loop
	return array 			--returns the newly made array to whatever called it
end 						--ends function

teams=initArray(32)			--should contain teams of all player ids, your menu should set it with teams[id]=*Gangname here*

addhook("hit","TeamDamageCheck")			--Makes the function execute whenever someone is hit
function TeamDamageCheck(id,source) 		--function
	if ( teams[id] == teams[source] ) then 	--checks if attackers team is same as victms
		return 1 							--if last statement was true, ignores the hit
	end 				--ends statement
end 					--ends function

Before integrating this code into your own, I would recommend you actually try to understand what all this does.

old [Solved]

Elev3n
User Off Offline

Quote
Thanks for reply @user Surplus: and sorry for the delay in responding...

Well, I understood the script but do not know exactly where to place the "teams[id]".


∗ UPDATE (edited):

After hours and hours reading about lua script, I finally understood and i found the correct place to apply the "teams [id] = * gangname *", and even i put a "msg2" saying that this is not possible.

Thanks, brother!
edited 1×, last 09.03.15 07:28:48 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview