SA-MP Forums Archive
CreateVehicle problem - 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: CreateVehicle problem (/showthread.php?tid=634513)



CreateVehicle problem - Kraeror - 20.05.2017

Hello, I have problem with creating a vehicle. When I'm trying to create a vehicle, it creates me two vehicles.
Here is my code:
Quote:

new vehicleid = CreateVehicle(VehicleInfo[Model], VehicleInfo[posX], VehicleInfo[posY], VehicleInfo[posZ], VehicleInfo[posA], VehicleInfo[Color1], VehicleInfo[Color2], 600);
PutPlayerInVehicle(playerid, vehicleid, 0);




Re: CreateVehicle problem - mjay768 - 20.05.2017

Please post code associated with this. Like where this is placed in your script.


Re: CreateVehicle problem - Kraeror - 20.05.2017

Here you are:
Quote:

enum VehicleData
{
VehID,
Model,
Float: posX,
Float: posY,
Float: posZ,
Float: posA,
Color1,
Color2,
Float:World
}
new VehicleInfo[VehicleData];

There is a save location to the vehicle (OnPlayerDisconnect):
Quote:

new vehicleid = GetPlayerVehicleID(playerid);
VehicleInfo[Model] = GetVehicleModel(vehicleid);
GetVehiclePos(vehicleid, VehicleInfo[posX], VehicleInfo[posY], VehicleInfo[posZ]);
GetVehicleZAngle(vehicleid, VehicleInfo[posA]);
GetVehicleColor(vehicleid, VehicleInfo[Color1], VehicleInfo[Color2]);
VehicleInfo[World] = GetVehicleVirtualWorld(vehicleid);
dini_IntSet(string, "VehModel", VehicleInfo[Model]);
dini_FloatSet(string, "Position(X)", PlayerInfo[playerid][posX]);
dini_FloatSet(string, "Position(Y)", PlayerInfo[playerid][posY]);
dini_FloatSet(string, "Position(Z)", PlayerInfo[playerid][posZ]);
dini_FloatSet(string, "FacingAngle", PlayerInfo[playerid][posA]);
dini_FloatSet(string, "VehPosition(X)", VehicleInfo[posX]);
dini_FloatSet(string, "VehPosition(Y)", VehicleInfo[posY]);
dini_FloatSet(string, "VehPosition(Z)", VehicleInfo[posZ]);
dini_FloatSet(string, "VehPosition(A)", VehicleInfo[posA]);
dini_IntSet(string, "VehColor1", VehicleInfo[Color1]);
dini_IntSet(string, "VehColor2", VehicleInfo[Color2]);
dini_FloatSet(string, "VehWorld", VehicleInfo[World]);

There is a loading (OnPlayerConnect):
Quote:

VehicleInfo[Model] = dini_Int(string2, "VehModel");
PlayerInfo[playerid][posX] = dini_Float(string2, "Position(X)");
PlayerInfo[playerid][posY] = dini_Float(string2, "Position(Y)");
PlayerInfo[playerid][posZ] = dini_Float(string2, "Position(Z)");
PlayerInfo[playerid][posA] = dini_Float(string2, "FacingAngle");
VehicleInfo[posX] = dini_Float(string2, "VehPosition(X)");
VehicleInfo[posY] = dini_Float(string2, "VehPosition(Y)");
VehicleInfo[posZ] = dini_Float(string2, "VehPosition(Z)");
VehicleInfo[posA] = dini_Float(string2, "VehPosition(A)");
VehicleInfo[Color1] = dini_Int(string2, "VehColor1");
VehicleInfo[Color2] = dini_Int(string2, "VehColor2");
VehicleInfo[World] = dini_Float(string2, "VehWorld");