[HELP] Vehicle Components. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Vehicle Components. (
/showthread.php?tid=525727)
[HELP] Vehicle Components. -
Roei1998 - 13.07.2014
Well, I have a question.
I created a dialog which add to the vehicle nitro & hydraulics.
The nitro saved, but the hydraulics didn't save.
Here is the part of the code:
ENUMS:
Код:
enum veh
{
carmodel,
Float:fx,
Float:fy,
Float:fz,
Float:fa,
color1,
color2,
respawn,
carteam,
cartype, // 0 = driveable by all // 1 family restricted // 2 job restricted // 3 rentable
modeltype, //0 car // 1 heli // 2 plane // 3 boat
jobname[20],
biznumber,
plate[10],
tmplocked,
tmplockedby,
carowner[MAX_STRING],
carprice,
reset,
Components[CAR_COMPONENTS],
dupekey[MAX_STRING],
vw,
paintjob,
nitro,
hydros,
}
new Vehicles[][veh] = {
DIALOG:
Код:
new vid = GetPlayerVehicleID(playerid);
if(dialogid == 158 && response == 1)
{
switch(listitem)
{
case 0:
{
dini_Set(CarFile(GetPlayerVehicleID(playerid)), "nitro", "1");
AddVehicleComponent(vid, 1010);
SendClientInfo(playerid, "Nitro added to your vehicle!");
GivePlayerMoneyEx(playerid,-300);
return 1;
}
case 1:
{
dini_Set(CarFile(GetPlayerVehicleID(playerid)), "hydros", "1");
AddVehicleComponent(vid, 1087);
SendClientInfo(playerid, "Hydros added to your vehicle!");
GivePlayerMoneyEx(playerid,-350);
return 1;
}
}
}
The part that should create the files:
Код:
dini_IntSet(CarFile(i), "nitro", Vehicles[i][nitro]);
dini_IntSet(CarFile(i), "hydros", Vehicles[i][hydros]);
A part of the stock:
Код:
Vehicles[i][nitro] = dini_Int(CarFile(i), "nitro");
Vehicles[i][hydros] = dini_Int(CarFile(i), "hydros");
OnVehicleSpawn:
Код:
if(Vehicles[vehicleid][nitro] > 0)
{
AddVehicleComponent(vid, 1010); // Nitro
return 1;
}
if(Vehicles[vehicleid][hydros] > 0)
{
AddVehicleComponent(vid, 1087); // Hydros
return 1;
}
Re: [HELP] Vehicle Components. -
greentarch - 13.07.2014
You returned (ending) the callback after loading nitro, that's why hydraulic didn't add.
(OnVehicleSpawn)
pawn Код:
if(Vehicles[vehicleid][nitro] > 0)
{
AddVehicleComponent(vid, 1010); // Nitro
}
if(Vehicles[vehicleid][hydros] > 0)
{
AddVehicleComponent(vid, 1087); // Hydros
}
Re: [HELP] Vehicle Components. -
Roei1998 - 13.07.2014
Hmm it didn't work. something else?