• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] too resource-intensive array
I need to create an array(i choosed iterator)?of streamed players for every player. So i got
PHP Code:

But it's very?resource-intensive, what?can be used instead or may be i don't know something about streaming players?

P.S. I know that i can redefine MAX_PLAYERS to less value but i don't want to do it (1000 default).
[Image: aWbv5wm.gif]

All streamed players for every player? What do you need to do with it?
(2019-04-20, 05:55 AM)mr_sacrimoni Wrote: All streamed players for every player? What do you need to do with it?
For identify nearby players?instead checking every player
PHP Code:
for(new iMAX_PLAYERSi)
//find out how far is every player from sender for sending him a msg 
Check only streamed players (must be faster, especially when streamed 2-3 players with 500 online)
PHP Code:
foreach(StreamedPlayers[playerid], i)
// find out how far is streamed player from sender for sending him a msg 

I will use it in OnPlayerText for chat sys
[Image: aWbv5wm.gif]

That array is about 4Mb. I wouldn't worry about it.
(2019-04-20, 07:19 AM)Mark2 Wrote: For identify nearby players?instead checking every player

Checking every player every single time might seem resource-intensive, but it is not. Honestly might be better than having to deal with initializing and updating the array consistently (which would also NOT be resource intensive either, but will be work intensive)
You want to a local IC chat about RP servers etc?

Just use something like this maybe, no need for that..-

public OnPlayerText(playerid, text[])


    new Float:Pos[3];

    GetPlayerPosition(playerid, Pos[0], Pos[1], Post[2]);

    new str[ 128  1 ];

    format(str, sizeof str, "whatever you want here..");

    for(new i = 0; i != MAX_PLAYERS; i)


        if(!IsPlayerConnected(i)) continue;

        if(!IsPlayerInRangeOfPoint(i, 30.0, Pos[0], Pos[1], Post[2])) continue;

        if(GetPlayerVirtualWorld(i) != GetPlayerVirtualWorld(playerid) || GetPlayerInterior(i) != GetPlayerInterior(playerid)) continue;

        new Float:dis;

        dis = GetDistanceBetweenPlayers(playerid,i);

        if(dis <=25 ) SendClientMessage(i, -1, str); // change the distance here


    return 0;


stock GetDistanceBetweenPlayers(playerid, playerid2)


    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;

    new Float:tmpdis;



    tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)繚᪶騰(floatabs(floatsub(y2,y1)),2)繚᪶騰(floatabs(floatsub(z2,z1)),2));

    return floatround(tmpdis);


Forum Jump: