Buy VEH
#1

right I have these here as the vehicles
pawn Код:
//Dealerships
    GTFO1= AddStaticVehicle(473,461.6448,-1885.9976,1.4758,32.5020,56,53); // Digny boat dealership
    GTFO2= AddStaticVehicle(472,470.8299,-1878.3210,2.6988,353.8353,56,53); // coastguard boat dealership
    GTFO3= AddStaticVehicle(446,491.6731,-1877.9454,3.1793,76.7462,1,5); // squalo boat dealeership
    GTFO4= AddStaticVehicle(402,561.4337,-1290.1370,17.0799,41.6603,13,13); // buffalo GROTTI
    GTFO5= AddStaticVehicle(415,555.1501,-1290.0126,17.0185,40.6865,25,1); // cheetah GROTTI
    GTFO6= AddStaticVehicle(429,549.8007,-1290.4285,16.9289,37.1887,13,13); // Banshee GROTTI
    GTFO7= AddStaticVehicle(475,544.2843,-1290.4539,17.0473,35.2693,9,39); // Sabre GROTTI
    GTFO8= AddStaticVehicle(477,538.7817,-1289.9727,17.0001,35.3376,94,1); // ZR GROTTI
    GTFO9= AddStaticVehicle(558,564.8015,-1281.4299,16.8786,91.9030,116,1); // Uranus GROTTI
    GTFO10= AddStaticVehicle(559,563.1653,-1277.8361,16.8986,96.0121,58,8); // Jester GROTTI
    GTFO11= AddStaticVehicle(589,561.4285,-1273.7260,16.9003,97.6116,31,31); // Club GROTTI
    GTFO12= AddStaticVehicle(402,561.4044,-1269.1206,17.0739,99.9186,22,22); // Buffalo GROTTI
    GTFO13= AddStaticVehicle(420,1092.7970,-1247.9038,15.6066,0.0099,6,1); // Taxi PROFESSIONS
    GTFO14= AddStaticVehicle(408,1098.5225,-1247.9800,16.3772,2.3717,26,26); // Trashmaster PROFFESION
    GTFO15= AddStaticVehicle(431,1091.3983,-1193.0220,18.2704,90.3025,75,59); // Bus PROFFESSION
    GTFO16= AddStaticVehicle(433,1090.8722,-1199.4076,18.3366,271.9277,43,0); // 433 PROFFESSION
And I have
pawn Код:
new GTFO1;
new GTFO2;
new GTFO3;
new GTFO4;
new GTFO5;
new GTFO6;
new GTFO7;
new GTFO8;
new GTFO9;
new GTFO10;
new GTFO11;
new GTFO12;
new GTFO13;
new GTFO14;
new GTFO15;
new GTFO16;
for the ID's of the cars
I then have
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new id = GetPlayerVehicleID(playerid);
        if(id == GTFO1 || id == GTFO2 || id == GTFO3 || id == GTFO4 || id == GTFO5 || id == GTFO6 || id == GTFO7 || id == GTFO8 ||
        id == GTFO9 || id == GTFO10 || id == GTFO11 || id == GTFO12 || id == GTFO13 || id == GTFO14 || id == GTFO15 || id == GTFO15 ||
        id == GTFO16 || id == GTFO17 || id == GTFO18 || id == GTFO19 || id == GTFO20)
        {
            SendClientMessage(playerid, 0xFF0000FF, "This car is not for sale.");
            return RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
But I'd like it to say
Would you like to buy this vehicle for 10,000?
(If not enough money and they click buy it ejects them from car)
If Yes when they can afford it they teleport to certain CORDS IN that car.. and another one of them cars spawns where you buy it from.
Reply
#2

Use "GameTextForPlayer" to show "Would you like to buy this vehicle for 10,000? Type /buy."(or SendClientMessage)
Click > https://sampwiki.blast.hk/wiki/GameTextForPlayer

Create a simple command like "/buy"
https://sampwiki.blast.hk/wiki/Creating_Commands

sample(Simple and not complete)
Код:
     
     if(!strcmp(cmdtext, "/buy")) 
     {
         new money = GetPlayerMoney(playerid);
        new playerState = GetPlayerState(playerid);
         if(playerstate == PLAYER_STATE_DRIVER)
        {
        if(money < 9999)
        {
GameTextForPlayer(playerid,"~r~Not Enough Cash~n~~g~$10000 Needed",5000,5);
RemovePlayerFromVehicle(playerid);
 return 1;
        }
else
{
        new id = GetPlayerVehicleID(playerid);
        if(id == GTFO1 || id == GTFO2 || id == GTFO3 || id == GTFO4 || id == GTFO5 || id == GTFO6 || id ==     GTFO7 || id == GTFO8 ||
        id == GTFO9 || id == GTFO10 || id == GTFO11 || id == GTFO12 || id == GTFO13 || id == GTFO14 || id == GTFO15 || id == GTFO15 ||
        id == GTFO16 || id == GTFO17 || id == GTFO18 || id == GTFO19 || id == GTFO20)
        {
          
            
            new cash = 10000 - money;
            GivePlayerMoney(playerid,cash);
            GameTextForPlayer(playerid,"~p~Vehicle Purchased~n~~r~-$10000",5000,5);
            
        }
}
    }
        return 1;
     }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)