MySQL and CreateCar Help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL and CreateCar Help (
/showthread.php?tid=616430)
MySQL and CreateCar Help -
HidroDF - 04.09.2016
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?