Buy the vehicle the player sit in.
#1

Hi, I've been trying to fix this but unfortunately without success...
I want to change this so insted of get in a vehicle, buy it and it spawns a new of same model I want it to be like this.
You get in the vehicle, buy it and then THAT vehicle becomes yours. Not spawning some other or anything like that. The exact same vehicle you get in and buy becomes yours. How can I do this?
pawn Код:
else if(strcmp(x_nr,"buy",true) == 0)
            {
                new car = 396;
                new model = GetVehicleModel(idcar);
                if(IsASalesVehicle(idcar))
                {
                    if(PlayerInfo[playerid][pLevel] < 3)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "You need to be level 3 to buy a vehicle!");
                        return 1;
                    }
                    if(PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999 || PlayerInfo[playerid][pPcarkey3] == 9999) { }
                    else return SendClientMessage(playerid, COLOR_GREY,"* You already own three cars!");
                    if(GetPlayerMoney(playerid) >= GetVehiclePrice(idcar))
                    {
                        if(PlayerInfo[playerid][pCarLic] == 1)
                        {
                            for(new h = 396; h < sizeof(CarInfo); h++)
                            {
                                if(CarInfo[h][cOwned] == 0)
                                {
                                    car = h;
                                    h = 9999;
                                }
                            }
                            format(string, sizeof(string),"LARP/Vehicles/%d.ini",car)
                            dini_Create(string);
                           
                            if(PlayerInfo[playerid][pPcarkey] == 9999) { PlayerInfo[playerid][pPcarkey] = car; }
                            else if(PlayerInfo[playerid][pPcarkey2] == 9999) { PlayerInfo[playerid][pPcarkey2] = car; }
                            else if(PlayerInfo[playerid][pPcarkey3] == 9999) { PlayerInfo[playerid][pPcarkey3] = car; }
                            else { return 1; }
                            CarInfo[car][cOwned] = 1;
                            strmid(CarInfo[car][cOwner], sendername, 0, strlen(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(playerid, COLOR_YELLOW2, "Your Aircraft has been deliveried to Las Venturas Airport, you can get it there!");
                                SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
                                SendClientMessage(playerid, COLOR_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!", 5000, 3);
                            }
                            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(playerid, COLOR_YELLOW2, "Your Boat has been deliveried to San Fierro Docks, you can get it there!");
                                SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
                                SendClientMessage(playerid, COLOR_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!", 5000, 3);
                            }
                            else
                            {
                                CarInfo[car][cLocationx] = -1589.2644;
                                CarInfo[car][cLocationy] = 106.9119;
                                CarInfo[car][cLocationz] = 3.5495;
                                CarInfo[car][cAngle] = 317.1649;
                                SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle has been deliveried to San Fierro Docks, you can get it there!");
                                SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
                                SendClientMessage(playerid, COLOR_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!", 5000, 3);
                            }
                            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] = AddStaticVehicleEx(CarInfo[car][cModel],CarInfo[car][cLocationx],CarInfo[car][cLocationy],CarInfo[car][cLocationz],90.0,1,1,-1);
                            PlayerPlayMusic(playerid);
                            SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
                            SendClientMessage(playerid, COLOR_GRAD2, "Type /vehiclehelp to view the vehicle manual!");
                            gEngine[playerid] = 0;
                            engineOn[GetPlayerVehicleID(playerid)] = false;
                            SendClientMessage(playerid, COLOR_GREY, "Remember to set the new Security Code of the Car (/v setcode)!");
                            new pass[24];
                            format(pass, sizeof(pass),"%d%d%d",random(9),random(9),random(9));
                            CarInfo[car][cCode] = strval(pass);
                            OnPropUpdate(4,car);
                            OnPlayerUpdateEx(playerid);
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "* For security reasons, a Driving License is needed to buy a car!");
                            return 1;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "  You don't have enough cash with you ! ");
                        return 1;
                    }
                }
            }
Reply
#2

PHP код:
else if(strcmp(x_nr,"buy",true) == 0)
            {
                new 
car 396;
                new 
model GetVehicleModel(idcar);
                if(
IsASalesVehicle(idcar))
                {
                    if(
PlayerInfo[playerid][pLevel] < 3)
                    {
                        
SendClientMessage(playeridCOLOR_GREY"You need to be level 3 to buy a vehicle!");
                        return 
1;
                    }
                    if(
PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999 || PlayerInfo[playerid][pPcarkey3] == 9999) { }
                    else return 
SendClientMessage(playeridCOLOR_GREY,"* You already own three cars!");
                    if(
GetPlayerMoney(playerid) >= GetVehiclePrice(idcar))
                    {
                        if(
PlayerInfo[playerid][pCarLic] == 1)
                        {
                            for(new 
396sizeof(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][pPcarkey] = car; }
                            else if(
PlayerInfo[playerid][pPcarkey2] == 9999) { PlayerInfo[playerid][pPcarkey2] = car; }
                            else if(
PlayerInfo[playerid][pPcarkey3] == 9999) { PlayerInfo[playerid][pPcarkey3] = car; }
                            else { return 
1; }
                            
car GetPlayerVehicleID(playerid);
                            
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);
                            
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 (/v setcode)!");
                            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;
                    }
                } 
Try with this code, it should works.
Reply
#3

Nope, didn't work
Reply
#4

bump
Reply
#5

bump
Reply
#6

I suggest not using a gf script.
Reply
#7

Quote:
Originally Posted by Luis-
Посмотреть сообщение
I suggest not using a gf script.
I'm not...
Reply
#8

Since you know how to script, I'll just show you the way:

1. Upon typing that /blabla buy, get that vehicle ID and save it into a variable, here you can make a fail-safe checking for that vehicle ID like if that vehicle is purchased by someone else, or if it is the state's vehicle, you cannot buy it, etc.

2. If those checks have been passed, save the vehicle ID in the user account file such as "MyCar = car id". From this point, you can make it so like whenever someone else besides the owner enters this car id, it will eject the player or whatever. Basically yeah, from that point on you can script more features for it.

TIP: If you want to do this, make sure you keep track of the vehicle IDs in your script and that new vehicles IDs are added after the last one in your script, every time, or it will mess up the whole car ownership system.
Reply
#9

Quote:
Originally Posted by Don_Cage
Посмотреть сообщение
I'm not...
If I remember correctly, LARP is a gf edit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)