Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] [SOLVED] how make a correct IF function with for parameter vehicle ID == enum id

 
  • 0 Vote(s) - 0 Average
Pawn [SOLVED] how make a correct IF function with for parameter vehicle ID == enum id
PutuSuhartawan
Offline

Burgershot Member
Posts: 120
Threads: 52
Joined: Nov 2020
Reputation: 1
Location: Indonesia
#1
2021-04-30, 10:50 PM (This post was last modified: 2021-05-10, 10:06 PM by PutuSuhartawan.)
SOLUTION:
Code:
stock IsPlayerInDealerVehicle(playerid)

{

new s; new invehicleid = GetPlayerVehicleID(playerid);

for( s=1; s<MAX_SALON_SLOT; s++)

        {





for(new salon=1; salon<MAX_SALON; salon++)

        {

             

              if(SalonCarIdSlot[salon][s] == invehicleid)

              {

              



              SetPVarInt(playerid, "UseIdSalon", salon);



SetPVarInt(playerid, "UseSlotSalon", s);

              new sVehSlotDeal = s;

              new salonDealID = salon;

              new st[160];

format(st,sizeof(st),"Anda yakin ingin membeli nomor tansport %i?\n\nModel: %s\nBiaya: $%i",

sVehSlotDeal ,NameCars(SalonModelSlot[salonDealID][sVehSlotDeal]),SalonPriseSlot[salonDealID][sVehSlotDeal]);

ShowPlayerDialog(playerid,64, DIALOG_STYLE_MSGBOX, "Pasar mobil", st, "Untuk membeli", "Keluarlah");

              return true;

              }

             



        }

}         





return 0;



}

how to make a correct IF function with the required parameter for a vehicle ID that has many Increments?
I find it difficult to match the player into a particular car.

Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger)
{
new slot=GetPVarInt(playerid,"SalonSlot");
new salon;
for(new s=1;s<MAX_SALON_SLOT;s++)
            {
             



if(vehicleid == SalonCarIdSlot[salon][s] )
{
new st[160];
format(st,sizeof(st),"Anda yakin ingin membeli nomor tansport %i?\n\nModel: %s\nBiaya: $%i",slot,NameCars(SalonModelSlot[s][slot]),SalonPriseSlot[s][slot]);
ShowPlayerDialog(playerid,64, DIALOG_STYLE_MSGBOX, "Pasar mobil", st, "Untuk membeli", "Keluarlah");
}


}

}


// IS THE CODE TRUE FOR ?
// If function detect is that vehicle a vehicle created for dealer vehicle
}

How to display dialog style on certain vehicles group enum?
Radical
Offline

Burgershot Member
Posts: 148
Threads: 21
Joined: Dec 2020
Reputation: 16
#2
2021-05-01, 12:54 AM
I do not understand what you want.
Please explain more...
PutuSuhartawan
Offline

Burgershot Member
Posts: 120
Threads: 52
Joined: Nov 2020
Reputation: 1
Location: Indonesia
#3
2021-05-01, 03:59 AM
(2021-05-01, 12:54 AM)Radical Wrote: I do not understand what you want.
Please explain more...

I just wanna show dialog if player enter vehicle on dealer vehicle sir

Code:
if(vehicleid == SalonCarIdSlot[salon][s] )
{
new st[160];
format(st,sizeof(st),"Anda yakin ingin membeli nomor tansport %i?\n\nModel: %s\nBiaya: $%i",slot,NameCars(SalonModelSlot[s][slot]),SalonPriseSlot[s][slot]);
ShowPlayerDialog(playerid,64, DIALOG_STYLE_MSGBOX, "Pasar mobil", st, "Untuk membeli", "Keluarlah");
}
Radical
Offline

Burgershot Member
Posts: 148
Threads: 21
Joined: Dec 2020
Reputation: 16
#4
2021-05-01, 11:57 AM
Code:
#define MAX_SALON_SLOT  (1)

#define SPORT_VEHICLES  (0)

enum dealerInfo
{
    carModel,
    carPrice,
    carSlot,
    Float: carPos[4],
    carID
}
new SalonData[][dealerInfo] =
{
    {451, 50000, SPORT_VEHICLES, {2507.0300, 2499.5908, 21.5469, -90.0000}},
    {411, 50000, SPORT_VEHICLES, {2507.2168, 2494.1467, 21.5469, -90.0000}},
};

public OnGameModeInit() {
    for (new s; s < MAX_SALON_SLOT; s++) {
        SalonData[s][carID] = CreateVehicle(SalonData[s][carModel], SalonData[s][carPos][0], SalonData[s][carPos][1], SalonData[s][carPos][2], SalonData[s][carPos][3], -1, -1, -1);
    }
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if (!ispassenger) {
        new salon_slot=GetPVarInt(playerid,"SalonSlot");
        for (new s; s < MAX_SALON_SLOT; s++) {
            if ( salon_slot == SalonData[s][carSlot] ) {
                if ( vehicleid == SalonData[s][carID] ) {
                    new st[160];
                    format(st,sizeof(st),"Anda yakin ingin membeli nomor tansport %i?\n\nModel: %s\nBiaya: $%i",s,NameCars(SalonData[s][carModel]),SalonData[s][carPrice]);
                    ShowPlayerDialog(playerid,64, DIALOG_STYLE_MSGBOX, "Pasar mobil", st, "Untuk membeli", "Keluarlah");
                    break;
                }
            }
        }
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
    if ( dialogid == 64 ) {
        
        if (!response)
            return 1;

        new salon_slot=GetPVarInt(playerid,"SalonSlot");
        for (new s; s < MAX_SALON_SLOT; s++) {
            if ( salon_slot == SalonData[s][carSlot] ) {
                if ( GetPlayerVehicleID(playerid) == SalonData[s][carID] ) {

                    if (GetPlayerMoney(playerid) < SalonData[s][carPrice])
                        return SendClientMessage(playerid, -1, "You don't have enough money."), RemovePlayerFromVehicle(playerid);

                    GivePlayerMoney(playerid, -SalonData[s][carPrice]);

                    new st[160];
                    format(st,sizeof(st),"You bought car : %s\nPrice: $%i",NameCars(SalonData[s][carModel]),SalonData[s][carPrice]);
                    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Delaer", st, "Okay", "");

                    //other stuffs...


                    break;
                }
            }
        }

        return 1;
    }
    return 1;
}
PutuSuhartawan
Offline

Burgershot Member
Posts: 120
Threads: 52
Joined: Nov 2020
Reputation: 1
Location: Indonesia
#5
2021-05-01, 06:12 PM
But is not work in a lot o vehicle dealer. I see a simply function like sample :
Code:
stock IsVelo(carid)
{
switch(GetVehicleModel(carid)) { case 481,509,510:return true; }
return 0;
}


stock IsFlyCar(carid)
{
switch(GetVehicleModel(carid)) { case 417,425,430,441,446,447,452..454,460,469,472,473,476,484,487,488,493,497,501,511..513,519,520,539,548,553,563,571,577,592,593,595:return true; }
return 0;
}

How to fix this issue sir?

Code:
stock IsPlayerInDealerVehicle(playerid)
{
/*
switch(GetPlayerVehicleID(playerid)) { case

for(new salon=1;salon<MAX_SALON;salon++)
    {
for(new s=1;s<MAX_SALON_SLOT;s++)
            {
              SalonCarIdSlot[salon][s];


            }
}           
:return true; }

return 0;
*/
}
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode