13.04.2012, 15:44
Is it possible to make this snippet of code a lot smaller by using something like an array? (condense down the army1, army2, army3 ect into something like army(1 to 6)
Im new to pawn code but I can code VB very well.
Possible to use something like this?:
Thanks in advance.
Im new to pawn code but I can code VB very well.
Possible to use something like this?:
Код:
For i = 1 to 6
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
new CarCheck = GetPlayerVehicleID(playerid);
if(CarCheck == Cars[GroveStreet] )
{
if(gTeam[playerid] != 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
return 1;
}
}
if(CarCheck == Cars[fbi] )
{
if(gTeam[playerid] != 4)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Your not part of the FBI!");
return 1;
}
}
if(CarCheck == Cars[army] )
{
if(gTeam[playerid] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Your not part of the army!");
return 1;
}
}
if(CarCheck == Cars[army1] )
{
if(gTeam[playerid] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Your not part of the army!");
return 1;
}
}
if(CarCheck == Cars[army2] )
{
if(gTeam[playerid] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Your not part of the army!");
return 1;
}
}
if(CarCheck == Cars[army3] )
{
if(gTeam[playerid] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Your not part of the army!");
return 1;
}
}
if(CarCheck == Cars[army4] )
{
if(gTeam[playerid] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Your not part of the army!");
return 1;
}
}
if(CarCheck == Cars[army5] )
{
if(gTeam[playerid] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Your not part of the army!");
return 1;
}
}
if(CarCheck == Cars[army6] )
{
if(gTeam[playerid] != 3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Your not part of the army!");
return 1;
}
}
if(CarCheck == Cars[Police] )
{
if(gTeam[playerid] != 2)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You are not part of the Police force! Run before they catch you!");
return 1;
}
}
return 1;
}
return 1;
}

