Skip to content
View in the app

A better way to browse. Learn more.

GTAGames.nl - De Nederlandse Grand Theft Auto Community!

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Opslaan probleem

Ik ben bezig met een carsystem die alle auto's opslaat.

Nu heb ik een probleem met de auto's opslaan als de server stopt.

Dit staat nu Car.txt:

Auto,11

Dit staat er na het opslaan in Car.txt:

Auto,1093664768

Laden:

stock LoadCars()
{
if(fexist("Car.txt"))
{
    CountCars();
	new Argument[13][70];
	new entry[256], BoughtCars;
	new File: Carfile = fopen("Car.txt", io_read);
    if (Carfile)
	{
	    for(new id; id<CarsAmount; id++)
		{
			fread(Carfile, entry);
			split(entry, Argument, ',');
			format(CarInfo[id][CarNaam], 64, "%s", Argument[0]);
			CarInfo[id][CarID] = floatstr(Argument[1]);
			CarInfo[id][CarM] = floatstr(Argument[2]);
			CarInfo[id][CarX] = floatstr(Argument[3]);
			CarInfo[id][CarY] = floatstr(Argument[4]);
			CarInfo[id][CarZ] = floatstr(Argument[5]);
			CarInfo[id][CarA] = floatstr(Argument[6]);
			CarInfo[id][CarC1] = floatstr(Argument[7]);
			CarInfo[id][CarC2] = floatstr(Argument[8]);
			CarInfo[id][CarBought] = floatstr(Argument[9]);
			format(CarInfo[id][CarOwner], 64, "%s", Argument[10]);
			CarInfo[id][CarPrice] = floatstr(Argument[11]);
			CarInfo[id][CarFuel] = floatstr(Argument[12]);
			//CarInfo[id][PickupNr] = CreateVehicle(CarInfo[id][CarM], CarInfo[id][CarX], CarInfo[id][CarY], CarInfo[id][CarZ], CarInfo[id][CarA], CarInfo[id][CarC1], CarInfo[id][CarC2], 60);
               if(CarInfo[id][CarBought] == 1)
			{
			    BoughtCars++;
			}
		}
		fclose(Carfile);
		printf("===================================");
		printf("||    %d Cars                     ||", CarsAmount);
		printf("||    %d Cars are bought          ||", BoughtCars);
		printf("===================================");
	}
}
}

Opslaan:

stock SaveCars()
{
new entry[256];
new File: Carfile = fopen("Car.txt", io_write);
for(new id; id<CarsAmount; id++)
{
    format(entry, 128, "%s,%d \r\n",CarInfo[id][CarNaam], CarInfo[id][CarID]);
	fwrite(Carfile, entry);
}
printf("Saved %d Cars!", CarsAmount);
fclose(Carfile);
}

Featured Replies

Het carid moet een integer zijn, geen float.

// Bij de LoadCars
CarInfo[id][CarID] = strval(Argument[1]);

  • Author

Dat zou theoretiesh werken maar ik krijg nog steeds een raar lang nummer.

Dus heb ik de code een beetje aangepast en dan blijkt dat het waarschijndelijk aan het opslaan ligt,

nu kijg ik alsnog 1065353216

>Pastebin<

stock LoadCars()
{
if(fexist("Car.txt"))
{
    CountCars();
	new Argument[3][70];
	new entry[256], BoughtCars;
	new File: Carfile = fopen("Car.txt", io_read);
    if (Carfile)
	{
	    for(new id; id<CarsAmount; id++)
		{
			fread(Carfile, entry);
			split(entry, Argument, ',');
			format(CarInfo[id][CarNaam], 64, "%s", Argument[0]);
			CarInfo[id][CarID] = 1;
			/*CarInfo[id][CarM] = floatstr(Argument[2]);
			CarInfo[id][CarX] = floatstr(Argument[3]);
			CarInfo[id][CarY] = floatstr(Argument[4]);
			CarInfo[id][CarZ] = floatstr(Argument[5]);
			CarInfo[id][CarA] = floatstr(Argument[6]);
			CarInfo[id][CarC1] = floatstr(Argument[7]);
			CarInfo[id][CarC2] = floatstr(Argument[8]);
			CarInfo[id][CarBought] = floatstr(Argument[9]);
			format(CarInfo[id][CarOwner], 64, "%s", Argument[10]);
			CarInfo[id][CarPrice] = floatstr(Argument[11]);
			CarInfo[id][CarFuel] = floatstr(Argument[12]);
			CarInfo[id][PickupNr] = CreateVehicle(CarInfo[id][CarM], CarInfo[id][CarX], CarInfo[id][CarY], CarInfo[id][CarZ], CarInfo[id][CarA], CarInfo[id][CarC1], CarInfo[id][CarC2], 60);
               if(CarInfo[id][CarBought] == 1)
			{
			    BoughtCars++;
			}*/
		}
		fclose(Carfile);
		printf("===================================");
		printf("||    %d Cars                     ||", CarsAmount);
		printf("||    %d Cars are bought          ||", BoughtCars);
		printf("===================================");
	}
}
}

stock SaveCars()
{
new entry[256];
new File: Carfile = fopen("Car.txt", io_write);
for(new id; id<CarsAmount; id++)
{
    format(entry, 128, "%s,%d",CarInfo[id][CarNaam], CarInfo[id][CarID]);
	fwrite(Carfile, entry);
}
printf("Saved %d Cars!", CarsAmount);
fclose(Carfile);
}

Edited by mosweg

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.