[Pomoc] Problem sa AddVehicleComponent

cofilinko Započeo cofilinko
pre 10 meseci
506
pregleda
4
postova
Ova tema je zaključana. Samo moderatori i administratori mogu odgovarati.
cofilinko
Enforcer
pre 10 meseci
Naslov problema*: Problem sa AddVehicleComponent
Opis problema*:
Kreirao sam vozila za LSPD i sad hocu da samo na vozilima modela 'Sultan' dodam odredjene komponente.
Kada koristim ovu vrstu koda
for(new i = 0; i < PoliceDPVehicle; i++)
petlja racuna vozila od nultog do 115-og.
Kada koristim ovu vrstu koda
for(new i = 0; i < sizeof(PoliceDPVehicle); i++)
petlja racuna vozila od nultog do 35-og.
Koriscenjem druge vrste koda se ni na jedno vozilo ne postavljaju nikakve komponente. Ne samo na vozila policije vec ni na jedno drugo vozilo.
Deo programskog koda*:

new PoliceDPVehicle;
CreateOrganisationVehicles(){
    PoliceDPVehicle = CreateVehicle(601, 1526.5243, -1646.2144, 5.6043, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(601, 1530.3875, -1646.1552, 5.6043, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(596, 1543.9326, -1659.0615, 5.5583, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(528, 1534.7406, -1645.9003, 5.9009, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(523, 1557.2734, -1694.6870, 5.3815, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(427, 1544.4691, -1651.0994, 5.9214, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(415, 1600.7389, -1704.0658, 5.6020, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(528, 1538.7095, -1645.8534, 5.9009, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(427, 1544.5243, -1655.1660, 5.9214, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(596, 1543.9204, -1663.1046, 5.5583, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(596, 1543.8357, -1667.8883, 5.5583, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(596, 1544.0886, -1672.0415, 5.5583, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(596, 1544.2990, -1676.2935, 5.5583, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(596, 1544.3818, -1680.3168, 5.5583, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(596, 1544.4489, -1684.4370, 5.5583, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(523, 1559.7129, -1694.6288, 5.3815, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(523, 1562.4556, -1694.6185, 5.3815, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(523, 1565.3148, -1694.5435, 5.3815, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(523, 1568.2756, -1694.5117, 5.3815, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(523, 1571.5009, -1694.5961, 5.3815, 180.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1564.6665, -1710.2943, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1570.2416, -1710.3699, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1574.5234, -1710.2474, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1578.5840, -1710.1772, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1583.3661, -1710.1727, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1587.6217, -1710.1632, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1591.5215, -1710.1095, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1595.3837, -1710.1494, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(560, 1558.9292, -1710.6021, 5.4999, 0.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(415, 1600.7902, -1700.1128, 5.6020, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(415, 1600.7874, -1696.1064, 5.6020, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(415, 1600.7799, -1692.0020, 5.6020, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(415, 1600.8523, -1687.9385, 5.6020, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(415, 1601.0525, -1684.0155, 5.6020, 90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(599, 1585.4449, -1671.7253, 6.0398, -90.0000, 162, 162, -1);
PoliceDPVehicle = CreateVehicle(599, 1585.3784, -1667.3473, 6.0398, -90.0000, 162, 162, -1);
}
CreateVehicleTunning(){
for(new i = 0; i < PoliceDPVehicle; i++){
printf("PD:%d", i);
    if (GetVehicleModel(i) == 560){
AddVehicleComponent(i, 1033); // Roof Vent
AddVehicleComponent(i, 1029); // Exhaust
AddVehicleComponent(i, 1169); // Front Bumper
AddVehicleComponent(i, 1141); // Rear Bumper
AddVehicleComponent(i, 1026); // Right Side Skirt
AddVehicleComponent(i, 1027); // Left Side Skrit
AddVehicleComponent(i, 1138); // Spoiler
AddVehicleComponent(i, 1010); // Nitro
    AddVehicleComponent(i, 1079); // Wheels
}
}
}

Debug informacije:
Prva linija koda: https://imgur.com/a/pvtcCTP
Druga linija koda: https://imgur.com/a/XNGx3VT

Funckije CreateVehicleTunning() i CreateOrganisationVehicles() se nalaze u OnGameModeInit.
Mladjo558
Shot Caller
pre 10 meseci
zasto si stavio:
for(new i = 0; i < PoliceDPVehicle; i++)

u ovom kodu petlja ide od 0 ukljucujuci i 0, sve do broja id-a tog vozila na 35 indeksu, ovo je pogresno.

Ispravljeni kod:
CreateVehicleTunning()
{
for(new i = 0; i < sizeof(PoliceDPVehicle); i++)
{
    printf("PD: %d", i);
    if(GetVehicleModel(PoliceDPVehicle) == 560)
    {
AddVehicleComponent(PoliceDPVehicle, 1033); // Roof Vent
AddVehicleComponent(PoliceDPVehicle, 1029); // Exhaust
AddVehicleComponent(PoliceDPVehicle, 1169); // Front Bumper
AddVehicleComponent(PoliceDPVehicle, 1141); // Rear Bumper
AddVehicleComponent(PoliceDPVehicle, 1026); // Right Side Skirt
AddVehicleComponent(PoliceDPVehicle, 1027); // Left Side Skrit
AddVehicleComponent(PoliceDPVehicle, 1138); // Spoiler
AddVehicleComponent(PoliceDPVehicle, 1010); // Nitro
            AddVehicleComponent(PoliceDPVehicle, 1079); // Wheels
}
}
return true;
}

ovde petlja ide od 0 pa sve do broja tih vozila
zatim trazi ID vozila na tom indeksu (indeks = i), i stavlja komponente

glavne greske su petlja i pogresan id vozila (stavio si i umesto PoliceDPVehicle), bas zato se ni ne postavljaju komponente na vozila jer je pogresan id vozila / nepostojeci.
cofilinko
Enforcer
pre 10 meseci
Samo da potvrdim.
Sad ni jednog drugo vozilo, u ovom slucaju sultan, nece imati postavljene ove komponente jer se ovde uzima niz iz PoliceDPVehicle i na postavlja se samo na ta vozila?
Inace hvala puno, testirao sam i radi savrseno.
Mladjo558
Shot Caller
pre 10 meseci
cofilinko wrote on March 5, 2025, 8:39 pm:
Samo da potvrdim.
Sad ni jednog drugo vozilo, u ovom slucaju sultan, nece imati postavljene ove komponente jer se ovde uzima niz iz PoliceDPVehicle i na postavlja se samo na ta vozila?
Inace hvala puno, testirao sam i radi savrseno.

nista, tu sam uvek da pomognem! Da, kao sto si rekao, komponente ce se prikazivati samo na policijskim vozilima, nece na svim sultanima na serveru.

Morate biti prijavljeni da biste odgovorili na ovu temu.

Prijava