sizeof - 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: sizeof (
/showthread.php?tid=609058)
sizeof -
Welaurs - 08.06.2016
Hi all. I have
PHP код:
#define MAX_FRAC 5
#define MAX_VEHICLES_FRAC 30
new fracCars[MAX_FRAC][MAX_VEHICLES_FRAC];
and
PHP код:
public OnGameModeInit()
{
for(new i = 1; i < sizeof(fracCarMenti)+1; i++) // cars LSPD
{
fracCars[0][i] = CreateVehicle(596, fracCarMenti[i][0], fracCarMenti[i][1], fracCarMenti[i][2], fracCarMenti[i][3], 0, 1, 600, 1);
}
return 1;
}
I want to know size of fracCars[0] here is:
PHP код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(modelid >= fracCars[0][0] && modelid <= sizeof(fracCars[0])) // LSPD cars
{
//code..
}
return 1;
}
How I can do this?
Re: sizeof -
Welaurs - 08.06.2016
upup
Re: sizeof -
Unte99 - 08.06.2016
Create a variable, then make a loop through all police cars and check if fracCars[0][i]!=0. If fracCars[0][i] is equal to 0, that means a that bit is holding an id for a police car. Then just add one value to the variable that you created at first. When the loop finishes, you will have the total number of existing police cars.