need help to spawn cars from an .ini file
#1

I've been trying different things for days now and i turn to you the community for helps please.

I want to have an individual .ini file for each vehicle but can not work out how to spawn vehicles ongamemodeinit using the files... please help me...

An example of the .ini filekept simple)

Код:
ID=2
LicensePlate=NTP 700R
Model=411
Color1=0
Color2=1
PosX=1780.3442
PosY=-2504.8789
PosZ=13.4324
PosR=327.7069
I created a way to save to a file, but not spawn from one, example:
Код:
	if(strcmp(cmd, "/sc", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
		    new string[64];
			new carid = GetPlayerVehicleID(playerid);
		    new plate[12];
			new rand1 = random(NumberPlateLetter);new rand2 = random(NumberPlateLetter);new rand3 = random(NumberPlateLetter);new rand4 = 100 + random(899);new rand5 = random(NumberPlateLetter);
		    format(plate, sizeof(plate), "%s%s%s %d%s", LetterGen[rand1], LetterGen[rand2], LetterGen[rand3], rand4, LetterGen[rand5]);
			format(string, sizeof(string), "vehicles/%s.ini", plate);
			new File: hFile = fopen(string, io_write);
			if (hFile)
			{
				new Float:x,Float:y,Float:z,Float:f;
				GetVehiclePos(carid, x, y, z);
				GetVehicleZAngle(carid, f);
			    new var[32];
				format(var, 32, "ID=%d\n", carid);fwrite(hFile, var);
				format(var, 32, "LicensePlate=%s\n", plate);fwrite(hFile, var);
				format(var, 32, "Model=%d\n",GetVehicleModel(carid));fwrite(hFile, var);
				format(var, 32, "Color1=%d\n", 0);fwrite(hFile, var);
				format(var, 32, "Color2=%d\n", 1);fwrite(hFile, var);
				format(var, 32, "PosX=%.4f\n",x);fwrite(hFile, var);
				format(var, 32, "PosY=%.4f\n",y);fwrite(hFile, var);
				format(var, 32, "PosZ=%.4f\n",z);fwrite(hFile, var);
				format(var, 32, "PosR=%.4f\n",f);fwrite(hFile, var);
				fclose(hFile);
				format(string, sizeof(string), "[iT:] Car Saved: ID:%d", carid);
				SendClientMessage(playerid, COLOR_YELLOW, string);
			}
		}
		return 1;
	}
idk, i'm self taught so i prolly have a heap of bad habits, the more i try the more i confuse myself, i hope some is nice enough to help me...
Reply
#2

Use a stock and then loop trough all files usinf for(new blablabla
Reply
#3

Quote:
Originally Posted by milanosie
Посмотреть сообщение
Use a stock and then loop trough all files usinf for(new blablabla
Yeah that's a bit above my ability though...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)