MySQL and CreateCar Help
#1

Hello! I have the following code:

Код:
enum Vehicles
{
	ID,
	Plate[30 char],
	Model,
	Color1,
	Color2,
	Float:PosX,
	Float:PosY,
	Float:PosZ,
	Float:PosA,
	Text3D:NameLabel,
	VehicleID,
	Float:Health,
	bool:Created
}

new Vehicle[MAX_VEHICLES][Vehicules];
I can create cars. Let's imagine I create 5 cars. If I delete the car number 3, carid of 4 and 5 will be 3 and 4. How I can get the correct variables if the id has changed? For example, if I want to use the /respawncar.

Код:
CMD:respawncar(playerid, params[])
{
    new level = AdminCheck(playerid);
	if(level >= 1)
	{
		new id;
		if(sscanf(params, "d", id)) return SendClientMessage(playerid, -1, "{40D3FF}[SRV]: {FFFFFF}Use: /respawncar [carid]");
		if(IsVehicleEmpty(id) && Vehicle[VehicleIDX(id)][Stats] == 0)
		{
  			new Float:health;
   			GetVehicleHealth(id, health);
   			GuardarHealth(id, health);
			SetVehicleToRespawn(id);
			SetVehicleHealth(id, health);
			SetVehiclePos(id, Vehicle[id][PosX], Vehicle[id][PosY], Vehicle[id][PosZ]);
			new Playername[MAX_PLAYER_NAME];
			Playername = GetName(playerid);
			new astring[256];
			format(astring, sizeof(astring), "{E34B25}[ADM]: {FFFFFF}%s(%d) respawned ID: %d.", Playername, playerid, id);
			AdminsBroadCast(-1, astring);
			if(IsPlayerConnected(GetPlayerIdFromName(Vehicle[id][Owner])))
			{
				new mess[200];
				format(mess,sizeof(mess),"{40D3FF}[SRV]: {FFFFFF}%s has send your vehicle %s to yhe last saved park position.", Playername, GetVehicleName(Vehicle[id][Model]));
				SendClientMessage(GetPlayerIdFromName(Vehicle[id][Owner]), -1, mess);
			}
		}
	}
 	else
	{
		return 0;
	}
	return 1;
}
But with this code the car goes to another vehicle location because is getting X, Y, Z of the last vehicle inserted on the id. When I remove the car, I don't delete the variables and I know that the problem is that, but if I delete the variables (equalig them to 0), the car goes to 0,0,0. Any help?
Reply


Messages In This Thread
MySQL and CreateCar Help - by HidroDF - 04.09.2016, 18:56

Forum Jump:


Users browsing this thread: 1 Guest(s)