Vehicle Insurance System
#1

Hello , i tried to make Vehicle insurance system . But i am facing some bugs . As i don't have any idea of how to make it . Here is the my code .
PHP код:
new Insurancetimer;
new 
VehicleInsurance[MAX_DVEHICLES]; 
OnGamemodeInit()
PHP код:
Insurancetimer SetTimer("Destroycar"100true); 
Public function
PHP код:
forward Destroycar(playerid);
public 
Destroycar(playerid)
{
    new 
vehicleid GetPVarInt(playerid"DialogValue1");
    new 
id GetVehicleID(vehicleid);
        if(
GetPlayerVehicleAccess(playeridid) < 2// This will detect whether this vehicle is owned by player or not.
        
{
              
SendClientMessage(playerid, -"You don't have keys of this vehicle");
        }
     if(
gettime() > Insurancetimer)
    {
                
SendClientMessage(playerid, -1"Insurance ended");
                
InsuranceTime[vehicleid] = 0;
                
DestroyVehicle(VehicleID[vehicleid]);
    }
    
//return 1;

When player try to buy vehicle
PHP код:
if(GetPlayerVehicles(playerid) >= MAX_PLAYER_VEHICLES)
            {
                
ShowErrorDialog(playerid"You can't buy any more vehicles! Max: " #MAX_PLAYER_VEHICLES );
                
return 1;
            }
            new 
id GetPVarInt(playerid"DialogValue1");
            if(
GetPlayerMoney(playerid) < VehicleValue[id])
            {
                
ShowErrorDialog(playerid"You don't have enough money to buy this vehicle!");
                return 
1;
            }
            new 
freeid GetFreeVehicleID();
            if(!
freeid)
            {
                
ShowErrorDialog(playerid"Vehicle dealership is out of stock!");
                return 
1;
            }
            
GivePlayerMoney(playerid, -VehicleValue[id]);
            new 
dealerid strval(VehicleOwner[id]);
            
VehicleCreated[freeid] = VEHICLE_PLAYER;
            
VehicleModel[freeid] = VehicleModel[id];
            
VehiclePos[freeid] = DealershipPos[dealerid];
            
VehicleColor[freeid] = VehicleColor[id];
            
VehicleInterior[freeid] = VehicleInterior[id];
            
VehicleWorld[freeid] = VehicleWorld[id];
            
VehicleValue[freeid] = VehicleValue[id];
            
GetPlayerName(playeridVehicleOwner[freeid], sizeof(VehicleOwner[]));
            
VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
            for(new 
d=0sizeof(VehicleTrunk[]); d++)
            {
                
VehicleTrunk[freeid][d][0] = 0;
                
VehicleTrunk[freeid][d][1] = 0;
            }
            for(new 
d=0sizeof(VehicleMods[]); d++)
            {
                
VehicleMods[freeid][d] = 0;
            }
            
VehiclePaintjob[freeid] = 255;
            
VehicleLock[freeid] = 0;
            
VehicleAlarm[freeid] = 0;
            
VehicleInsurance[freeid] = 1;
            
UpdateVehicle(freeid0);
            
SaveVehicle(freeid);
            new 
msg[128];
            
format(msgsizeof(msg), "You have bought this vehicle for $%d"VehicleValue[id]);
            
SendClientMessage(playeridCOLOR_WHITEmsg); 
When Player Try to insure his vehicle by Clicking on list item in dialogbox.
PHP код:
new vehicleid GetPVarInt(playerid"DialogValue1");
                    if(
GetPlayerVehicleAccess(playeridvehicleid) < 2)
                    {
                        
ShowErrorDialog(playerid"You are not the owner of this vehicle!");
                        return 
1;
                    }
                    
SendClientMessage(playeridCOLOR_WHITE"You vehicle insurance renewed.");
                    
InsuranceTime[vehicleid] = gettime() + 60*60*24*2;
                    
UpdateVehicle(vehicleid1);
                    
PutPlayerInVehicle(playeridVehicleID[vehicleid], 0);
                    
SaveVehicle(vehicleid); 
That's all my code . As This look clearly make sense that it won't work . But i don't have any idea what to do . I want to make a system that on vehicle insurance expiration The Vehicle Destroy . and He can renew his insurance again by clicking on list item in dialog box . When code is the last one.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)