new CGLSVehicles[23];
CGLSVehicles[1] = AddStaticVehicleEx(472,-2954.7998047,491.1992188,0.0000000,63.9953613,6,-1,15); //Coastguard
CGLSVehicles[2] = AddStaticVehicleEx(472,-2954.8000488,495.2999878,0.0000000,64.0000000,6,53,15); //Coastguard
CGLSVehicles[3] = AddStaticVehicleEx(472,-2941.3000488,491.6000061,0.0000000,310.0000000,6,53,15); //Coastguard
CGLSVehicles[4] = AddStaticVehicleEx(472,-2955.0000000,499.2999878,0.0000000,63.9953613,6,53,15); //Coastguard
CGLSVehicles[5] = AddStaticVehicleEx(472,-2955.3000488,503.5000000,0.0000000,63.9953613,6,-1,15); //Coastguard
CGLSVehicles[6] = AddStaticVehicleEx(472,-2941.2998047,495.8994141,0.0000000,309.9957275,6,-1,15); //Coastguard
CGLSVehicles[7] = AddStaticVehicleEx(472,-2940.6992188,501.2998047,0.0000000,309.9957275,6,-1,15); //Coastguard
CGLSVehicles[8] = AddStaticVehicleEx(472,-2941.0996094,505.5996094,0.0000000,309.9957275,6,-1,15); //Coastguard
CGLSVehicles[9] = AddStaticVehicleEx(430,-2981.3999023,491.2999878,0.0000000,2.0000000,-1,103,15); //Predator
CGLSVehicles[10] = AddStaticVehicleEx(430,-2971.1000977,491.5000000,0.0000000,357.9978027,-1,103,15); //Predator
CGLSVehicles[11] = AddStaticVehicleEx(430,-2980.6999512,508.0000000,0.0000000,359.9978027,-1,103,15); //Predator
CGLSVehicles[12] = AddStaticVehicleEx(430,-2970.8999023,507.5000000,0.0000000,357.9949951,-1,103,15); //Predator
CGLSVehicles[13] = AddStaticVehicleEx(490,-2949.3999023,458.7999878,5.1999998,334.0000000,6,-1,15); //FBI Rancher
CGLSVehicles[14] = AddStaticVehicleEx(490,-2954.1999512,458.7999878,5.1999998,333.9953613,6,-1,15); //FBI Rancher
CGLSVehicles[15] = AddStaticVehicleEx(490,-2958.5000000,459.5000000,5.1999998,333.9953613,6,-1,15); //FBI Rancher
CGLSVehicles[16] = AddStaticVehicleEx(490,-2944.5996094,459.0000000,5.1999998,333.9953613,6,-1,15); //FBI Rancher
CGLSVehicles[17] = AddStaticVehicleEx(597,-2971.3994141,458.6992188,4.6999998,337.9998779,7,1,15); //Police Car (SFPD)
CGLSVehicles[18] = AddStaticVehicleEx(597,-2978.6999512,458.6000061,4.6999998,337.9998779,7,1,15); //Police Car (SFPD)
CGLSVehicles[19] = AddStaticVehicleEx(597,-2975.3000488,458.6000061,4.6999998,337.9998779,7,1,15); //Police Car (SFPD)
CGLSVehicles[20] = AddStaticVehicleEx(597,-2982.1999512,458.3999939,4.6999998,337.9998779,7,1,15); //Police Car (SFPD)
CGLSVehicles[21] = AddStaticVehicleEx(497,-2969.3000488,479.6000061,5.0000000,0.0000000,7,1,15); //Police Maverick
CGLSVehicles[22] = AddStaticVehicleEx(487,-2954.1999512,479.5000000,5.0000000,0.0000000,6,-1,15); //Maverick
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetPlayerVehicleID(playerid) == CGLSVehicles[]) // LINE 656
{
}
return 1;
}
(656) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
for(new counter = 0; counter < sizeof(CGLSVehicles); counter++)
{
if(GetPlayerVehicleID(playerid) == CGLSVehicles[counter])
{
// code
}
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i; i < sizeof(CGLSVehicles); i++)
{
if(GetPlayerVehicleID(playerid) == CGLSVehicles[i]) // LINE 656
{
//Do stuff, they're in one of your vehicle!
break; //Stop the loop, we don't need it anymore.
}
}
return 1;
}
pawn Код:
|
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
vid = GetPlayerVehicleID(playerid);
for(new i; i < sizeof(CGLSVehicles); i++)
{
if(vid == CGLSVehicles[i]) // LINE 656
{
//Do stuff, they're in one of your vehicle!
break; //Stop the loop, we don't need it anymore.
}
}
return 1;
}
Well that will work but you don't want to keep calling the same function every iteration it should actually look like this.
pawn Код:
|
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i; i < sizeof(CGLSVehicles); i++)
{
if(vehicleid == CGLSVehicles[i]) // LINE 656
{
//Do stuff, they're in one of your vehicle!
break; //Stop the loop, we don't need it anymore.
}
}
return 1;
}
And, there is no difference as this function will be called along side again and again either if it's out the loop.
|
new CGLSVehicles[23]; // is from 0 to 22
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(CGLSVehicles[0] <= vehicleid <= CGLSVehicles[22])
{
// do something
}
return 1;
}