SA-MP Forums Archive
Tag mismatch - 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: Tag mismatch (/showthread.php?tid=592257)



Tag mismatch - rambalili2 - 22.10.2015

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.


Re: Tag mismatch - Vince - 22.10.2015

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.


Re: Tag mismatch - ATGOggy - 22.10.2015

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;




Re: Tag mismatch - rambalili2 - 22.10.2015

I want it for my group vehicles only


Re: Tag mismatch - ATGOggy - 22.10.2015

I updated the code above. Try it.


Re: Tag mismatch - rambalili2 - 22.10.2015

Works like a charm thanks bro!


Re: Tag mismatch - Vince - 22.10.2015

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);
            }
        } 



Re: Tag mismatch - ATGOggy - 22.10.2015

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