shorter code...
#1

Hi, can somebody explain to me how i can make a shorter code to add Nos to all vehicles? this is what i have..

pawn Код:
lilgunna = AddStaticVehicleEx(560, 288.13833618164, 2472.4133300781, 16.281105041504, 0.000000, -1, -1, 60); //32
    lilgunna = AddStaticVehicleEx(560, 284.63854980469, 2472.4951171875, 16.281105041504, 0.000000, -1, -1, 60); //33
    lilgunna = AddStaticVehicleEx(560, 280.38958740234, 2472.5947265625, 16.281105041504, 0.000000, -1, -1, 60); //34
    lilgunna = AddStaticVehicleEx(560, 276.63958740234, 2472.6826171875, 16.281105041504, 0.000000, -1, -1, 60); //35
Thats the vehicleid, now here is cb.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if (vehicleid == lilgunna)
  {
    AddVehicleComponent(lilgunna, 1010); // Nitro
  }

    return 1;
}


My issue is, its only adding the nos to the last vehicle on that list. So how can i do it without re-making 500 "if(vehicleid"'s?
Reply
#2

use arrays/a loop .
Reply
#3

im new.. lol.. so like you just saying use arrays/loop pwns my knowledge.


Do you mean like..

pawn Код:
new 1;
new 2;
new 3;
new 4;
new 5;
Do tht?
Reply
#4

pawn Код:
new
    lilgunna[4];
pawn Код:
lilgunna[0] = AddStaticVehicleEx(560, 288.13833618164, 2472.4133300781, 16.281105041504, 0.000000, -1, -1, 60); //32
lilgunna[1] = AddStaticVehicleEx(560, 284.63854980469, 2472.4951171875, 16.281105041504, 0.000000, -1, -1, 60); //33
lilgunna[2] = AddStaticVehicleEx(560, 280.38958740234, 2472.5947265625, 16.281105041504, 0.000000, -1, -1, 60); //34
lilgunna[3] = AddStaticVehicleEx(560, 276.63958740234, 2472.6826171875, 16.281105041504, 0.000000, -1, -1, 60); //35
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new
      i;
  for(i = 0; i < sizeof(lilgunna); i++)
  {
    if(vehicleid == lilgunna[i]) AddVehicleComponent(lilgunna[i], 1010); // Nitro
  }
  return 1;
}
You could use ******'s foreach, it's faster than normal for.
Reply
#5

thx don
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)