new arrVehInfo[][][] =
{
{411, 56000, "Infernus"},
{541, 12000, "Bullet"}
};
public OnPlayerStateChange(playerid, newstate, oldstate)
{
// Was he onfoot and THEN he entered the driver and if yes, then only show him the info!
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new iVeh = GetPlayerVehicleID(playerid); // Get his vehicle ID not vehicle MODEL.
new iVehModel = GetVehicleModel(iVeh); // Can call implicitly the above 2 functions, but multiple calls, no - no or just for simplicity's sake
for(new index = 0; index < sizeof(arrVehInfo); index++ )
{
if(arrVehInfo[index][0] == iVehModel)
// Yes - he's in that row's model
{
new szString[80];
format(szString, sizeof szString, "VEHICLE: You can sell this %s at a nearby carshop for $%d.", arrVehInfo[index][2], arrVehInfo[index][1] ) ;
// remember - the 0th pos was the model, 1st pos - the price and the 2nd pos - the string.
SendClientMessage(playerid, -1, szString);
break ; // You got the vehicle, why loop anymore?
}
}
return 1;
}
(16268) : error 033: array must be indexed (variable "arrVehInfo")
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
if(arrVehInfo[index][0]
new arrVehInfo[][][] = { {411, 56000, "Infernus"}, {541, 12000, "Bullet"} }; |
if(arrVehInfo[index][0][0] == iVehModel)
public OnPlayerStateChange(playerid, newstate, oldstate)
{
// Was he onfoot and THEN he entered the driver and if yes, then only show him the info!
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new iVeh = GetPlayerVehicleID(playerid); // Get his vehicle ID not vehicle MODEL.
new iVehModel = GetVehicleModel(iVeh); // Can call implicitly the above 2 functions, but multiple calls, no - no or just for simplicity's sake
for(new index = 0; index < sizeof(arrVehInfo); index++ )
{
if(arrVehInfo[index][0][0] == iVehModel)
// Yes - he's in that row's model
{
new szString[80];
format(szString, sizeof szString, "VEHICLE: You can sell this %s at a nearby carshop for $%d.", arrVehInfo[index][2], arrVehInfo[index][1] ) ;
// remember - the 0th pos was the model, 1st pos - the price and the 2nd pos - the string.
SendClientMessage(playerid, -1, szString);
break ; // You got the vehicle, why loop anymore?
}
}
return 1;
}
you may try this:
PHP код:
PHP код:
|