sizeof
#1

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 
1sizeof(fracCarMenti)+1i++) // cars LSPD
    
{
        
fracCars[0][i] = CreateVehicle(596fracCarMenti[i][0], fracCarMenti[i][1], fracCarMenti[i][2],   fracCarMenti[i][3], 016001);
    }
    return 
1;

I want to know size of fracCars[0] here is:
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
modelid >= fracCars[0][0] && modelid <= sizeof(fracCars[0])) // LSPD cars
    
{
        
//code..
    
}
    return 
1;

How I can do this?
Reply
#2

upup
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)