Tag mismatch
#1

I made this command for re-spawning my group vehicles and i get 2 warnings on this 2 lines

The enum

Код:
enum Bcars 
{
	Car1,
	Car2,
	Car3,
	Car4,
	Car5,
	Car6,
	Car7 
}
new Bcar[Bcars];
Command
Код:
CMD:breset2(playerid, params[])
{
	if(PlayerInfo[playerid][pBikers] >= 2)
 	{
        for(new i; i < MAX_VEHICLES; i++)
        {
            if(!VehicleOccupied(Bcar[i]))
			{
   				SetVehicleToRespawn(Bcar[i]);
			}
		}
        	SendClientMessage(playerid, COLOR_GREEN, "Unoccupied vehicles of The Bikers have been respawned.");
        }
        else
        {
        	SendClientMessage(playerid, COLOR_RED, "Are you sure you typed the correct command?");
        }
		return 1;
}
and i get warning 213: tag mismatch on this lines

Код:
 if(!VehicleOccupied(Bcar[i]))
Код:
SetVehicleToRespawn(Bcar[i]);
if any one can help me fix this warnings it would be greate thanks.
Reply
#2

I don't understand why you need the enum. Just use a normal array. Besides that you are seriously going out of bounds by using MAX_VEHICLES, because you array has only 7 slots but MAX_VEHICLES is defined as 2000.
Reply
#3

This is all enough:
PHP код:
new car1car2car3bool:bCars[MAX_VEHICLES];
public 
OnGameModeInit()
{
     
car1=AddStasticVehicle(.....
     
bCars[car1]=true;
     
car2=AddStasticVehicle(.....
     
bCars[car2]=true;
     ......
     return 
1;
}
CMD:breset2(playeridparams[])
{
    if(
PlayerInfo[playerid][pBikers] >= 2)
     {
        for(new 
iMAX_VEHICLESi++)
        {
            if(!
VehicleOccupied(i) && bCars[i])
            {
                   
SetVehicleToRespawn(i);
            }
        }
            
SendClientMessage(playeridCOLOR_GREEN"Unoccupied vehicles of The Bikers have been respawned.");
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"Are you sure you typed the correct command?");
        }
        return 
1;

Reply
#4

I want it for my group vehicles only
Reply
#5

I updated the code above. Try it.
Reply
#6

Works like a charm thanks bro!
Reply
#7

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
This is all enough:
Oh please, this is all completely redundant. At the very least there is no more out of bounds error, but at the expense of 285 times the memory usage and processing overhead. Well done! (yes, that is sarcastic).

PHP код:

new Bcar[7]; // 7 cars, oh my god!
public OnGameModeInit()
{
    
Bcar[0] = AddStaticVehicle(...);
    
Bcar[1] = AddStaticVehicle(...);
    ...
    
Bcar[6] = AddStaticVehicle(...);
}
        for(new 
isizeof(Bcars); i++)
        {
            if(!
VehicleOccupied(i) && bCars[i])
            {
                   
SetVehicleToRespawn(i);
            }
        } 
Reply
#8

Your code won't work, Vince.
Things inside the for loop is wrong.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)