"Yes" "No" dialog problem
#1

I am using LARP!
Hey, I downloded this dealership filterscript:
https://sampforum.blast.hk/showthread.php?tid=299738
And when I enter a car, it asks me if I want to buy it "Yes" or "No", but when I press the "Yes" or "No" nothing happeneds.
Here are those lines in the script:
pawn Код:
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new
            vehicleid = GetPlayerVehicleID(playerid),
            dialog_string[128];

        if(VehicleStatistics[vehicleid][vehicle_onsale] == 1)
        {
            format(dialog_string, sizeof(dialog_string), "Would you like to buy this %s costing $%d?", GetVehicleName(vehicleid), VehicleStatistics[vehicleid][vehicle_price]);
            ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "Car Purchase", dialog_string, "Yes", "No");
            return 1;
        }
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1337)
    {
        if(response)
        {
            new
                vehicleid = GetPlayerVehicleID(playerid),
                model = GetVehicleModel(vehicleid),
                price = VehicleStatistics[vehicleid][vehicle_price],
                Float:position[5],
                string[128],
                dealershipid = -1,
                var[32],
                playername[24];

            GetPlayerName(playerid, playername, sizeof(playername));
            GetPlayerPos(playerid, position[1], position[2], position[3]);
            GetPlayerFacingAngle(playerid, position[4]);

            if(GetPVarInt(playerid, "AmountOfCars") >= MAX_OWNABLE_CARS)
                return SendClientMessage(playerid, color_grey, "    You already own the maximum amount of vehicles !"), RemovePlayerFromVehicle(playerid);

            if(GetPlayerMoney(playerid) < price)
                return SendClientMessage(playerid, color_grey, "    You can't afford that !"), RemovePlayerFromVehicle(playerid);

            for(new i = 1; i < MAX_DEALERSHIPS; i++)
            {
                if(IsPlayerInRangeOfPoint(playerid, DealershipStatistics[i][dealership_radius], DealershipStatistics[i][dealership_x], DealershipStatistics[i][dealership_y], DealershipStatistics[i][dealership_z]))
                {
                    dealershipid = i;
                    break;
                }
            }

            DealershipStatistics[dealershipid][dealership_earnings] += (price / 4);

            GivePlayerMoney(playerid, -price);

            RemovePlayerFromVehicle(playerid);
            vehicleid = CreateVehicle(model, (position[1] + (7.5 * floatsin(-position[4], degrees))), (position[2] + (7.5 * floatcos(position[4], degrees))), position[3], position[4], 0, 0, -1);
            format(string, sizeof(string), "Thank you for purchasing at %s, we hope to see you again!", DealershipStatistics[dealershipid][dealership_name]);
            SendClientMessage(playerid, color_white, string);
            SendClientMessage(playerid, color_white, "Your vehicle has been spawned in front of you.");

            SetPVarInt(playerid, "AmountOfCars", GetPVarInt(playerid, "AmountOfCars") + 1);

            format(var, sizeof(var), "Model_%d", GetPVarInt(playerid, "AmountOfCars"));
            SetPVarInt(playerid, var, model);

            format(var, sizeof(var), "X_%d", GetPVarInt(playerid, "AmountOfCars"));
            SetPVarFloat(playerid, var, (position[1] + (7.5 * floatsin(-position[4], degrees))));

            format(var, sizeof(var), "Y_%d", GetPVarInt(playerid, "AmountOfCars"));
            SetPVarFloat(playerid, var, (position[2] + (7.5 * floatcos(position[4], degrees))));

            format(var, sizeof(var), "Z_%d", GetPVarInt(playerid, "AmountOfCars"));
            SetPVarFloat(playerid, var, position[3]);

            format(var, sizeof(var), "Angle_%d", GetPVarInt(playerid, "AmountOfCars"));
            SetPVarFloat(playerid, var, position[4]);

            format(var, sizeof(var), "Carkey_%d", GetPVarInt(playerid, "AmountOfCars"));
            SetPVarInt(playerid, var, vehicleid);
           
            format(var, sizeof(var), "Paintjob_%d", GetPVarInt(playerid, "AmountOfCars"));
            SetPVarInt(playerid, var, -1);

            strmid(owner[vehicleid], playername, 0, strlen(playername), 255);
            SavePlayerVehicleData(playerid);
            return 1;
        }
        else return RemovePlayerFromVehicle(playerid);
    }
    return 0;
How can I fix it?
Reply
#2

Check you GM. If you also have dialog with ID 1337 that can cause the problem .
Reply
#3

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Check you GM. If you also have dialog with ID 1337 that can cause the problem .
No, I don't
What to do?

Edit: Oh, it's a GM problem.
I have LARP, but I tried it on another GM and it worked there.
What do I do?
Reply
#4

Oh, so it is a gamemode problem? From the wiki it seems that if a script doesn't return 0 in the callback (assuming a case where no matching dialog is found), the callback wont fire for filterscripts.

Open up your gamemode and see if 0 is returned in case there's no dialog to display for the player.
Reply
#5

Quote:
Originally Posted by AndreT
Посмотреть сообщение
Oh, so it is a gamemode problem? From the wiki it seems that if a script doesn't return 0 in the callback (assuming a case where no matching dialog is found), the callback wont fire for filterscripts.

Open up your gamemode and see if 0 is returned in case there's no dialog to display for the player.
I don't have OnDialogResponse on my GM :O
Every time I login, I need to type /login <password>.
How to fix it?
Reply
#6

Debug the script.
Put prints in the code to see what's getting called.
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
Debug the script.
Put prints in the code to see what's getting called.
How can I debug it?
Reply
#8

Why do I have to keep re-quoting myself on this forum?

Quote:
Originally Posted by MP2
Посмотреть сообщение
Put prints in the code to see what's getting called.
Quote:
Originally Posted by MP2
Посмотреть сообщение
Put prints in the code to see what's getting called.
Quote:
Originally Posted by MP2
Посмотреть сообщение
Put prints in the code to see what's getting called.
Quote:
Originally Posted by MP2
Посмотреть сообщение
Put prints in the code to see what's getting called.
Quote:
Originally Posted by MP2
Посмотреть сообщение
Put prints in the code to see what's getting called.
Quote:
Originally Posted by MP2
Посмотреть сообщение
Put prints in the code to see what's getting called.
Quote:
Originally Posted by MP2
Посмотреть сообщение
Put prints in the code to see what's getting called.
Reply
#9

Quote:
Originally Posted by MP2
Посмотреть сообщение
Why do I have to keep re-quoting myself on this forum?
What are prints?
I don't know, I am a begginer scripter.

And I added OnDialogResponse with return 1 and then return 0 in wiki, and it still won't work.
What do to?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)