Jump to content
  • 0

Problema masini personale


ProAeXel

Question

Problema intalnita (descriere): Dupa ce cumpar o masina de la dealership ,o parchez cu /v park,iar dupa restartarea serverului ,masina dispare ,dar cand scriu /mycars imi apare ca as avea cheile unei masini,dar nu se specifica ce masina.
Ero(area / rile) / warning-(ul / urile): La compilare nu am absolut nici o eroare /warn
Liniile de cod / sursa / script-ul:
 

 

enum cInfo
{
	cModel,
	Float:cLocationx,
	Float:cLocationy,
	Float:cLocationz,
	Float:cAngle,
	cColorOne,
	cColorTwo,
	cOwner[MAX_PLAYER_NAME],
	cDescription[12],
	cValue,
	cLicense[14],
	cRegistration,
	cOwned,
	cLock,
	mod1,
	mod2,
	mod3,
	mod4,
	mod5,
	mod6,
	mod7,
	mod8,
	mod9,
	mod10,
	mod11,
	mod12,
	mod13,
	mod14,
	mod15,
	mod16,
	mod17,
	paintjob,
};

new CarInfo[1000][cInfo];
	if(newstate == PLAYER_STATE_DRIVER)
	{
		if(IsAnOwnableCar(newcar))
		{
		    if(CarInfo[newcar][cOwned]==1)
		    {
		        format(string,sizeof(string),"* Vehiculul privat al jucatorului {ffffff}%s",CarInfo[newcar][cOwner]);
				SendClientMessage(playerid, COLOR_ORANGE, string);
				if(PlayerInfo[playerid][pPcarkey] == vehicle) { }
				else if(PlayerInfo[playerid][pPcarkey2] == vehicle) { }
				else if(PlayerInfo[playerid][pPcarkey3] == vehicle) { }
				else
				{
				    RemovePlayerFromVehicle(playerid);
				    SendClientMessage(playerid, COLOR_GREY, "* Nu detii keyFle acestei masini.");
				}
		    }
		}
	} 
PUBLIC: OnCarUpdate()
{
	new idx;
	new File: file2;
	idx = carsonserver;
 	while (idx < sizeof(CarInfo))
	{
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%dn",
		CarInfo[idx][cModel],
		CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cColorOne],
		CarInfo[idx][cColorTwo],
		CarInfo[idx][cOwner],
		CarInfo[idx][cDescription],
		CarInfo[idx][cValue],
		CarInfo[idx][cLicense],
		CarInfo[idx][cOwned],
		CarInfo[idx][cLock],
		CarInfo[idx][mod1],
		CarInfo[idx][mod2],
		CarInfo[idx][mod3],
		CarInfo[idx][mod4],
		CarInfo[idx][mod5],
		CarInfo[idx][mod6],
		CarInfo[idx][mod7],
		CarInfo[idx][mod8],
		CarInfo[idx][mod9],
		CarInfo[idx][mod10],
		CarInfo[idx][mod11],
		CarInfo[idx][mod12],
		CarInfo[idx][mod13],
		CarInfo[idx][mod14],
		CarInfo[idx][mod15],
		CarInfo[idx][mod16],
		CarInfo[idx][mod17],
		CarInfo[idx][paintjob]);
		if(idx == carsonserver)
		{
			file2 = fopen("personalcars.cfg", io_write);
		}
		else
		{
			file2 = fopen("personalcars.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	return 1;
} 
PUBLIC: LoadCar()
{
	new arrCoords[31][64];
	new strFromFile2[256];
	new File: file = fopen("personalcars.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);
			strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
			CarInfo[idx][cValue] = strval(arrCoords[9]);
			strmid(CarInfo[idx][cLicense], arrCoords[10], 0, strlen(arrCoords[10]), 255);
			CarInfo[idx][cOwned] = strval(arrCoords[11]);
			CarInfo[idx][cLock] = strval(arrCoords[12]);
			CarInfo[idx][mod1] = strval(arrCoords[13]);
			CarInfo[idx][mod2] = strval(arrCoords[14]);
			CarInfo[idx][mod3] = strval(arrCoords[15]);
			CarInfo[idx][mod4] = strval(arrCoords[16]);
			CarInfo[idx][mod5] = strval(arrCoords[17]);
			CarInfo[idx][mod6] = strval(arrCoords[18]);
			CarInfo[idx][mod7] = strval(arrCoords[19]);
			CarInfo[idx][mod8] = strval(arrCoords[20]);
			CarInfo[idx][mod9] = strval(arrCoords[21]);
			CarInfo[idx][mod10] = strval(arrCoords[22]);
			CarInfo[idx][mod11] = strval(arrCoords[23]);
			CarInfo[idx][mod12] = strval(arrCoords[24]);
			CarInfo[idx][mod13] = strval(arrCoords[25]);
			CarInfo[idx][mod14] = strval(arrCoords[26]);
			CarInfo[idx][mod15] = strval(arrCoords[27]);
			CarInfo[idx][mod16] = strval(arrCoords[28]);
			CarInfo[idx][mod17] = strval(arrCoords[29]);
			CarInfo[idx][paintjob] = strval(arrCoords[30]);
			printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
			idx++;
		}
	}
	return 1;
}

PUBLIC: SaveCarCoords()
{
	new idx;
	new File: file2;
	while (idx < sizeof(CarInfo))
	{
	    new coordsstring[256];
	    format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%dn",
		CarInfo[idx][cModel],
		CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cColorOne],
		CarInfo[idx][cColorTwo],
		CarInfo[idx][mod1],
		CarInfo[idx][mod2],
		CarInfo[idx][mod3],
		CarInfo[idx][mod4],
		CarInfo[idx][mod5],
		CarInfo[idx][mod6],
		CarInfo[idx][mod7],
		CarInfo[idx][mod8],
		CarInfo[idx][mod9],
		CarInfo[idx][mod10],
		CarInfo[idx][mod11],
		CarInfo[idx][mod12],
		CarInfo[idx][mod13],
		CarInfo[idx][mod14],
		CarInfo[idx][mod15],
		CarInfo[idx][mod16],
		CarInfo[idx][mod17],
		CarInfo[idx][paintjob]);
		if(idx == carsonserver)
		{
			file2 = fopen("personalcars.cfg", io_write);
		}
		else
		{
			file2 = fopen("personalcars.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	return 1;
} 
PUBLIC: CarKeys(playerid)
{
    new string2[64];
	new playername2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername2, sizeof(playername2));
	format(string2, sizeof(string2), "KeyMasini/%s.ini", playername2);
	new File: UserFile = fopen(string2, io_read);
	if ( UserFile )
	{
		new key[ 256 ] , val[ 256 ];
		new Data[ 256 ];
		while ( fread( UserFile , Data , sizeof( Data ) ) )
		{
			key = ini_GetKey( Data );
			if( strcmp( key , "CarKey" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPcarkey] = strval( val ); }
			if( strcmp( key , "CarKey2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPcarkey2] = strval( val ); }
			if( strcmp( key , "CarKey3" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPcarkey3] = strval( val ); }
        }
        fclose(UserFile);
	}
	return 1;
} 

Ati incercat sa rezolvati singur?: Da,dar nu am obtinut nici un rezultat bun.Am cautat pe o multime de forumuri ,dar tot nimic.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Incearca sa folosesti acel cfg...doar pentru a da load la masini , si sa ai alte CFG-uri care sa fie salvate masinile , sau foloseste SQLite / MySQL.

 

Iar atunci cand dai load la masini , sa se uite in primu rand daca exista masina deja creeata in CFG-ul respectiv si sa o creeze , daca nu este creeata sa o creeze din personalcars.cfg

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.