Can Saving
#1

When someone buy car, it have it. But if server restarts or he come after some time, he anymore dont have that car.

PHP код:
 else if(strcmp(x_nr,"buy",true) == 0)
            {
                new 
car 1;
                new 
model GetVehicleModel(idcar);
                if(
IsASalesVehicle(idcar))
                {
                    if(
PlayerInfo[playerid][pLevel] < 2)
                    {
                        
SendClientMessage(playeridCOLOR_GREY"You need to be level 2 to buy a vehicle!");
                        return 
1;
                    }
                    if(
PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999) { }
                    else return 
SendClientMessage(playeridCOLOR_GREY,"* You already own Two cars!");
                    if(
GetPlayerMoney(playerid) >= GetVehiclePrice(idcar))
                    {
                        if(
PlayerInfo[playerid][pCarLic] == 1)
                        {
                            for(new 
1sizeof(CarInfo); h++)
                            {
                                if(
CarInfo[h][cOwned] == 0)
                                {
                                    
car h;
                                    
9999;
                                }
                            }
                            
format(stringsizeof(string),"LARP/Vehicles/%d.ini",car)
                            
dini_Create(string);
                            
                            if(
PlayerInfo[playerid][pPcarkey] != 9999) { PlayerInfo[playerid][pPcarkey2] = car; }
                            else { 
PlayerInfo[playerid][pPcarkey] = car; }
                            
CarInfo[car][cOwned] = 1;
                            
strmid(CarInfo[car][cOwner], sendername0strlen(sendername), 999);
                            
SafeGivePlayerMoney(playerid,-GetVehiclePrice(idcar));
                            if(
IsModelAPlane(idcar) || IsModelAHeli(idcar))
                            {
                                
CarInfo[car][cLocationx] = 1432.6451;
                                
CarInfo[car][cLocationy] = 1378.7216;
                                
CarInfo[car][cLocationz] = 11.5507;
                                
CarInfo[car][cAngle] = 359.2072;
                                
SendClientMessage(playeridCOLOR_YELLOW2"Your Aircraft has been deliveried to Las Venturas Airport, you can get it there!");
                                
SendClientMessage(playeridCOLOR_YELLOW2"Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
                                
SendClientMessage(playeridCOLOR_NICERED"REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
                                
GameTextForPlayer(playerid"~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~Las Venturas Airport!"50003);
                            }
                            else if(
IsModelABoat(idcar))
                            {
                                
CarInfo[car][cLocationx] = -1568.9614;
                                
CarInfo[car][cLocationy] = 169.0118;
                                
CarInfo[car][cLocationz] = -0.6016;
                                
CarInfo[car][cAngle] = 208.7506;
                                
SendClientMessage(playeridCOLOR_YELLOW2"Your Boat has been deliveried to San Fierro Docks, you can get it there!");
                                
SendClientMessage(playeridCOLOR_YELLOW2"Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
                                
SendClientMessage(playeridCOLOR_NICERED"REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
                                
GameTextForPlayer(playerid"~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~San Fierro Docks!"50003);
                            }
                            else
                            {
                                
CarInfo[car][cLocationx] = -1589.2644;
                                
CarInfo[car][cLocationy] = 106.9119;
                                
CarInfo[car][cLocationz] = 3.5495;
                                
CarInfo[car][cAngle] = 317.1649;
                                
SendClientMessage(playeridCOLOR_YELLOW2"Your vehicle has been deliveried to San Fierro Docks, you can get it there!");
                                
SendClientMessage(playeridCOLOR_YELLOW2"Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
                                
SendClientMessage(playeridCOLOR_NICERED"REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
                                
GameTextForPlayer(playerid"~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~San Fierro Docks!"50003);
                            }
                            
CarInfo[car][cModel] = model;
                            
CarInfo[car][cVirWorld] = 0;
                            
CarInfo[car][cPaintjob] = 999;
                            
                            
CarInfo[car][cColorOne] = 1;
                            
CarInfo[car][cColorTwo] = 1;
                            
                            
CarInfo[car][cComponent0] = 0;
                            
CarInfo[car][cComponent1] = 0;
                            
CarInfo[car][cComponent2] = 0;
                            
CarInfo[car][cComponent3] = 0;
                            
CarInfo[car][cComponent4] = 0;
                            
CarInfo[car][cComponent5] = 0;
                            
CarInfo[car][cComponent6] = 0;
                            
CarInfo[car][cComponent7] = 0;
                            
CarInfo[car][cComponent8] = 0;
                            
CarInfo[car][cComponent9] = 0;
                            
CarInfo[car][cComponent10] = 0;
                            
CarInfo[car][cComponent11] = 0;
                            
CarInfo[car][cComponent12] = 0;
                            
CarInfo[car][cComponent13] = 0;
                            
                            
DestroyVehicle(car);
                            
ownedcar[car] = CreateVehicle(CarInfo[car][cModel],CarInfo[car][cLocationx],CarInfo[car][cLocationy],CarInfo[car][cLocationz],90.0,1,1,30000);
                            
PlayerPlayMusic(playerid);
                            
SendClientMessage(playeridCOLOR_GRAD2"Congratulations on your new purchase!");
                            
SendClientMessage(playeridCOLOR_GRAD2"Type /vehiclehelp to view the vehicle manual!");
                            
gEngine[playerid] = 0;
                            
engineOn[GetPlayerVehicleID(playerid)] = false;
                            
SendClientMessage(playeridCOLOR_GREY"Remember to set the new Security Code of the Car!");
                            new 
pass[24];
                            
format(passsizeof(pass),"%d%d%d",random(9),random(9),random(9));
                            
CarInfo[car][cCode] = strval(pass);
                            
OnPropUpdate(4,car);
                            
OnPlayerUpdateEx(playerid);
                        }
                        else
                        {
                            
SendClientMessage(playeridCOLOR_WHITE"* For security reasons, a Driving License is needed to buy a car!");
                            return 
1;
                        }
                    }
                    else
                    {
                        
SendClientMessage(playeridCOLOR_GREY"  You don't have enough cash with you ! ");
                        return 
1;
                    }
                }
            } 
Code.

For some the cars are saving for some no. If he write /findcar it shows it it is Army HQ and it have NG patrol car not his Uranus or smth.

And LoadCar lines
PHP код:
public LoadCar()
{
    new 
file[26];
    for(new 
idx 1idx sizeof(CarInfo) ; idx++)
    {
            
format(filesizeof(file),"LARP/Vehicles/%d.ini"idx);
             
CarInfo[idx][cModel] = dini_Int(file,"Model");
            
CarInfo[idx][cLocationx] = dini_Float(file,"Location_X");
            
CarInfo[idx][cLocationy] = dini_Float(file,"Location_Y");
            
CarInfo[idx][cLocationz] = dini_Float(file,"Location_Z");
            
CarInfo[idx][cAngle] = dini_Float(file,"Angle");
            
CarInfo[idx][cColorOne] = dini_Int(file,"Color_1");
            
CarInfo[idx][cColorTwo] = dini_Int(file,"Color_2");
            
strmid(CarInfo[idx][cOwner], dini_Get(file,"Owner"), 0strlen(dini_Get(file,"Owner")), 255);
            
CarInfo[idx][cOwned] = dini_Int(file,"Owned");
            
strmid(CarInfo[idx][cPlate], dini_Get(file,"Plate"), 0strlen(dini_Get(file,"Plate")), 255);
            
CarInfo[idx][cLock] = dini_Int(file,"Locked");
            
CarInfo[idx][cID] = dini_Int(file,"ID");
            
CarInfo[idx][cPaintjob] = dini_Int(file,"Paintjob");
            
CarInfo[idx][cVirWorld] = dini_Int(file,"VirtualWorld");
            
CarInfo[idx][cUnused] = dini_Int(file,"Unused");
               
CarInfo[idx][cComponent0] = dini_Int(file,"Component0");
               
CarInfo[idx][cComponent1] = dini_Int(file,"Component1");
            
CarInfo[idx][cComponent2] = dini_Int(file,"Component2");
            
CarInfo[idx][cComponent3] = dini_Int(file,"Component3");
            
CarInfo[idx][cComponent4] = dini_Int(file,"Component4");
            
CarInfo[idx][cComponent5] = dini_Int(file,"Component5");
            
CarInfo[idx][cComponent6] = dini_Int(file,"Component6");
            
CarInfo[idx][cComponent7] = dini_Int(file,"Component7");
            
CarInfo[idx][cComponent8] = dini_Int(file,"Component8");
            
CarInfo[idx][cComponent9] = dini_Int(file,"Component9");
            
CarInfo[idx][cComponent10] = dini_Int(file,"Component10");
            
CarInfo[idx][cComponent11] = dini_Int(file,"Component11");
            
CarInfo[idx][cComponent12] = dini_Int(file,"Component12");
            
CarInfo[idx][cComponent13] = dini_Int(file,"Component13");
            
CarInfo[idx][cCode] = dini_Int(file,"SecurityCode");
            
CarInfo[idx][cParkTicket] = dini_Int(file,"TicketPrice");
            
strmid(CarInfo[idx][cTicketer], dini_Get(file,"Officer"), 0strlen(dini_Get(file,"Officer")), 255);
            
CarInfo[idx][cTrunkGun1] = dini_Int(file,"Gun1");
            
CarInfo[idx][cTrunkAmmo1] = dini_Int(file,"Ammo1");
            
CarInfo[idx][cTrunkGun2] = dini_Int(file,"Gun2");
            
CarInfo[idx][cTrunkAmmo2] = dini_Int(file,"Ammo2");
            
CarInfo[idx][cTrunkGun3] = dini_Int(file,"Gun3");
            
CarInfo[idx][cTrunkAmmo3] = dini_Int(file,"Ammo3");
            
CarInfo[idx][cTrunkGun4] = dini_Int(file,"Gun4");
            
CarInfo[idx][cTrunkAmmo4] = dini_Int(file,"Ammo4");
            
CarInfo[idx][cTrunkGun5] = dini_Int(file,"Gun5");
            
CarInfo[idx][cTrunkAmmo5] = dini_Int(file,"Ammo5");
            
CarInfo[idx][cTrunkGun6] = dini_Int(file,"Gun6");
            
CarInfo[idx][cTrunkAmmo6] = dini_Int(file,"Ammo6");
            
CarInfo[idx][cTrunkGun7] = dini_Int(file,"Gun7");
            
CarInfo[idx][cTrunkAmmo7] = dini_Int(file,"Ammo7");
            
CarInfo[idx][cTrunkGun8] = dini_Int(file,"Gun8");
            
CarInfo[idx][cTrunkAmmo8] = dini_Int(file,"Ammo8");
            
CarInfo[idx][cTrunkGun9] = dini_Int(file,"Gun9");
            
CarInfo[idx][cTrunkAmmo9] = dini_Int(file,"Ammo9");
            
CarInfo[idx][cTrunkGun10] = dini_Int(file,"Gun10");
            
CarInfo[idx][cTrunkAmmo10] = dini_Int(file,"Ammo10");
            
CarInfo[idx][cTrunkGun11] = dini_Int(file,"Gun11");
            
CarInfo[idx][cTrunkAmmo11] = dini_Int(file,"Ammo11");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)