English 4 sub-teams - Friendly fire

4 replies
Goto Page
To the start Previous 1 Next To the start
24.02.15 10:15:06 pm
Up
Elev3n
User
Offline Off
Hey Guys!

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

IMG:http://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
24.02.15 10:24:50 pm
Up
Waldin
User
Offline Off
change on standar :v
user Waldin (2014) has written:
can be create 3D option for tiles on 3D
user DC (2014) has written:
@user Waldin: This is a 2D game. there are no 3D tiles.
changelog (2017) has written:
ADDED Experimental 3D rendering mode
24.02.15 11:15:34 pm
Up
Time
User
Offline Off
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
IMG:https://sc-cdn.scaleengine.net/i/3a137042de3c79a4d3c69b1f036866e92.jpg
24.02.15 11:35:04 pm
Up
Surplus
User
Offline Off
You check if the victims team is the same as the attackers team.

Code:
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.
07.03.15 01:58:40 am
Up
Elev3n
User
Offline Off
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