Dynamic vehicle system help
#1

Hi, i wanted to add a dynamic vehicle system (add them with a cmd) but i have a little problem, the saved file is empty and nameless :
Quote:

ModelID = 0
Color1 = 0
Color2 = 0
ParkX = 0.000000
ParkY = 0.000000
ParkZ = 0.000000
ParkAng = 0.000000
Plate =

Here is the cmd for creating the vehicle:
Quote:

CMD:creervoiture(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new model,voitureid,couleura1,couleura2,plaque,Float ,Float:y,Float:z,Float:angle;
if(sscanf(params, "iiis[32]",model,couleura1,couleura2,plaque)) return SendClientMessage(playerid, COLOR_RED, "Usage: /creervoiture [model] [couleur1] [couleur2] [plaque]");
GetPlayerPos(playerid, x, y , z);
GetPlayerFacingAngle(playerid, angle);
voitureid = AddStaticVehicleEx(model, x, y, z, angle, couleura1, couleura2, 300);
model = gVehicleStats[voitureid][ModelID];
couleura1 = gVehicleStats[voitureid][Color1];
couleura2 = gVehicleStats[voitureid][Color2];
x = gVehicleStats[voitureid][ParkX];
y = gVehicleStats[voitureid][ParkY];
z = gVehicleStats[voitureid][ParkZ];
angle = gVehicleStats[voitureid][ParkAng];
plaque = gVehicleStats[voitureid][Plate];
SaveVehicle(voitureid);
}
else SendClientMessage(playerid, COLOR_RED, "Vous n'кtes pas un admin!");
return 1;
}

And here is the saving part
Quote:

stock SaveVehicle(i)
{
new path[32];
if(gVehicleStats[i][FileID] == 999)
{
gVehicleStats[i][FileID] = GetAvailableFileID();
}
format(path, sizeof(path), "Vehicles/%s.ini", gVehicleStats[i][FileID]);
new INI:handle = INI_Open(path);
INI_WriteInt(handle,"ModelID", gVehicleStats[i][ModelID]);
INI_WriteInt(handle,"Color1", gVehicleStats[i][Color1]);
INI_WriteInt(handle,"Color2", gVehicleStats[i][Color2]);
INI_WriteFloat(handle,"ParkX", gVehicleStats[i][ParkX]);
INI_WriteFloat(handle,"ParkY", gVehicleStats[i][ParkY]);
INI_WriteFloat(handle,"ParkZ", gVehicleStats[i][ParkZ]);
INI_WriteFloat(handle,"ParkAng", gVehicleStats[i][ParkAng]);
INI_WriteString(handle,"Plate", gVehicleStats[i][Plate]);
INI_Close(handle);
}

How to fix it please ?
Ps: Sorry for my english
Reply
#2

Reverse all these

x = gVehicleStats[voitureid][ParkX];
y = gVehicleStats[voitureid][ParkY];
z = gVehicleStats[voitureid][ParkZ];

to

gVehicleStats[voitureid][ParkX] = x;
gVehicleStats[voitureid][ParkY] = y;
gVehicleStats[voitureid][ParkZ] = z;
Reply
#3

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Reverse all these

x = gVehicleStats[voitureid][ParkX];
y = gVehicleStats[voitureid][ParkY];
z = gVehicleStats[voitureid][ParkZ];

to

gVehicleStats[voitureid][ParkX] = x;
gVehicleStats[voitureid][ParkY] = y;
gVehicleStats[voitureid][ParkZ] = z;
The saved file isn't empty anymore
Quote:

ModelID = 462
Color1 = 1
Color2 = 0
ParkX = -1998.803955
ParkY = 92.413574
ParkZ = 27.687500
ParkAng = 86.866607
Plate = A

but it's still nameless, can you please tell me how to fix it ? Thanks
EDIT: Here is GetAviableFileID:
Quote:

stock GetAvailableFileID()
{
new path[32];

for(new i; i<MAX_VEHICLES; i++)
{
format(path, sizeof(path), "Vehicles/%s.ini", i);
if(!fexist(path))
{
return i;
}
}
return 0;
}

Reply
#4

Bump ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)