SA-MP Forums Archive
[HELP]Big problem - 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]Big problem (/showthread.php?tid=543908)



[HELP]Big problem - ExTaSy69 - 29.10.2014

Hi , I have a big problem on my SA:MP server
I have buycar system and when I buy a car it doesn't record it on cars.cfg and after I restart the server it dissapears .
What can I do , help me please ...


Re: [HELP]Big problem - Mic_H - 29.10.2014

1: https://sampforum.blast.hk/showthread.php?tid=507416
2: Give us more info.. Like, the script-part used to save data, load data etc.


Re: [HELP]Big problem - ExTaSy69 - 29.10.2014

public OnVehicleSpawn(vehicleid)
{
for(new nl = 0; nl < 4; nl++)
{
if(nl <= 2) DestroyObject(Faruri[nl]);
DestroyObject(neon[nl]);
}
Neon[vehicleid][FaruriPrendida] = 0;
Neon[vehicleid][NeonPrendido] = 0;
if(IsAnOwnableCar(vehicleid))
{
if(CarInfo[vehicleid][cPaintjob] != 999)
{
ChangeVehiclePaintjob(vehicleid, CarInfo[vehicleid][cPaintjob]);
}
SetVehicleModifications(vehicleid);
ChangeVehicleColor(vehicleid, CarInfo[vehicleid][cColorOne],CarInfo[vehicleid][cColorTwo]);
}
return 1;
}

public LoadCar()
{
new arrCoords[29][64];
new strFromFile2[256];
new File: file = fopen("cfg/cars.cfg", io_read);
if (file)
{
new idx = PersonalCarID;
while (idx < sizeof(CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
CarInfo[idx][cModel] = strval(arrCoords[0]);
CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
CarInfo[idx][cColorOne] = strval(arrCoords[5]);
CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
CarInfo[idx][cValue] = strval(arrCoords[9]);
strmid(CarInfo[idx][cLicense], arrCoords[10], 0, strlen(arrCoords[10]), 255);
CarInfo[idx][cOwned] = strval(arrCoords[11]);
CarInfo[idx][cLock] = strval(arrCoords[12]);
CarInfo[idx][cComponent0] = strval(arrCoords[13]);
CarInfo[idx][cComponent1] = strval(arrCoords[14]);
CarInfo[idx][cComponent2] = strval(arrCoords[15]);
CarInfo[idx][cComponent3] = strval(arrCoords[16]);
CarInfo[idx][cComponent4] = strval(arrCoords[17]);
CarInfo[idx][cComponent5] = strval(arrCoords[18]);
CarInfo[idx][cComponent6] = strval(arrCoords[19]);
CarInfo[idx][cComponent7] = strval(arrCoords[20]);
CarInfo[idx][cComponent8] = strval(arrCoords[21]);
CarInfo[idx][cComponent9] = strval(arrCoords[22]);
CarInfo[idx][cComponent10] = strval(arrCoords[23]);
CarInfo[idx][cComponent11] = strval(arrCoords[24]);
CarInfo[idx][cComponent12] = strval(arrCoords[25]);
CarInfo[idx][cComponent12] = strval(arrCoords[26]);
CarInfo[idx][cComponent13] = strval(arrCoords[27]);
CarInfo[idx][cPaintjob] = strval(arrCoords[28]);
printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
idx++;
}
}
return 1;
}

public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d\n",
CarInfo[idx][cModel],
CarInfo[idx][cLocationx],
CarInfo[idx][cLocationy],
CarInfo[idx][cLocationz],
CarInfo[idx][cAngle],
CarInfo[idx][cColorOne],
CarInfo[idx][cColorTwo],
CarInfo[idx][cOwner],
CarInfo[idx][cDescription],
CarInfo[idx][cValue],
CarInfo[idx][cLicense],
CarInfo[idx][cOwned],
CarInfo[idx][cLock],
CarInfo[idx][cComponent0],
CarInfo[idx][cComponent1],
CarInfo[idx][cComponent2],
CarInfo[idx][cComponent3],
CarInfo[idx][cComponent4],
CarInfo[idx][cComponent5],
CarInfo[idx][cComponent6],
CarInfo[idx][cComponent7],
CarInfo[idx][cComponent8],
CarInfo[idx][cComponent9],
CarInfo[idx][cComponent10],
CarInfo[idx][cComponent11],
CarInfo[idx][cComponent12],
CarInfo[idx][cComponent13],
CarInfo[idx][cPaintjob]);
if(idx == PersonalCarID)
{
file2 = fopen("cfg/cars.cfg", io_write);
}
else
{
file2 = fopen("cfg/cars.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}

Do u need anymore informations ? I am a begginer and I really need help for my server


Re: [HELP]Big problem - Mic_H - 29.10.2014

Please give me a brief info about what you are planning to do with this function, savecar()... Does it save all loaded cars to the file?? Or you want to save all In-Server cars?


Re: [HELP]Big problem - ExTaSy69 - 29.10.2014

So , I want the personal cars to be recorded/saved in cars.cfg . Because when I buy a car it's not recorded in cars.cfg and after I restart the server it dissapears .
Like today I buy a sultan . It will not appear in cars.cfg and after I restart the server the car is going to be destroyed . I don't know what to do .


Re: [HELP]Big problem - ExTaSy69 - 30.10.2014

UP ! Can somebody help me ? I can't run my server withoud my cars ...


Re: [HELP]Big problem - ExTaSy69 - 31.10.2014

UP ! I really need help , can someone help me please ?


Re: [HELP]Big problem - ExTaSy69 - 01.11.2014

UP ! I really need help , can someone help me please ?


Re: [HELP]Big problem - Sew_Sumi - 01.11.2014

I really don't think the cars.cfg is intended to be used in this way...

What's the script edit you are using?


Re: [HELP]Big problem - sammp - 01.11.2014

No no no no no no no no no no no no no no no
No no no no no no no no no no no no no no no

You're doing it wrong..