SA-MP Forums Archive
Dialog problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dialog problem (/showthread.php?tid=179031)



Dialog problem - FrankC - 25.09.2010

if you press "Cancel" (second button) i want it to go out of the car
ive tryed to add
Код:
else
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
but nothing happends... what is wrong with this. here is the code

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 4512 && response == 1)
    {
        if(IsPlayerConnected(playerid))
                {
            for(new i = 0; i < sizeof(CarInfo); i++)
                        {
                if(CarInfo[i][ownedvehicle] == GetPlayerVehicleID(playerid))
                                {
                    if(PlayerInfo[playerid][pCarKey]!=0)
                                        {
                       SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /carsell if you want to buy this one!");
                                           return 1;
                    }
                                        if(CarInfo[i][cOwned]==1)
                                        {
                        SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
                                                return 1;
                                        }
                                        if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
                                        {
                        PlayerInfo[playerid][pCarKey] = i;
                                                CarInfo[i][cOwned] = 1;
                                                CarOffered[playerid]=0;
                                                GetPlayerName(playerid, sendername2, sizeof(sendername2));
                                                strmid(CarInfo[i][cOwner], sendername2, 0, strlen(sendername2), 999);
                                                GivePlayerMoney(playerid,-CarInfo[i][cValue]);
                                                GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
                                                SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
                                                SendClientMessage(playerid, COLOR_GRAD2, "Type /carhelp for help");
                                                TogglePlayerControllable(playerid, 1);
                                                SaveCars();
                                                return 1;
                    }
                                        else
                                        {
                                        RemovePlayerFromVehicle(playerid);
                                        TogglePlayerControllable(playerid, 1);
										
                        return 1;
                     }



Re: Dialog problem - Mikkel_Pedersen - 25.09.2010

To make second button work you should use:
pawn Код:
if(!response)
And then eject the player


Re: Dialog problem - FrankC - 25.09.2010

Quote:
Originally Posted by Mikkel_Pedersen
Посмотреть сообщение
To make second button work you should use:
pawn Код:
if(!response)
And then eject the player
Yes but dont that response need a number like 1/0 ore something?


Re: Dialog problem - Mikkel_Pedersen - 25.09.2010

Well
pawn Код:
if(!response)
Is the same as: (Well as far i know)
pawn Код:
if(response == 0)
Like
pawn Код:
if(!strcmp("/hey", cmdtext, true)
Is the same as
pawn Код:
if(strcmp("/hey", cmdtext, true) == 0)



Re: Dialog problem - FrankC - 25.09.2010

Quote:
Originally Posted by Mikkel_Pedersen
Посмотреть сообщение
Well
pawn Код:
if(!response)
Is the same as: (Well as far i know)
pawn Код:
if(response == 0)
Like
pawn Код:
if(!strcmp("/hey", cmdtext, true)
Is the same as
pawn Код:
if(strcmp("/hey", cmdtext, true) == 0)
Okay thanks i try make if(!response) with case


Re: Dialog problem - Mauzen - 25.09.2010

Yep, response is 1 if you click ok, and 0 if you click cancel
So do it like this:

pawn Код:
if(dialogid == 4512)
{
    if(response == 1)
    {
    //Your code after the first if
    } else
    {
        RemovePlayerFromVehicle(playerid);
        TogglePlayerControllable(playerid, 1);
    }
}
You do not need to use IsPlayerConnected btw, because a player who is not connected cant click on a dialog


Re: Dialog problem - FrankC - 25.09.2010

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Yep, response is 1 if you click ok, and 0 if you click cancel
So do it like this:

pawn Код:
if(dialogid == 4512)
{
    if(response == 1)
    {
    //Your code after the first if
    } else
    {
        RemovePlayerFromVehicle(playerid);
        TogglePlayerControllable(playerid, 1);
    }
}
You do not need to use IsPlayerConnected btw, because a player who is not connected cant click on a dialog
Oh okay thanks, And about the "IsPlayerConnected" haha thanks


Re: Dialog problem - FrankC - 25.09.2010

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Yep, response is 1 if you click ok, and 0 if you click cancel
So do it like this:

pawn Код:
if(dialogid == 4512)
{
    if(response == 1)
    {
    //Your code after the first if
    } else
    {
        RemovePlayerFromVehicle(playerid);
        TogglePlayerControllable(playerid, 1);
    }
}
You do not need to use IsPlayerConnected btw, because a player who is not connected cant click on a dialog
I think i did it right but now i get allot of errors "Did not found..." all in the dialog can't be found now ?
here is what i did

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 4512)
	{    
	if(response == 1)    
	{
            for(new i = 0; i < sizeof(CarInfo); i++)
                        {
                if(CarInfo[i][ownedvehicle] == GetPlayerVehicleID(playerid))
                                {
                    if(PlayerInfo[playerid][pCarKey]!=0)
                                        {
                       SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /car sell if you want to buy this one!");
                                           return 1;
                    }
                                        if(CarInfo[i][cOwned]==1)
                                        {
                        SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
                                                return 1;
                                        }
                                        if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
                                        {
                        PlayerInfo[playerid][pCarKey] = i;
                                                CarInfo[i][cOwned] = 1;
                                                CarOffered[playerid]=0;
                                                GetPlayerName(playerid, sendername2, sizeof(sendername2));
                                                strmid(CarInfo[i][cOwner], sendername2, 0, strlen(sendername2), 999);
                                                GivePlayerMoney(playerid,-CarInfo[i][cValue]);
                                                GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
                                                SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
                                                SendClientMessage(playerid, COLOR_GRAD2, "Type /car manual to view the car manual!");
                                                TogglePlayerControllable(playerid, 1);
                                                SaveCars();
                                                return 1;
                    }
                                        else
                                        {
                                        RemovePlayerFromVehicle(playerid);
                                        TogglePlayerControllable(playerid, 1);
										
                        return 1;
                    }
                }
            }
        }
        return 1;
        }
        return 1;
}



Re: Dialog problem - FrankC - 25.09.2010

Only one error now

Код:
error 010: invalid function or declaration



Re: Dialog problem - FrankC - 25.09.2010

Can anybody help me here does there miss a "}" ore something?

error:

Quote:

error 010: invalid function or declaration

Code:

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 4512)
{    
    if(response == 1)    
	{
            for(new i = 0; i < sizeof(CarInfo); i++)
                        {
                if(CarInfo[i][ownedvehicle] == GetPlayerVehicleID(playerid))
                                {
                    if(PlayerInfo[playerid][pCarKey]!=0)
                                        {
                       SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /car sell if you want to buy this one!");
                                           return 1;
                    }
                                        if(CarInfo[i][cOwned]==1)
                                        {
                        SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
                                                return 1;
                                        }
                                        if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
                                        {
                        PlayerInfo[playerid][pCarKey] = i;
                                                CarInfo[i][cOwned] = 1;
                                                CarOffered[playerid]=0;
                                                GetPlayerName(playerid, sendername2, sizeof(sendername2));
                                                strmid(CarInfo[i][cOwner], sendername2, 0, strlen(sendername2), 999);
                                                GivePlayerMoney(playerid,-CarInfo[i][cValue]);
                                                GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
                                                SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
                                                SendClientMessage(playerid, COLOR_GRAD2, "Type /car manual to view the car manual!");
                                                TogglePlayerControllable(playerid, 1);
                                                SaveCars();
                                                return 1;

                    }
                                        else
                                        {
                                        RemovePlayerFromVehicle(playerid);
                                        TogglePlayerControllable(playerid, 1);
										}
                       return 1;
                    }
                }
            }
        }
        return 1;
        }
        return 1;
}