Jump to content
Geplaatst:
comment_1572419

Ik heb het volgende:

De command

dcmd_aveh(playerid, params[])
{
new vehid;
new c1, c2;
new Float:x, Float:y, Float:z, Float:a;
if(PlayerInfo[playerid][adminlevel] >= 2)
{
		if(sscanf(params, "i,i,i", vehid,c1,c2))
       {
               SendClientMessage(playerid, COLOR_DRED, "USAGE: /aveh <carid> <color1> <color2>");
               return 1;
	}
	new i;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, a);
	DCars[i][CarX] = x;
	DCars[i][CarY] = y;
	DCars[i][CarZ] = z;
	DCars[i][CarAngle] = a;
	DCars[i][CarModel] = vehid;
	DCars[i][CarColor1] = c1;
	DCars[i][CarColor2] = c2;
 		CreateVehicle(DCars[i][CarModel],DCars[i][CarX]+5,DCars[i][CarY],DCars[i][CarZ],DCars[i][CarAngle],DCars[i][CarColor1],DCars[i][CarColor2], 60);
		SaveDynamicCars();
}
return 1;
}

De Save public

public SaveDynamicCars()
{
new idx;
new File: file2;
while (idx < sizeof(DCars))
{

	new coordsstring[512];
	format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d\n",
	DCars[idx][CarModel],
	DCars[idx][CarX],
	DCars[idx][CarY],
	DCars[idx][CarZ],
	DCars[idx][CarAngle],
	DCars[idx][CarColor1],
	DCars[idx][CarColor2]);
	if(idx == 0)
	{
		file2 = fopen("Cars/carspawns.cfg", io_write);
	}
	else
	{
		file2 = fopen("Cars/carspawns.cfg", io_append);
	}
	fwrite(file2, coordsstring);
	idx++;
	fclose(file2);
}
return 1;
}

En als laatste de load public

public LoadDynamicCars()
{
new arrCoords[9][64];
new strFromFile2[256];
new File: file = fopen("Cars/carspawns.cfg", io_read);
if (file)
{
	new idx;
	while (idx < sizeof(DCars))
	{
		fread(file, strFromFile2);
		split(strFromFile2, arrCoords, '|');
		DCars[idx][CarModel] = strval(arrCoords[0]);
		DCars[idx][CarX] = floatstr(arrCoords[1]);
		DCars[idx][CarY] = floatstr(arrCoords[2]);
		DCars[idx][CarZ] = floatstr(arrCoords[3]);
		DCars[idx][CarAngle] = floatstr(arrCoords[4]);
		DCars[idx][CarColor1] = strval(arrCoords[5]);
		DCars[idx][CarColor2] = strval(arrCoords[6]);
   		CreateVehicle(DCars[idx][CarModel],DCars[idx][CarX],DCars[idx][CarY],DCars[idx][CarZ],DCars[idx][CarAngle],DCars[idx][CarColor1],DCars[idx][CarColor2], 60);
		idx++;
	}
	fclose(file);
}
return 1;
}

Het probleem:

Ik spawn een vehicle ( met /aveh) en die moet dan gelijk saven op ed plek (zie SaveDynamicCars bij de command).

Dit doet hij wel, maar niet zoals het hoord.

Want als ik het script re-start staat er geen auto, nu staat er bij de carspawn.cfg hele rare dingen, het begint gewoon met model,x,y,z,angle enz.

Maar daar achter staan nog heel veel 0.0000|0.0000|37 enz. hele rare dingen die daar, volgens mij, niet horen.

Iemand een idee wat er aan de hand is?

Ik loop al 1 week te experimenteren mja, het resultaat staat boven.

// Rutger.

Featured Replies

Geplaatst:
comment_1572875

               if(idx == 0)
               {
                       file2 = fopen("Cars/carspawns.cfg", io_write);
               }
               else
               {
                       file2 = fopen("Cars/carspawns.cfg", io_append);
               }

Dan ga je steeds een file openen, je kunt toch beter van de eerste keer dat instellen?

En dan maar pas op het einde fclose doen, maar of dat dat je probleem zal oplossen weet ik niet.

Bewerkt: door GTAguillaume

Een reactie plaatsen

Je kan nu een reactie plaatsen en pas achteraf registreren. Als je al lid bent, log eerst in om met je eigen account een reactie te plaatsen.

Gast
Op dit onderwerp reageren...

Recent actief 0

  • Er zijn hier geen geregistreerde gebruikers aanwezig.