how can i do a interator of players streammeds?
# support-forum
c
I wanna loop for closer players and create a list of streammed players would use a lot of less resources to do that, but idk how to do I tried:
Copy code
c++
new Iterator:PlayersStreamedForPlayer<MAX_PLAYERS><MAX_PLAYERS>;

public OnPlayerStreamIn(playerid, forplayerid)
{
    Iter_Add(PlayersStreamedForPlayer, forplayerid, playerid);
}
public OnPlayerStreamOut(playerid, forplayerid)
{
    Iter_Remove(PlayersStreamedForPlayer, forplayerid, playerid);
}

CMD:test(playerid) {
    new Float:Pos[3];
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    foreach(new i : PlayersStreamedForPlayer) {
        if(!IsACop(i)) continue;
        if(IsPlayerInRangeOfPoint(i, 30.0, Pos[0], Pos[1], Pos[2])) {
            new str[128];
            format(str, sizeof(str), "Target id was found: %i", i);
            SendClientMessage(playerid, -1, str);
        }
    }
}
but it returns me errors on lines: line:
Copy code
c++
new Iterator:PlayersStreamedForPlayer<MAX_PLAYERS><MAX_PLAYERS>;
error:
Copy code
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(484) : warning 200: symbol "PlayersStreamedForPlayer@YSII_C" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(484) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(484) : error 001: expected token: ";", but found "<"
line:
Copy code
c++
Iter_Add(PlayersStreamedForPlayer, forplayerid, playerid);
error:
Copy code
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(30069) : warning 200: symbol "PlayersStreamedForPlayer@YSII_C" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(30069) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(30069) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(30069) : warning 202: number of arguments does not match definition
line:
Copy code
c++
Iter_Remove(PlayersStreamedForPlayer, forplayerid, playerid);
error:
Copy code
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(30078) : warning 200: symbol "PlayersStreamedForPlayer@YSII_C" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(30078) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(30078) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(30078) : warning 202: number of arguments does not match definition
line:
Copy code
c++
foreach(new i : PlayersStreamedForPlayer) {
error:
Copy code
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(40846) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(40846) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(40846) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
is anybody know a way to make it work?line:
Copy code
c++
foreach(new i : PlayersStreamedForPlayer) {
error:
Copy code
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(40846) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(40846) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
/home/hiwyn/Documents/sampserver/gamemodes/CNR.pwn(40846) : warning 200: symbol "PlayersStreamedForPlayer@YSII_A" is truncated to 31 characters
is anybody know a way to make it work?
g
new Iterator:PlayersStreamedForPlayer[MAX_PLAYERS]
Multi-Dimensional Iterators From the original release topic it should be known that you can have arrays of iterators (multi-dimensional, or MD, iterators):
Copy code
c
new
    Iterator:OwnedVehicle[MAX_PLAYERS]<MAX_VEHICLES>;
Iter_Init(OwnedVehicle);
// Add vehicles to players here...
Iter_Add(OwnedVehicle[playerid], 42);
Iter_Add(OwnedVehicle[playerid], 43);
Iter_Add(OwnedVehicle[playerid], 44);
// Other code...
foreach (new vehicleid : OwnedVehicle[playerid])
{
    printf("Player %d owns vehicle %d", playerid, vehicleid).
}
Iter_Add(PlayersStreamedForPlayer[forplayerid], playerid);
c
YSI is not compatible with sampvoice 😦
@gorgeous-tomato-73021 u did not post a example here?
g
I did, but zWz were correct
i only posted this: new Iterator:PlayersStreamedForPlayer[MAX_PLAYERS];
this is the way in a multidimensional array in iterator
c
ty
is that right? \/
Copy code
c++
new Iterator:PlayersStreamedForPlayer[MAX_PLAYERS]<MAX_PLAYERS>;

public OnPlayerStreamIn(playerid, forplayerid)
{
    Iter_Add(PlayersStreamedForPlayer[forplayerid], playerid);
}
public OnPlayerStreamOut(playerid, forplayerid)
{
    Iter_Remove(PlayersStreamedForPlayer[forplayerid], playerid);
}

CMD:test(playerid) {
    new Float:Pos[3];
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    foreach(new i : PlayersStreamedForPlayer[playerid]) {
        if(!IsACop(i)) continue;
        if(IsPlayerInRangeOfPoint(i, 30.0, Pos[0], Pos[1], Pos[2])) {
            new str[128];
            format(str, sizeof(str), "Target id was found: %i", i);
            SendClientMessage(playerid, -1, str);
        }
    }
}
g
I don't know bruh lmao
how its not?
c
server crashes if u use both
i'll test it, ty very much
it compiles, lets see if it will work 😄
g
just use the sampvoice in a filterscript