Open-GTO / foreach

foreach standalone include (non y_iterate version)
Other
22 stars 8 forks source link

Iter_Remove is failing/not working on custom array of iterators #19

Open hiwyn opened 9 months ago

hiwyn commented 9 months ago

Iter_Remove is failing/not working on custom array of iterators

public OnPlayerDisconnect(playerid, reason) {
       new facid = fmember[playerid];
        if(facid > 0) {
            Iter_Remove(FactionMembers_List[facid], playerid);
        }
}

but the player id stills on the facid list

ziggi commented 9 months ago

Show output with this:

public OnPlayerDisconnect(playerid, reason) {
    new facid = fmember[playerid];
    if (facid > 0) {
        foreach (new id : FactionMembers_List[facid]) {
            printf("BEFORE playerid = %d", id);
        }

        Iter_Remove(FactionMembers_List[facid], playerid);

        foreach (new id : FactionMembers_List[facid]) {
            printf("AFTER playerid = %d", id);
        }
    }
}