I'm trying to assing a entity to a team, the goal is the next: in my heart heart entity when you kill somebody a red heart enttiy is spawned, if you touch it you get+1 lifes, i want to make to only users from the same team with the 'victim' can touch the heart.
Example if i'm a tero and i die, only terrorists can take that heart. also to render the entity based on the team .. rendering is working fine bun i can't assing to a entity a team, idk why , here's the code:
Declaration:
PHP Code:
// i will ad in g_pdData[] but for the moment leave it separatly until somebody figure out why is not working // i use 33 the size because anyway can exist in a round as much entites as much players die . so i think is enough 33 new EntTeamId[ Max_Players + 1 ];
Assigning the value of the victim team ( i try in a looooot of ways, is just simple not working ):
It does. If you set entity's pev_team to some value it will remain that way unless some other code changes it (like the game itself, which is unlikely for info_target entities). Just as for any other pev_ value. Even Lasermine plugin uses it to determine lasermine entity's team if I remember correctly.
It does. If you set entity's pev_team to some value it will remain that way unless some other code changes it (like the game itself, which is unlikely for info_target entities). Just as for any other pev_ value. Even Lasermine plugin uses it to determine lasermine entity's team if I remember correctly.
So what i done wrong above ?
However i'm also curious 'why' my first code wasn't working ?
However i'm also curious 'why' my first code wasn't working ?
Just because you can make such arrays for players, does not mean you can make it for other entities too.
Let me explain:
PHP Code:
new EntTeamId[ Max_Players + 1 ];
This array has valid indexes from 0 to 32(however, for players you will only use the 1 - 32 indexes). You should know by now that the first 32 indexes are always reserved for players. In other words, from 1 to maxplayers there are always players. After MAX_PLAYERS, the other entities indexes start. Given that your "iEnt" is a custom entity it's guaranteed that it's index will be bigger than 32, so there is no way to do EntTeamId[iEnt].
Check your error logs, this code will produce an index out of bounds.
What Klippy said is correct and should work. Anyway, you can use other unused fields like pev_iuser1.