SA-MP Forums Archive
Array Dynamic - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Array Dynamic (/showthread.php?tid=455754)



Array Dynamic - Kyra - 03.08.2013

Hi i want to create a script with an array dynamic for optimise my script.

On my old script i use 1 loop on a loop for calculate the numbers players in team private connected

But example with 30 players, with a loop on a loop 30 x 30 (900), it's the reason why i want know if it's possible to create an array dynamic example.

PHP код:
new MAXNUMBERTEAMID;
    foreach(new 
Player)
    {
        if(
gLogged[i])
        {
            if(
MAXNUMBERTEAMID PlayerInfo[i][pTeamId] && PlayerInfo[i][pTeamId] > 0MAXNUMBERTEAMID PlayerInfo[i][pTeamId];
        }
    }
    new 
TestV[MAXNUMBERTEAMID+1];// but it's bad 
ps: i tested pvar (array dynamic) with my loop at 900 it's fast
https://sampforum.blast.hk/showthread.php?tid=362842


Re: Array Dynamic - Alternative112 - 03.08.2013

Impossible in PAWN, it needs to know how big arrays/strings are before compilation.


Re: Array Dynamic - Bakr - 03.08.2013

As the above poster said, it isn't natively supported in the language. However, ****** has released y_malloc (similar to that of malloc() in C) and there are a couple of plugins available to take advantage of dynamic memory allocation.


Re: Array Dynamic - Sinner - 03.08.2013

It's possible with any of the data container plugins (I think there are 2 released atm).

This supports vector, map, deque and multimap.
https://sampforum.blast.hk/showthread.php?tid=364285


Re: Array Dynamic - Edix - 03.08.2013

Foreach has more functinos then just have a loop around all the players on the server.

You could make a itter that will save the ID's of the players you need and then make a loop around them.

I cant explain a lot about foreach but this topic will be able to help you out https://sampforum.blast.hk/showthread.php?tid=92679 check the "Functions" section.