Array List assign to Variable
#9

Right I'm with you now.

Well this is simple enough just do something like so:

pawn Код:
//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;
So if 'model' is 541 (Bullet model) then it will check the array at index 141 to see if it is flagged true or false then react accordingly, model is the param from your command or whatever.

You could use the creation as a custom function with a return:

pawn Код:
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)
}
I haven't checked this dude, just writing it out from my head so it could have typos or little bugs which I'm not aware of but in theory it will work no problems I think (hope hehe) and now we don't require loops or whatever unless we want to do a global set for the 'gDisabledVehicle' array.
Reply


Messages In This Thread
Array List assign to Variable - by member - 07.10.2009, 17:37
Re: Array List assign to Variable - by yom - 07.10.2009, 17:44
Re: Array List assign to Variable - by MenaceX^ - 07.10.2009, 17:48
Re: Array List assign to Variable - by member - 07.10.2009, 17:52
Re: Array List assign to Variable - by member - 09.10.2009, 16:43
Re: Array List assign to Variable - by SpiderPork - 09.10.2009, 16:47
Re: Array List assign to Variable - by Donny_k - 09.10.2009, 16:55
Re: Array List assign to Variable - by member - 09.10.2009, 17:52
Re: Array List assign to Variable - by Donny_k - 10.10.2009, 00:15

Forum Jump:


Users browsing this thread: 2 Guest(s)