new DisabledCars[] = {407, 416, 425, 427, 432, 441, 447, 449, 464, 465, 476, 479, 501, 520, 537, 538, 552, 564, 569, 570, 577, 590, 591, 592, 594, 601, 606, 608, 610};
LoadDefaultDisabledVehicles()
{
for(new i = 400; i < MAX_SPAWNABLE_VEHICLES+400; i++)
{
CarInfo[i-400][allow] = true;
}
for (new x = 0; x < sizeof(DisabledCars); x++) // This bit is where I am stuck - It is obviously wrong and I tested it.
{
CarInfo[x][allow] = false;
}
printf("Disabled Vehicles Loaded!");
}
CarInfo[DisabledCarID_GOES_HERE][allow] = true;
CarInfo[DisabledCarID_GOES_HERE][allow] = false;
CarInfo[407][allow] = false;
CarInfo[416][allow] = false;
CarInfo[425][allow] = false;
CarInfo[427][allow] = false;
CarInfo[432][allow] = false;
/// etc etc (from my DisabledCars[] list).
DisabledCars[x]
CarInfo[DisabledCars[x]][allow] = false;
|
Originally Posted by 0rb
pawn Код:
pawn Код:
But there are other (better) ways of doing it, without the need of a loop. |
|
Originally Posted by 0rb
pawn Код:
pawn Код:
But there are other (better) ways of doing it, without the need of a loop. |
LoadDefaultDisabledVehicles()
{
for(new i = 400; i < MAX_SPAWNABLE_VEHICLES+400; i++)
{
CarInfo[i-400][allow] = true;
}
for(new i = 400; i < MAX_SPAWNABLE_VEHICLES+400; i++)
{
CarInfo[DisabledCars[i-400]][allow] = false;
}
printf("Disabled Vehicles Loaded!");
}
EDIT: Just tested it, and the server/player crashes - the class selection is messed up and no response from the server.
|
Originally Posted by [B2K
Hustler ]
EDIT: Just tested it, and the server/player crashes - the class selection is messed up and no response from the server. |
Other better solutions are welcome. Please help. Thanks.
for(new x = 0; x < MAX_VEHICLES; x++)
{
switch(x)
{
case 407: // Set the vehicle disabled
case 416: // Set the vehicle disabled
case 425: // Set the vehicle disabled
}
}
stock IsDisabledVehicleModel( model )
{
switch ( model )
{
case 407, 416, 425, 427, 432, 441, 447, 449, 464, 465, 476, 479, 501, 520, 537, 538, 552, 564, 569, 570, 577, 590, 591, 592, 594, 601, 606, 608, 610 : return true;
}
return false;
}
//some command
if ( !IsDisabledVehicleModel( strval( params ) ) ) CreateVehicle( strval( params ), ................ );
), was that I want to un-disable re-disable vehicles in-game. So right now disabled vehicles have this variable:CarInfo[idx-400][allow] = false;
CarInfo[idx-400][allow] = true;
//global
new
gDisabledVehicle[ 211 ] = { true, ... }; //all are enabled and 211 is the total model count - 400 to 611
//create a vehicle
if ( ( model - 400 ) > -1 && ( model - 400 ) < 212 )
{
if ( !gDisabledVehicle[ ( model - 400 ) ] ) CreateVehicle( model, coords etc........ );
}
//enable a vehicle
gDisabledVehicle[ ( model - 400 ) ] = true;
//disable a vehicle
gDisabledVehicle[ ( model - 400 ) ] = false;
CreateEnabledVehicle( model, ...... )
{
if ( ( model - 400 ) > -1 && ( model - 400 ) < 212 ) //OOB protection so we don't go outside the array bounds and crash the script
{
if ( !gDisabledVehicle[ ( model - 400 ) ] )
{
CreateVehicle( model, coords etc........ ); //it wasn't disabled so create it
return true; //return a success
}
}
return false; //return a failure, the vehicle was disabled or the index was invalid after subtracting 400 from it (we passed say 717 so the index was 317)
}