i would show u a few coeds of a Veh OwnerShip System(This a few codes of mine)
My one saves vehicle components,colors,player numbers,locked,etc so i will not add that to compicate things !
pawn Код:
#define MAX_CARS 100
enum Car_Info
{
Model,
Price,
Float:CarX,
Float:CarY,
Float:CarZ,
Float:CarRot,
Locked,
ColorA,
ColorB,
};
new VehicleInfo[MAX_CARS][Car_Info];
//Laoding the car (this is a perse!)
forward LoadCar(playerid, name[], value[]);
public LoadCar(playerid, name[], value[])
{
if(!strcmp(name,"Model"))SetPVarInt(playerid,"Model",strval(value));
if(!strcmp(name,"Price"))SetPVarInt(playerid,"Price",strval(value));
if(!strcmp(name,"X"))SetPVarFloat(playerid,"X",strval(value));
if(!strcmp(name,"Y"))SetPVarFloat(playerid,"Y",strval(value));
if(!strcmp(name,"Z"))SetPVarFloat(playerid,"Z",strval(value));
if(!strcmp(name,"Rot"))SetPVarFloat(playerid,"Rot",strval(value));
if(!strcmp(name,"Locked"))SetPVarInt(playerid,"Locked",strval(value));
if(!strcmp(name,"ColorA"))SetPVarInt(playerid,"ColorA",strval(value));
if(!strcmp(name,"ColorB"))SetPVarInt(playerid,"ColorB",strval(value));
}
forward OnPlayerConnect(playerid);
public OnPlayerConnect(playerid)
{
//you will ahve to show the "file" 's directory
if(fexist(file))
{
VehicleInfo[playerid][Model] = GetPVarInt(playerid, "Model");
VehicleInfo[playerid][Price] = GetPVarInt(playerid, "Price");
VehicleInfo[playerid][CarX] = GetPVarFloat(playerid, "X");
VehicleInfo[playerid][CarY] = GetPVarFloat(playerid, "Y");
VehicleInfo[playerid][CarZ] = GetPVarFloat(playerid, "Z");
VehicleInfo[playerid][CarRot] = GetPVarFloat(playerid, "Rot");
VehicleInfo[playerid][ColorA] = GetPVarInt(playerid, "ColorA");
VehicleInfo[playerid][ColorB] = GetPVarInt(playerid, "ColorB");
}
//my custume Stock for saving the vehicle
stock SaveVehicle(playerid,ModelID,Float:X,Float:Y,Float:Z,Float:R,CarLocked,VehColorA,VehColorB)
{
new file[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"%s.txt",name);//directory name.path
if(fexist(file))
{
new INI:Acc = INI_Open(file);
INI_WriteInt(Acc,"Model", ModelID);
INI_WriteFloat(Acc,"X", X);
INI_WriteFloat(Acc,"Y", Y);
INI_WriteFloat(Acc,"Z", Z);
INI_WriteFloat(Acc,"Rot", R);
//INI_WriteInt(Acc,"Locked", CarLocked);
INI_WriteInt(Acc,"VehColorA", VehColorA);
INI_WriteInt(Acc,"VehColorB", VehColorB);
//INI_WriteInt(Acc,"VehicleFuel", FuelPercent[Vehicle[playerid]]);
INI_Close(Acc);
}else return false;
return 1;
}