else if(strcmp(x_nr,"buy",true) == 0) { new coordsstring[256]; new car = 1; new model = GetVehicleModel(idcar); if(IsASalesVehicle(idcar)) { if(IsPlayerInVehicle(playerid, idcar)) { if(PlayerInfo[playerid][pLevel] < 4) { SendClientMessage(playerid, COLOR_GREY, "You need to be level 4 to buy a vehicle!"); return 1; } if(PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999 || PlayerInfo[playerid][pPcarkey3] == 9999) { } else return SendClientMessage(playerid, COLOR_GREY,"* You already own 3 cars!"); if(GetPlayerMoney(playerid) >= GetVehiclePrice(idcar)) { if(PlayerInfo[playerid][pCarLic] == 1) { for(new h = carsonserver; h < sizeof(CarInfo); h++) { if(CarInfo[h][cOwned] == 0) { car = h; h = 9999; } } new File: file = fopen("masini.cfg", io_read); if(PlayerInfo[playerid][pPcarkey] != 9999 && PlayerInfo[playerid][pPcarkey2] == 9999) { PlayerInfo[playerid][pPcarkey2] = car; } else if(PlayerInfo[playerid][pPcarkey] != 9999 && PlayerInfo[playerid][pPcarkey2] != 9999){ PlayerInfo[playerid][pPcarkey3] = car; } else { PlayerInfo[playerid][pPcarkey] = car; } CarInfo[car][cOwned] = 1; strmid(CarInfo[car][cOwner], sendername, 0, strlen(sendername), 999); SafeGivePlayerMoney(playerid,-GetVehiclePrice(idcar)); if(IsModelAPlane(idcar) || IsModelAHeli(idcar)) { CarInfo[car][cLocationx] = 1409.4000200; CarInfo[car][cLocationy] = -2492.5000000; CarInfo[car][cLocationz] = 180.0000000; CarInfo[car][cAngle] = 0; SendClientMessage(playerid, COLOR_YELLOW2, "Your Aircraft has been deliveried to Los Santos Airport, you can get it there!"); SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!"); SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!"); GameTextForPlayer(playerid, "~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~Las Venturas Airport!", 5000, 3); } else if(IsModelABoat(idcar)) { CarInfo[car][cLocationx] = 308.1000100; CarInfo[car][cLocationy] = -2068.5000000; CarInfo[car][cLocationz] = 0.0000000; CarInfo[car][cAngle] = 0; SendClientMessage(playerid, COLOR_YELLOW2, "Your Boat has been deliveried to Los Santos Docks, you can get it there!"); SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!"); SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!"); GameTextForPlayer(playerid, "~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~San Fierro Docks!", 5000, 3); } else { CarInfo[car][cLocationx] = 1963.6999500; CarInfo[car][cLocationy] = -2308.3000500; CarInfo[car][cLocationz] = 13.2000000; CarInfo[car][cAngle] = 0; SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle has been deliveried to Los Santos Airport, you can get it there!"); SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!"); SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!"); GameTextForPlayer(playerid, "~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~Los Santos Airport!", 5000, 3); } format(coordsstring, sizeof(coordsstring), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", CarInfo[car][cModel] = model, CarInfo[car][cVirWorld] = 0, CarInfo[car][cPaintjob] = 999, CarInfo[car][cColorOne] = 1, CarInfo[car][cColorTwo] = 1, CarInfo[car][cComponent0] = 0, CarInfo[car][cComponent1] = 0, CarInfo[car][cComponent2] = 0, CarInfo[car][cComponent3] = 0, CarInfo[car][cComponent4] = 0, CarInfo[car][cComponent5] = 0, CarInfo[car][cComponent6] = 0, CarInfo[car][cComponent7] = 0, CarInfo[car][cComponent8] = 0, CarInfo[car][cComponent9] = 0, CarInfo[car][cComponent10] = 0, CarInfo[car][cComponent11] = 0, CarInfo[car][cComponent12] = 0, CarInfo[car][cComponent13] = 0); { file = fopen("masini.cfg", io_write); } fwrite(file, coordsstring); car++; fclose(file); DestroyVehicle(car); ownedcar[car] = CreateVehicle(CarInfo[car][cModel],CarInfo[car][cLocationx],CarInfo[car][cLocationy],CarInfo[car][cLocationz],90.0,1,1,30000); PlayerPlayMusic(playerid); SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!"); SendClientMessage(playerid, COLOR_GRAD2, "Type /vehiclehelp to view the vehicle manual!"); gEngine[playerid] = 0; engineOn[GetPlayerVehicleID(playerid)] = false; SafeRemovePlayerFromVehicle(playerid); OnProppUpdate(); OnPlayerUpdateEx(playerid); } else { SendClientMessage(playerid, COLOR_WHITE, "* For security reasons, a Driving License is needed to buy a car!"); return 1; } } else { SendClientMessage(playerid, COLOR_GREY, " You don't have enough cash with you ! "); return 1; } } else { //do nothing } } }
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); CarInfo[idx][cOwned] = strval(arrCoords[8]); CarInfo[idx][cLock] = strval(arrCoords[9]); 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][cComponent13] = strval(arrCoords[25]); strmid(CarInfo[idx][cPlate], arrCoords[7], 0, strlen(arrCoords[7]), 255); printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cPlate]); idx++; } } return 1; }
Don't use the native file system, use DINI or something like that. Avoid flatfile is best (MySQL or SQLlight) Is it finding the file? Use prints to debug and see if the entire load script is running. |
[01:08:40] Loaded 0 filterscripts. [01:08:40] CarInfo: 444 Owner:Mickey LicensePlate Mickey [01:08:40] CarInfo: 445 Owner:Mickey LicensePlate Mickey [01:08:40] CarInfo: 446 Owner:Mickey LicensePlate Mickey [01:08:40] CarInfo: 447 Owner: LicensePlate [01:08:40] CarInfo: 448 Owner: LicensePlate [01:08:40] CarInfo: 449 Owner: LicensePlate [01:08:40] CarInfo: 450 Owner: LicensePlate [01:08:40] CarInfo: 451 Owner: LicensePlate ... [01:08:40] CarInfo: 996 Owner: LicensePlate [01:08:40] CarInfo: 997 Owner: LicensePlate [01:08:40] CarInfo: 998 Owner: LicensePlate [01:08:40] CarInfo: 999 Owner: LicensePlate [01:17:12] [SCRIPT]: Loaded Houses [01:17:12] [SCRIPT]: Loaded Bizzes [01:17:12] [SCRIPT]: Loaded S-Bizzes [01:17:12] [SCRIPT]: Loaded 540 Objects [01:17:12] [SCRIPT]: Loaded 181 Pickups [01:17:12] [01:17:12] Tric RPG [01:17:12] _________________________________________ [01:17:12] By: Mickey [01:17:12] [01:17:12] Number of vehicle models: 135