imagine you got this array
pawn Код:
new ObservedByID[MAX_PLAYERS][MAX_PLAYERS];
each second dimension will carry max 500 players spectating the player in the first dimension:
pawn Код:
ObservedByID[Babul][0]+=1;//raise the amount of players watching me
and then set the playerid of the player watching into cell 1 (cell 0 stores the amount for the max cell-entry)
pawn Код:
ObservedByID[Babul][ObservedByID[Babul][0]]=iTorran;
//thats the same as
ObservedByID[Babul][1]=iTorran;
//...since the script needs to cycle through all [Babul] entries (1 in cell 0), it will access cell [1], thats where YOUR id is stored.
now the little issue when one player stops spectating, so his playerid gets removed from, lets say, cell [3], will result this array being changed:
pawn Код:
ObservedByID[Babul]={5 (playerids watching), 10,11,12,13,14}
playerids 10 to 14 are watching me, and playerid 12 stops now, this causes a gap in the array:
pawn Код:
ObservedByID[Babul]={5 (playerids watching), 10,11,<>,13,14}
since you know the max amount of players speccing, stored in cell 0, (its 4 players now indeed), you can use the missing playerid 12 cell [3] to store the last playerid 14, which changes the array to
pawn Код:
ObservedByID[Babul]={4 (playerids watching), 10,11,14,13,<>}
where the last cell [5] is not accessed anymore.
what YOU will need to care for, are the links to the cell[] from the WATCHING players:
if you are the playerid12 who stops speccing, then how the script should know that your id got stored in cell 3?
pawn Код:
new WatchingID[MAX_PLAYERS];
...since a player can spectate ONE player only, while he can (be? get?) watched by more players...
i hope you know how to do the rest? ^^