Removeplayerfromvehicle
#1

i have this vehicle script:

pawn Код:
case DIALOG_VEHICLE_BUY:
        {
            new vehicleid = GetPVarInt(playerid, "DialogValue1");
            new caption[32], info[256];
            format(caption, sizeof(caption), "Vehicle ID %d", vehicleid);
            format(info, sizeof(info), "This vehicle is for sale ($%d)\nWould you like to buy it?", VehicleValue[vehicleid]);
            ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, info, "Yes", "No");
        }
how i make so if player select no, removeplayerfromvehicle?
Reply
#2

The response variable for OnDialogResponse will be equal to 0 if they select the second button.
Reply
#3

pawn Код:
if(!response) return RemovePlayerFromVehicle(vehid)
something like that i think
Reply
#4

i would of thought it would be like this :

pawn Код:
if(dialogid == DIALOG_VEHICLE_BUY);
{
       if(!response) return RemovePlayerFromVehicle(vehid)
       {
          case 1:
          {
             //code
lol think im wrong :/
Reply
#5

oh man im very confused. pls help?
Reply
#6

okay here is my buy vehicle dialog.
pawn Код:
if(dialogid == DIALOG_VEHICLE_BUY)
    {
        if(response)
        {
            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(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
            VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
            for(new d=0; d < sizeof(VehicleTrunk[]); d++)
            {
                VehicleTrunk[freeid][d][0] = 0;
                VehicleTrunk[freeid][d][1] = 0;
            }
            for(new d=0; d < sizeof(VehicleMods[]); d++)
            {
                VehicleMods[freeid][d] = 0;
            }
            VehiclePaintjob[freeid] = 255;
            VehicleLock[freeid] = 0;
            VehicleAlarm[freeid] = 0;
            UpdateVehicle(freeid, 0);
            SaveVehicle(freeid);
            new msg[128];
            format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
            SendClientMessage(playerid, COLOR_WHITE, msg);
            RemovePlayerFromVehicle(playerid);
        }
        else
        {
            RemovePlayerFromVehicle(playerid);
        }
        return 1;
    }
i added removeplayerfromvehicle so when player press "yes", it will remove player from vehicle. that works. but when i press "no" (i added it after "else"), it doesnt work. pls help?
Reply
#7

Please post the full code of your OnDialogResponse, it doesn't make sense that you have a switch() and an if statement both with the same dialog id.
Reply
#8

Quote:
Originally Posted by h02
Посмотреть сообщение
Please post the full code of your OnDialogResponse, it doesn't make sense that you have a switch() and an if statement both with the same dialog id.
okay this is just from avs vehicle system as i am using it.

http://pastebin.com/bF9Fjikr
Reply
#9

Quote:
Originally Posted by TheDiscussionCafe
Посмотреть сообщение
okay here is my buy vehicle dialog.
pawn Код:
if(dialogid == DIALOG_VEHICLE_BUY)
    {
        if(response)
        {
            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(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
            VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
            for(new d=0; d < sizeof(VehicleTrunk[]); d++)
            {
                VehicleTrunk[freeid][d][0] = 0;
                VehicleTrunk[freeid][d][1] = 0;
            }
            for(new d=0; d < sizeof(VehicleMods[]); d++)
            {
                VehicleMods[freeid][d] = 0;
            }
            VehiclePaintjob[freeid] = 255;
            VehicleLock[freeid] = 0;
            VehicleAlarm[freeid] = 0;
            UpdateVehicle(freeid, 0);
            SaveVehicle(freeid);
            new msg[128];
            format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
            SendClientMessage(playerid, COLOR_WHITE, msg);
            RemovePlayerFromVehicle(playerid);
        }
        else
        {
            RemovePlayerFromVehicle(playerid);
        }
        return 1;
    }
i added removeplayerfromvehicle so when player press "yes", it will remove player from vehicle. that works. but when i press "no" (i added it after "else"), it doesnt work. pls help?
Change that to this:
pawn Код:
if(dialogid == DIALOG_VEHICLE_BUY)
    {
        if(response)
        {
            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(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
            VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
            for(new d=0; d < sizeof(VehicleTrunk[]); d++)
            {
                VehicleTrunk[freeid][d][0] = 0;
                VehicleTrunk[freeid][d][1] = 0;
            }
            for(new d=0; d < sizeof(VehicleMods[]); d++)
            {
                VehicleMods[freeid][d] = 0;
            }
            VehiclePaintjob[freeid] = 255;
            VehicleLock[freeid] = 0;
            VehicleAlarm[freeid] = 0;
            UpdateVehicle(freeid, 0);
            SaveVehicle(freeid);
            new msg[128];
            format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
            SendClientMessage(playerid, COLOR_WHITE, msg);
            RemovePlayerFromVehicle(playerid);
        }
        if(!response) return RemovePlayerFromVehicle(playerid);
        return 1;
    }
Hope this helps
Reply
#10

Quote:
Originally Posted by Sandiel
Посмотреть сообщение
Change that to this:
pawn Код:
if(dialogid == DIALOG_VEHICLE_BUY)
    {
        if(response)
        {
            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(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
            VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
            for(new d=0; d < sizeof(VehicleTrunk[]); d++)
            {
                VehicleTrunk[freeid][d][0] = 0;
                VehicleTrunk[freeid][d][1] = 0;
            }
            for(new d=0; d < sizeof(VehicleMods[]); d++)
            {
                VehicleMods[freeid][d] = 0;
            }
            VehiclePaintjob[freeid] = 255;
            VehicleLock[freeid] = 0;
            VehicleAlarm[freeid] = 0;
            UpdateVehicle(freeid, 0);
            SaveVehicle(freeid);
            new msg[128];
            format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
            SendClientMessage(playerid, COLOR_WHITE, msg);
            RemovePlayerFromVehicle(playerid);
        }
        if(!response) return RemovePlayerFromVehicle(playerid);
        return 1;
    }
Hope this helps
sorry that dont work either.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)