[Help]/v park
#1

When I type a /v park, show me that my vehicle is created at this point, I reset the server and the vehicle we would not be created in a place where I parked the car, but we are creating a vehicle for vehicles with ID 1 (I purchased vehicle with the last ID (159)).
In the. Cfg file changes the coordinates of the vehicle, but the vehicle is not made at this site.

Код:
    		if(listitem == 1)
    		{
    		    new veh;
    		    new Float: x, Float: y, Float: z, Float: rx;
    		    veh = PlayerInfo[playerid][pPcocarkey];
    		    if(!IsPlayerInVehicle(playerid, veh))
			    {
			   		SendClientMessage(playerid, COLOR_RED, "Nisi u svom vozilu.");
			   		return 1;
				}
				GetVehiclePos(veh, x, y, z);
				GetVehicleZAngle(veh, rx);
				SCM(playerid, COLOR_SKYBLUE,"Uspjesno ste parkirali vozilo. Vozilo ce se stvarati na ovom mjestu.");
				VehicleInfo[veh][vLocationX] = x;
				VehicleInfo[veh][vLocationY] = y;
				VehicleInfo[veh][vLocationZ] = z;
				VehicleInfo[veh][vLocationRX] = rx;
				SaveVehicles();
			}
Код:
LoadVehicles()
{
	new arrCoords[27][64],
	    strFromFile2[256],
	    File: file = fopen("/Nekretnine/cocars.cfg", io_read);

	if (file)
	{
		new idx;

		while (idx < sizeof(VehicleInfo))
		{
			fread(file, strFromFile2);
			split(strFromFile2, arrCoords, ',');
			
			VehicleInfo[idx][vLocationX] = floatstr(arrCoords[0]);
			VehicleInfo[idx][vLocationY] = floatstr(arrCoords[1]);
			VehicleInfo[idx][vLocationZ] = floatstr(arrCoords[2]);
			VehicleInfo[idx][vLocationRX] = floatstr(arrCoords[3]);
			VehicleInfo[idx][vArmour] = floatstr(arrCoords[4]);
			VehicleInfo[idx][vOwned] = strval(arrCoords[5]);
			strmid(VehicleInfo[idx][vOwner], arrCoords[6], 0, strlen(arrCoords[6]), 255);
			strmid(VehicleInfo[idx][vName], arrCoords[7], 0, strlen(arrCoords[7]), 255);
			VehicleInfo[idx][vModel] = strval(arrCoords[8]);
			VehicleInfo[idx][vColor1] = strval(arrCoords[9]);
			VehicleInfo[idx][vColor2] = strval(arrCoords[10]);
			VehicleInfo[idx][vLock] = strval(arrCoords[11]);
			VehicleInfo[idx][vBuyPrice] = strval(arrCoords[12]);
			VehicleInfo[idx][vENCOwned] = strval(arrCoords[13]);
			VehicleInfo[idx][vENCMoney] = strval(arrCoords[14]);
			VehicleInfo[idx][vCarRegisterOwned] = strval(arrCoords[15]);
			VehicleInfo[idx][vCarRegisterNum] = strval(arrCoords[16]);
			VehicleInfo[idx][vMats] = strval(arrCoords[17]);
			VehicleInfo[idx][vDrugs] = strval(arrCoords[18]);
			VehicleInfo[idx][vGun1] = strval(arrCoords[19]);
			VehicleInfo[idx][vGunAmmo1] = strval(arrCoords[20]);
			VehicleInfo[idx][vGun2] = strval(arrCoords[21]);
			VehicleInfo[idx][vGunAmmo2] = strval(arrCoords[22]);
			VehicleInfo[idx][vGun3] = strval(arrCoords[23]);
			VehicleInfo[idx][vGunAmmo3] = strval(arrCoords[24]);
			VehicleInfo[idx][vBenzin] = strval(arrCoords[25]);
			VehicleInfo[idx][vID] = strval(arrCoords[26]);
			printf("Co-vozilo %d je uspjesno ucitano.\n",idx);
			idx++;
		}
		fclose(file);
	}
	return 1;
}

SaveVehicles()
{
	new idx,
	    File: file2;

	while (idx < sizeof(VehicleInfo))
	{
		new coordsstring[312];


		format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
		VehicleInfo[idx][vLocationX],
		VehicleInfo[idx][vLocationY],
		VehicleInfo[idx][vLocationZ],
		VehicleInfo[idx][vLocationRX],
		VehicleInfo[idx][vArmour],
		VehicleInfo[idx][vOwned],
		VehicleInfo[idx][vOwner],
		VehicleInfo[idx][vName],
		VehicleInfo[idx][vModel],
		VehicleInfo[idx][vColor1],
		VehicleInfo[idx][vColor2],
		VehicleInfo[idx][vLock],
		VehicleInfo[idx][vBuyPrice],
		VehicleInfo[idx][vENCOwned],
		VehicleInfo[idx][vENCMoney],
		VehicleInfo[idx][vCarRegisterOwned],
		VehicleInfo[idx][vCarRegisterNum],
		VehicleInfo[idx][vMats],
		VehicleInfo[idx][vDrugs],
		VehicleInfo[idx][vGun1],
		VehicleInfo[idx][vGunAmmo1],
		VehicleInfo[idx][vGun2],
		VehicleInfo[idx][vGunAmmo2],
		VehicleInfo[idx][vGun3],
		VehicleInfo[idx][vGunAmmo3],
		VehicleInfo[idx][vBenzin],
		VehicleInfo[idx][vID]);

		if(idx == 0)
		{
			file2 = fopen("/Nekretnine/cocars.cfg", io_write);
		}
		else
		{
			file2 = fopen("/Nekretnine/cocars.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	idx = 0;
	return 1;
}
OnGameModeInit()

Код:
	for(new v = 0; v < sizeof(VehicleInfo); v++)
	{
		VehicleInfo[v][vID] = AddStaticVehicleEx(VehicleInfo[v][vModel], VehicleInfo[v][vLocationX], VehicleInfo[v][vLocationY], VehicleInfo[v][vLocationZ], VehicleInfo[v][vLocationRX], VehicleInfo[v][vColor1], VehicleInfo[v][vColor2], 999999);
		LinkVehicleToInterior(VehicleInfo[v][vID], 0);
  		SetVehicleVirtualWorld(VehicleInfo[v][vID], 0);
  		Fuel[VehicleInfo[v][vID]] = VehicleInfo[v][vBenzin];
	}
Reply
#2

I fix this Bug

Lock
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)