Jump to content
  • 0

Problema vehicule


Jizzy.

Question

Salut. Am incercat sa adaug un sistem de vehicule dar nu inteleg de ce nu se actualizeaza datele in baza de date. O sa va las script-ul mai jos:

 

function LoadVehicles() {
	Vehicless = cache_num_rows();
	new str[30];
	for(new i = 0; i <= Vehicless; i++) {
		VehicleInfo[i][vehModel]		= cache_get_field_content_int(i, "Model");
		VehicleInfo[i][vehColor1]		= cache_get_field_content_int(i, "Color1");
		VehicleInfo[i][vehColor2]		= cache_get_field_content_int(i, "Color2");
		VehicleInfo[i][vehGroup]		= cache_get_field_content_int(i, "Group");
		VehicleInfo[i][vehRank]			= cache_get_field_content_int(i, "Rank");
		VehicleInfo[i][vehRotation]		= cache_get_field_content_float(i, "Rotation");
		VehicleInfo[i][vehPosX]			= cache_get_field_content_float(i, "PosX");
		VehicleInfo[i][vehPosY]			= cache_get_field_content_float(i, "PosY");
		VehicleInfo[i][vehPosZ]			= cache_get_field_content_float(i, "PosZ");
		VehicleInfo[i][vehCarIDD]		= cache_get_field_content_int(i, "ID");

		if(VehicleInfo[i][vehColor1] < 0) VehicleInfo[i][vehColor1] = random(126); 
		if(VehicleInfo[i][vehColor2] < 0) VehicleInfo[i][vehColor2] = random(126);
		if(VehicleInfo[i][vehGroup] == 8 && VehicleInfo[i][vehModel] == 411 || VehicleInfo[i][vehGroup] == 2 && VehicleInfo[i][vehModel] == 541 || VehicleInfo[i][vehGroup] == 1 && VehicleInfo[i][vehModel] == 411 || VehicleInfo[i][vehGroup] == 8 && VehicleInfo[i][vehModel] == 468 || VehicleInfo[i][vehGroup] == 8 && VehicleInfo[i][vehModel] == 470) {
			VehicleInfo[i][vehCarID] = CreateVehicle(VehicleInfo[i][vehModel], VehicleInfo[i][vehPosX], VehicleInfo[i][vehPosY], VehicleInfo[i][vehPosZ], VehicleInfo[i][vehRotation], VehicleInfo[i][vehColor1], VehicleInfo[i][vehColor2], 1800, 1);
		}
		else {
			VehicleInfo[i][vehCarID] = CreateVehicle(VehicleInfo[i][vehModel], VehicleInfo[i][vehPosX], VehicleInfo[i][vehPosY], VehicleInfo[i][vehPosZ], VehicleInfo[i][vehRotation], VehicleInfo[i][vehColor1], VehicleInfo[i][vehColor2], 1800);
		}
		if(VehicleInfo[i][vehGroup] == 0) {
			format(str,sizeof(str),"%d",i+1);
			SetVehicleNumberPlate(VehicleInfo[i][vehCarID],str);
		}
		else if(VehicleInfo[i][vehGroup] > 0) {
			if(VehicleInfo[i][vehGroup] > 9) {
				format(str,sizeof(str),"F%d %d",VehicleInfo[i][vehGroup],i+1);
				SetVehicleNumberPlate(VehicleInfo[i][vehCarID],str);
			}
			else if(VehicleInfo[i][vehGroup] < 10) {
				format(str,sizeof(str),"F0%d %d",VehicleInfo[i][vehGroup],i+1);
				SetVehicleNumberPlate(VehicleInfo[i][vehCarID],str);
			}
		}
		if(VehicleInfo[i][vehGroup] == 13) {
			if(VehicleInfo[i][vehModel] != 438) {
				new taxiobj = CreateObject(19308, 0.00000, 0.00000, 0.00000,0.00000, 0.00000, 0.00000);
				AttachObjectToVehicle(taxiobj, VehicleInfo[i][vehCarID], 0.000000, -0.249999, 0.949999, 0.000000, 0.000001, 90.449951);
			}
		}
		if(VehicleInfo[i][vehGroup] == 8 || VehicleInfo[i][vehGroup] == 2 || VehicleInfo[i][vehGroup] == 1) {
			if(VehicleInfo[i][vehModel] == 411) {
				object = CreateObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
				AttachObjectToVehicle(object, VehicleInfo[i][vehCarID],  0.010000, -0.060000, 0.689999, 0.000000, 0.000000, 0.000000);
				new policecar = CreateObject(19327, -2597.0762, -2638.4270, -5.3536, -87.6999, 90.4001, -87.1805);
				SetObjectMaterialText(policecar, "POLICE", 0, OBJECT_MATERIAL_SIZE_256x128, "Arial", 40, 1, -16777216, 0, 1);
				AttachObjectToVehicle(policecar, VehicleInfo[i][vehCarID], 0.000000, -1.984998, 0.229999, -85.424964, 0.000000, 0.000000);
			}
		}
	}
	printf("%d server vehicles loaded.", Vehicless);
	return 1;
}
case DIALOG_SAVEVEHICLE: {
			if(response) {
				if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to be in a vehicle to save it.");
				new Float:vPos[4],strquery[160],i;
				GetVehiclePos(vehicleid, vPos[0], vPos[1], vPos[2]);
			    GetVehicleZAngle(vehicleid, vPos[3]);
			    print("1 - savevehicle");
				format(strquery, sizeof(strquery), "INSERT INTO `vehicles` (`Model`, `PosX`, `PosY`, `PosZ`, `Rotation`) VALUES ('%d', '%f', '%f', '%f', '%f')", GetVehicleModel(vehicleid), vPos[0], vPos[1], vPos[2], vPos[3]);
			    new Cache: ab = mysql_query(SQL, strquery);
				i = cache_insert_id();
				cache_delete(ab);

				VehicleInfo[i][vehModel] = GetVehicleModel(GetPlayerVehicleID(playerid));
				VehicleInfo[i][vehPosX] = vPos[0];
				VehicleInfo[i][vehPosY] = vPos[1];
				VehicleInfo[i][vehPosZ] = vPos[2];
				VehicleInfo[i][vehRotation] = vPos[3];
				VehicleInfo[i][vehGroup] = 0;
				VehicleInfo[i][vehRank] = 0;
				VehicleInfo[i][vehCarID] = GetPlayerVehicleID(playerid);
				for(new x = 0; x < MAX_VEHICLES; x++)
				{
			    	if(Carspawn[x] == GetPlayerVehicleID(playerid))
					{
			    	    Carspawn[x] = 0;
			    	}
			    }
				VehicleInfo[i][vehCarID] = GetPlayerVehicleID(playerid);
				Vehicless++;
				format(strquery, sizeof(strquery), "The vehicle %d was successfully inserted in database. (db: %d)", VehicleInfo[i][vehCarID], VehicleInfo[i][vehCarIDD]);
				SCM(playerid, COLOR_GREY, strquery);
				print("2 - savevehicle");
			}
		}
                                                  
// ALL VEHICLES
enum vehInfo {
	vehModel,
	vehColor1,
	vehColor2,
	vehGroup,
	vehRank,
	vehCarID,
	vehCarIDD,
	Float:vehPosX,
	Float:vehPosY,
	Float:vehPosZ,
	Float:vehRotation
};
new VehicleInfo[1000][vehInfo];

 

Cand folosesc o comanda (Ex: /vcolor, /vgroup, /vrank etc.) nu se actualizeaza in baza de date. De la ce poate fi problema?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
Acum 15 ore, Jizzy. a spus:

Salut. Am incercat sa adaug un sistem de vehicule dar nu inteleg de ce nu se actualizeaza datele in baza de date. O sa va las script-ul mai jos:

 


function LoadVehicles() {
	Vehicless = cache_num_rows();
	new str[30];
	for(new i = 0; i <= Vehicless; i++) {
		VehicleInfo[i][vehModel]		= cache_get_field_content_int(i, "Model");
		VehicleInfo[i][vehColor1]		= cache_get_field_content_int(i, "Color1");
		VehicleInfo[i][vehColor2]		= cache_get_field_content_int(i, "Color2");
		VehicleInfo[i][vehGroup]		= cache_get_field_content_int(i, "Group");
		VehicleInfo[i][vehRank]			= cache_get_field_content_int(i, "Rank");
		VehicleInfo[i][vehRotation]		= cache_get_field_content_float(i, "Rotation");
		VehicleInfo[i][vehPosX]			= cache_get_field_content_float(i, "PosX");
		VehicleInfo[i][vehPosY]			= cache_get_field_content_float(i, "PosY");
		VehicleInfo[i][vehPosZ]			= cache_get_field_content_float(i, "PosZ");
		VehicleInfo[i][vehCarIDD]		= cache_get_field_content_int(i, "ID");

		if(VehicleInfo[i][vehColor1] < 0) VehicleInfo[i][vehColor1] = random(126); 
		if(VehicleInfo[i][vehColor2] < 0) VehicleInfo[i][vehColor2] = random(126);
		if(VehicleInfo[i][vehGroup] == 8 && VehicleInfo[i][vehModel] == 411 || VehicleInfo[i][vehGroup] == 2 && VehicleInfo[i][vehModel] == 541 || VehicleInfo[i][vehGroup] == 1 && VehicleInfo[i][vehModel] == 411 || VehicleInfo[i][vehGroup] == 8 && VehicleInfo[i][vehModel] == 468 || VehicleInfo[i][vehGroup] == 8 && VehicleInfo[i][vehModel] == 470) {
			VehicleInfo[i][vehCarID] = CreateVehicle(VehicleInfo[i][vehModel], VehicleInfo[i][vehPosX], VehicleInfo[i][vehPosY], VehicleInfo[i][vehPosZ], VehicleInfo[i][vehRotation], VehicleInfo[i][vehColor1], VehicleInfo[i][vehColor2], 1800, 1);
		}
		else {
			VehicleInfo[i][vehCarID] = CreateVehicle(VehicleInfo[i][vehModel], VehicleInfo[i][vehPosX], VehicleInfo[i][vehPosY], VehicleInfo[i][vehPosZ], VehicleInfo[i][vehRotation], VehicleInfo[i][vehColor1], VehicleInfo[i][vehColor2], 1800);
		}
		if(VehicleInfo[i][vehGroup] == 0) {
			format(str,sizeof(str),"%d",i+1);
			SetVehicleNumberPlate(VehicleInfo[i][vehCarID],str);
		}
		else if(VehicleInfo[i][vehGroup] > 0) {
			if(VehicleInfo[i][vehGroup] > 9) {
				format(str,sizeof(str),"F%d %d",VehicleInfo[i][vehGroup],i+1);
				SetVehicleNumberPlate(VehicleInfo[i][vehCarID],str);
			}
			else if(VehicleInfo[i][vehGroup] < 10) {
				format(str,sizeof(str),"F0%d %d",VehicleInfo[i][vehGroup],i+1);
				SetVehicleNumberPlate(VehicleInfo[i][vehCarID],str);
			}
		}
		if(VehicleInfo[i][vehGroup] == 13) {
			if(VehicleInfo[i][vehModel] != 438) {
				new taxiobj = CreateObject(19308, 0.00000, 0.00000, 0.00000,0.00000, 0.00000, 0.00000);
				AttachObjectToVehicle(taxiobj, VehicleInfo[i][vehCarID], 0.000000, -0.249999, 0.949999, 0.000000, 0.000001, 90.449951);
			}
		}
		if(VehicleInfo[i][vehGroup] == 8 || VehicleInfo[i][vehGroup] == 2 || VehicleInfo[i][vehGroup] == 1) {
			if(VehicleInfo[i][vehModel] == 411) {
				object = CreateObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
				AttachObjectToVehicle(object, VehicleInfo[i][vehCarID],  0.010000, -0.060000, 0.689999, 0.000000, 0.000000, 0.000000);
				new policecar = CreateObject(19327, -2597.0762, -2638.4270, -5.3536, -87.6999, 90.4001, -87.1805);
				SetObjectMaterialText(policecar, "POLICE", 0, OBJECT_MATERIAL_SIZE_256x128, "Arial", 40, 1, -16777216, 0, 1);
				AttachObjectToVehicle(policecar, VehicleInfo[i][vehCarID], 0.000000, -1.984998, 0.229999, -85.424964, 0.000000, 0.000000);
			}
		}
	}
	printf("%d server vehicles loaded.", Vehicless);
	return 1;
}
case DIALOG_SAVEVEHICLE: {
			if(response) {
				if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to be in a vehicle to save it.");
				new Float:vPos[4],strquery[160],i;
				GetVehiclePos(vehicleid, vPos[0], vPos[1], vPos[2]);
			    GetVehicleZAngle(vehicleid, vPos[3]);
			    print("1 - savevehicle");
				format(strquery, sizeof(strquery), "INSERT INTO `vehicles` (`Model`, `PosX`, `PosY`, `PosZ`, `Rotation`) VALUES ('%d', '%f', '%f', '%f', '%f')", GetVehicleModel(vehicleid), vPos[0], vPos[1], vPos[2], vPos[3]);
			    new Cache: ab = mysql_query(SQL, strquery);
				i = cache_insert_id();
				cache_delete(ab);

				VehicleInfo[i][vehModel] = GetVehicleModel(GetPlayerVehicleID(playerid));
				VehicleInfo[i][vehPosX] = vPos[0];
				VehicleInfo[i][vehPosY] = vPos[1];
				VehicleInfo[i][vehPosZ] = vPos[2];
				VehicleInfo[i][vehRotation] = vPos[3];
				VehicleInfo[i][vehGroup] = 0;
				VehicleInfo[i][vehRank] = 0;
				VehicleInfo[i][vehCarID] = GetPlayerVehicleID(playerid);
				for(new x = 0; x < MAX_VEHICLES; x++)
				{
			    	if(Carspawn[x] == GetPlayerVehicleID(playerid))
					{
			    	    Carspawn[x] = 0;
			    	}
			    }
				VehicleInfo[i][vehCarID] = GetPlayerVehicleID(playerid);
				Vehicless++;
				format(strquery, sizeof(strquery), "The vehicle %d was successfully inserted in database. (db: %d)", VehicleInfo[i][vehCarID], VehicleInfo[i][vehCarIDD]);
				SCM(playerid, COLOR_GREY, strquery);
				print("2 - savevehicle");
			}
		}
                                                  
// ALL VEHICLES
enum vehInfo {
	vehModel,
	vehColor1,
	vehColor2,
	vehGroup,
	vehRank,
	vehCarID,
	vehCarIDD,
	Float:vehPosX,
	Float:vehPosY,
	Float:vehPosZ,
	Float:vehRotation
};
new VehicleInfo[1000][vehInfo];

 

Cand folosesc o comanda (Ex: /vcolor, /vgroup, /vrank etc.) nu se actualizeaza in baza de date. De la ce poate fi problema?

Arata comenzile /vcolor, /vgroup, /vrank

Link to comment
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.