Array Dynamic
#1

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
Reply
#2

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

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.
Reply
#4

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
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)