public LoadCar() { new arrCoords[31][64]; new strFromFile2[256]; new File: file = fopen("masini.cfg", io_read); if (file) { new idx = carsonserver; 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][cPaintjob] = strval(arrCoords[10]); CarInfo[idx][cVirWorld] = strval(arrCoords[11]); CarInfo[idx][cComponent0] = strval(arrCoords[12]); CarInfo[idx][cComponent1] = strval(arrCoords[13]); CarInfo[idx][cComponent2] = strval(arrCoords[14]); CarInfo[idx][cComponent3] = strval(arrCoords[15]); CarInfo[idx][cComponent4] = strval(arrCoords[16]); CarInfo[idx][cComponent5] = strval(arrCoords[17]); CarInfo[idx][cComponent6] = strval(arrCoords[18]); CarInfo[idx][cComponent7] = strval(arrCoords[19]); CarInfo[idx][cComponent8] = strval(arrCoords[20]); CarInfo[idx][cComponent9] = strval(arrCoords[21]); CarInfo[idx][cComponent10] = strval(arrCoords[22]); CarInfo[idx][cComponent11] = strval(arrCoords[23]); CarInfo[idx][cComponent12] = strval(arrCoords[24]); CarInfo[idx][cComponent12] = strval(arrCoords[25]); CarInfo[idx][cComponent13] = strval(arrCoords[26]); printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]); idx++; } } return 1; } public SaveCarCoords() { new idx; new File: file2; while (idx < sizeof(CarInfo)) { new coordsstring[256]; format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|% d|%d|%d|%d|%d|%d|%d|%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][cPaintjob], CarInfo[idx][cVirWorld], 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][cComponent12], CarInfo[idx][cComponent13]); if(idx == carsonserver) { file2 = fopen("masini.cfg", io_write); } else { file2 = fopen("masini.cfg", io_append); } fwrite(file2, coordsstring); idx++; fclose(file2); } return 1; } if(strcmp(cmd, "/adeletecar", true) == 0) { if(IsPlayerAdmin(playerid)) { CarInfo[idcar][cOwned] = 0; CarInfo[idcar][cModel] = 0; CarInfo[idcar][cColorOne] = 0; CarInfo[idcar][cColorTwo] = 0; CarInfo[idcar][cLocationx] = 0; CarInfo[idcar][cLocationy] = 0; CarInfo[idcar][cLocationz] = 0; CarInfo[idcar][cAngle] = 0; CarInfo[idcar][cValue] = 0; CarInfo[idcar][cLock] = 0; strmid(CarInfo[idcar][cOwner], "Dealership", 0, strlen("Dealership"), 999); format(CarInfo[idcar][cDescription], 32, "0"); DestroyVehicle(idcar); OnPropUpdate(); SavePlayerData(playerid); } } if(strcmp(cmd, "/acreatecar", true) == 0) { if(IsPlayerAdmin(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]"); return 1; } new car; car = strval(tmp); if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_WHITE, " Vehicle Number can't be below 400 or above 611 !"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]"); return 1; } new color1; color1 = strval(tmp); if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 126 !"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]"); return 1; } new color2; color2 = strval(tmp); if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 126 !"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]"); return 1; } new value; value = strval(tmp); new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z); new thiscar = CreateVehicle(car,X,Y,Z,1,color1,color2,99999999); format(CarInfo[thiscar][cLicense], 32 ,"ForSale"); SetVehicleNumberPlate(vehid,CarInfo[thiscar][cLicense]); CarInfo[thiscar][cOwned] = 0; CarInfo[thiscar][cModel] = car; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2; CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1; CarInfo[thiscar][cValue] = value; CarInfo[thiscar][cLock] = 0; PutPlayerInVehicle(playerid,thiscar,0); strmid(CarInfo[vehid][cOwner], "Dealership", 0, strlen("Dealership"), 999); format(CarInfo[thiscar][cDescription], 32, "%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]); format(string, sizeof(string), " Masina %d a fost creata cu succes!.", thiscar); SendClientMessage(playerid, COLOR_BLUE, string); } else { SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!"); return 1; } } |