Vehicle ownership?
#1

Hi. I have literally spent the last 4 hours trying to create a vehicle ownership system that saves a vehicle you buy at a dealership to your account.

I have the vInfo enum, savevehicles and loadvehicles to a point in which im not sure how i can make it save unique owners. It should also load and spawn the vehicle once the owner has logged in.

Could anyone tell me what i am forgetting please? I have SaveVehicles & LoadVehicles in OnGameModeInit and OnGameModeExit too.

Thanks to anyone that could help in any way.

my vehicle info enum
pawn Код:
enum vInfo
{
    vId,
    vModel[24],
    bool:vOwned,
    vOwner[MAX_PLAYER_NAME],
    vPrice,
    bool:vParked,
    bool:vSpawned,
    bool:vLocked,
    Float:vLastX,
    Float:vLastY,
    Float:vLastZ,
    Float:vLastA,
    Float:vHealth,
    vInt,
    vVW
}
new VehicleInfo[MAX_PLAYERS][vInfo];
my save vehicles function
pawn Код:
forward SaveVehicles(vid)
public SaveVehicles(vid)
{
    new fileV[40];
    format(fileV, sizeof(fileV), VPATH, vid);
    new INI:File = INI_Open(UserVPath(vid));
    INI_SetTag(File,"vehicledata");
    INI_WriteInt(File,"Id", VehicleInfo[vid][vId]);
    INI_WriteString(File,"Model", VehicleInfo[vid][vModel]);
    INI_WriteBool(File, "Owned", VehicleInfo[vid][vOwned]);
    INI_WriteString(File,"Owner", VehicleInfo[vid][vOwner]);
    INI_WriteInt(File,"Price", VehicleInfo[vid][vPrice]);
    INI_WriteBool(File,"Parked", VehicleInfo[vid][vParked]);
    INI_WriteBool(File,"Spawned", VehicleInfo[vid][vSpawned]);
    INI_WriteBool(File,"Locked", VehicleInfo[vid][vLocked]);
    INI_WriteFloat(File,"LastX", VehicleInfo[vid][vLastX]);
    INI_WriteFloat(File,"LastY", VehicleInfo[vid][vLastY]);
    INI_WriteFloat(File,"LastZ", VehicleInfo[vid][vLastZ]);
    INI_WriteFloat(File,"LastA", VehicleInfo[vid][vLastA]);
    INI_WriteFloat(File,"Health", VehicleInfo[vid][vHealth]);
    INI_WriteInt(File,"Interior", VehicleInfo[vid][vInt]);
    INI_WriteInt(File,"VirtualWorld", VehicleInfo[vid][vVW]);
    INI_Close(File);
    return 1;
}
my load vehicles function
pawn Код:
forward LoadVehicles(vid,name[],value[]);
public LoadVehicles(vid, name[], value[])
{
    INI_Int("Id", VehicleInfo[vid][vId]);
    INI_String("Model", VehicleInfo[vid][vModel], 30);
    INI_Bool("Owned", VehicleInfo[vid][vOwned]);
    INI_String("Owner", VehicleInfo[vid][vOwner],MAX_PLAYER_NAME);
    INI_Int("Price", VehicleInfo[vid][vPrice]);
    INI_Bool("Parked", VehicleInfo[vid][vParked]);
    INI_Bool("Spawned", VehicleInfo[vid][vSpawned]);
    INI_Bool("Locked", VehicleInfo[vid][vLocked]);
    INI_Float("LastX", VehicleInfo[vid][vLastX]);
    INI_Float("LastY", VehicleInfo[vid][vLastY]);
    INI_Float("LastZ", VehicleInfo[vid][vLastZ]);
    INI_Float("LastA", VehicleInfo[vid][vLastA]);
    INI_Float("Health", VehicleInfo[vid][vHealth]);
    INI_Int("Interior", VehicleInfo[vid][vInt]);
    INI_Int("VirtualWorld", VehicleInfo[vid][vVW]);
   
    //(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
    CreateVehicle(vid, VehicleInfo[vid][vLastX],VehicleInfo[vid][vLastY],VehicleInfo[vid][vLastZ],VehicleInfo[vid][vLastA], 1, 1, 50000000);
    return 1;
}
Part of my dialog in which you buy the vehicle.
pawn Код:
case DIALOG_VEHICLEBUY2DOOR:
        {
            new Float:x, Float:y, Float:z, Float:angle;
            x= 2135.0498;
            y= -1142.3728;
            z= 25.0758;
            angle = 71.6283;
            new price, vehid,vmodel[128],vowner[MAX_PLAYER_NAME];
           
            //vmodel= GetVehicleName(vid);
           
            if(!response) return 1;
            if(response)
            {
                switch(listitem)
                {
                    case 0://majestic
                    {
                        price = 2100;
                        //CreateVehicleEx(517,x,y,z,angle, 4,4,5000, vowner);/*,INI_Float(filename, "XSpawn")*/
                        CreateVehicle(517,x,y,z,angle,0,0,5000);
                        vehid = VehicleInfo[vehid][vId];
                        VehicleInfo[vehid][vOwner] = GetName(playerid);
                        VehicleInfo[vehid][vOwned] = true;
                        VehicleInfo[vehid][vLastX] = x;
                        VehicleInfo[vehid][vLastY] = y;
                        VehicleInfo[vehid][vLastZ] = z;
                        VehicleInfo[vehid][vLastA] = angle;
                        GivePlayerMoney(playerid, -price);
                        vmodel = GetVehicleName(vehid);
                       
                    }
                }
            }
        }
Reply


Messages In This Thread
Vehicle ownership? - by EiresJason - 06.04.2013, 18:51
Re: Vehicle ownership? - by MattyG - 06.04.2013, 19:02
Re: Vehicle ownership? - by EiresJason - 07.04.2013, 12:10

Forum Jump:


Users browsing this thread: 1 Guest(s)