SA-MP Forums Archive
Array size - 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 size (/showthread.php?tid=453964)



Array size - RajatPawar - 27.07.2013

Suppose I have this -
pawn Код:
enum _pINFO
{
   var
}
new PlayerInfo[MAX_PLAYERS][_pINFO];


stock _function( variable )
{
    new counter;
    for(.. 'i' loop through all the players )
    {
         if( PlayerInfo[i][var] == variable ) counter ++;
         else continue;
     }
}
And now I want to do this-
pawn Код:
online_ = _function( 1 );
new array[online];
But that won't work right?
So is there a way to do this? Dynamically allocate memory? Runtime?


Re: Array size - iggy1 - 27.07.2013

You could make a plugin for dynamic memory, or use an existing one.

There may be other libs that allow something similar, y_malloc maybe - although iv never used that so don't know what is does for sure. Name suggests its for allocating memory though.

But as for dynamically assigning sizes to arrays at runtime - can't be done.