need some help!
#1

Is there any way to remove alot of this code to be alot simpilar I hate typing car after car after car .... I want to be able to add the price and the vehicle id and cordinates and everything else creates the 3dtextlabel and Etc...

Like im fine with adding the dealercars[randomnumber] = addstaticvehicle(43925--0295 -324);
and the price CarPrice[DealerCars[0]] = 85000; everything else i like to have a stock to add the price and string and 3dtextlabel


pawn Код:
public LoadVehicles()
{
    new string[32], string2[32], string3[32], string4[32], string5[32], string6[32], string7[32], string8[32], string9[32];
    DealerCars[0] = AddStaticVehicle(541,538.4867,-1282.8323,17.2422,185.1891,-1,-1);// Bullet
    DealerCars[1] = AddStaticVehicle(402,537.8731,-1273.0552,17.8527,308.4883,-1,-1);// Buffalo
    DealerCars[2] = AddStaticVehicle(444,547.4461,-1267.4044,16.9855,12.8657,-1,-1);// Monster
    DealerCars[3] = AddStaticVehicle(439,550.8978,-1264.9133,16.9855,11.1392,-1,-1);// Stallion
    DealerCars[4] = AddStaticVehicle(565,548.6735,-1287.4486,16.9918,357.9976,-1,-1);// Flash
    DealerCars[5] = AddStaticVehicle(451,544.8066,-1284.0590,16.9887,178.2442,-1,-1);// Turismo
    DealerCars[6] = AddStaticVehicle(400,561.1696,-1287.6387,16.9916,358.8935,-1,-1);// LandStalker
    DealerCars[7] = AddStaticVehicle(554,564.5045,-1287.7549,16.9918,359.0627,-1,-1);// Yosemite
    DealerCars[8] = AddStaticVehicle(411,552.0139,-1287.6346,16.9919,357.9609,-1,-1);// Infernus
    IsADealerCar[DealerCars[0]] = true;
    IsADealerCar[DealerCars[1]] = true;
    IsADealerCar[DealerCars[2]] = true;
    IsADealerCar[DealerCars[3]] = true;
    IsADealerCar[DealerCars[4]] = true;
    IsADealerCar[DealerCars[5]] = true;
    IsADealerCar[DealerCars[6]] = true;
    IsADealerCar[DealerCars[7]] = true;
    IsADealerCar[DealerCars[8]] = true;
    CarPrice[DealerCars[0]] = 85000;
    CarPrice[DealerCars[1]] = 85000;
    CarPrice[DealerCars[2]] = 40000;
    CarPrice[DealerCars[3]] = 12500;
    CarPrice[DealerCars[4]] = 15000;
    CarPrice[DealerCars[5]] = 95000;
    CarPrice[DealerCars[6]] = 15000;
    CarPrice[DealerCars[7]] = 25000;
    CarPrice[DealerCars[8]] = 90000;
    format(string, sizeof(string), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[0]), CarPrice[DealerCars[0]]);
    format(string2, sizeof(string2), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[1]), CarPrice[DealerCars[1]]);
    format(string3, sizeof(string3), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[2]), CarPrice[DealerCars[2]]);
    format(string4, sizeof(string4), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[3]), CarPrice[DealerCars[3]]);
    format(string5, sizeof(string5), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[4]), CarPrice[DealerCars[4]]);
    format(string6, sizeof(string6), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[5]), CarPrice[DealerCars[5]]);
    format(string7, sizeof(string7), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[6]), CarPrice[DealerCars[6]]);
    format(string8, sizeof(string8), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[7]), CarPrice[DealerCars[7]]);
    format(string9, sizeof(string9), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[8]), CarPrice[DealerCars[8]]);
    DealerCar[0] = Create3DTextLabel(string, 0x33CCFFAA, 538.4867,-1282.8323,17.2422, 20.0, 0);
    DealerCar[1] = Create3DTextLabel(string2, 0x33CCFFAA, 537.8731,-1273.0552,17.8527, 20.0, 0);
    DealerCar[2] = Create3DTextLabel(string3, 0x33CCFFAA, 547.4461,-1267.4044,16.9855, 20.0, 0);
    DealerCar[3] = Create3DTextLabel(string4, 0x33CCFFAA, 550.8978,-1264.9133,16.9855, 20.0, 0);
    DealerCar[4] = Create3DTextLabel(string5, 0x33CCFFAA, 548.6735,-1287.4486,16.9918, 20.0, 0);
    DealerCar[5] = Create3DTextLabel(string6, 0x33CCFFAA, 544.8066,-1284.0590,16.9887, 20.0, 0);
    DealerCar[6] = Create3DTextLabel(string7, 0x33CCFFAA, 561.1696,-1287.6387,16.9916, 20.0, 0);
    DealerCar[7] = Create3DTextLabel(string8, 0x33CCFFAA, 564.5045,-1287.7549,16.9918, 20.0, 0);
    DealerCar[8] = Create3DTextLabel(string9, 0x33CCFFAA, 552.0139,-1287.6346,16.9919, 20.0, 0);
    return 1;
}
Reply
#2

Heya,

pawn Код:
public LoadVehicles()
{
    //Details of the cars go here now:
    CreateDealerCar(VehicleID, Float:X, Float:Y, Float:Z, Float:A, Price, Color1 = 5, Color2 = 152);
    CreateDealerCar(VehicleID, Float:X, Float:Y, Float:Z, Float:A, Price);  //If you colors are both -1, you don't have to enter them
    return 1;
}
pawn Код:
stock CreateDealerCar(VehicleID, Float:X, Float:Y, Float:Z, Float:A, Price, Color1 = -1, Color2 = -1)
{
    static id;
    DealerCars[id] = AddStaticVehicle(VehicleID,X,Y,Z,A,Color1,Color2);
    IsADealerCar[DealerCars[id]] = true;
    CarPrice[DealerCars[id]] = Price;
    new string[50];
    format(string, sizeof(string), "Name: %s\nPrice: $%i", GetVehicleNameFromID(DealerCars[id]), CarPrice[DealerCars[id]]);
    DealerCar[id] = Create3DTextLabel(string, 0x33CCFFAA, X,Y,Z, 20.0, 0);
    id++;
    return 1;
}
I didn't use the 'static' so often yet, so if this causes any problems let me know please, then I'll give you a fix.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)