SA-MP Forums Archive
Error with ShowPlayerDialog - 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)
+--- Thread: Error with ShowPlayerDialog (/showthread.php?tid=363219)



Error with ShowPlayerDialog - maramizo - 26.07.2012

pawn Code:
CMD:buyhouselock(playerid, params[])
{
    new idx = GetPlayerVirtualWorld(playerid)-100;
    if(BizInfo[idx][bType] == 1)
    {
        ShowPlayerDialog(playerid, BUYHOUSELOCK, DIALOG_STYLE_LIST, "Lock Type", "Door Lock - 50,000$\nCentral Locking System - 250,000$", "Choose", "Cancel"); //HERE is where the code reaches, then returns on the next sentence. But NO DIALOG SHOWS.
        return 1;
    }
    else
    {
        return SendClientMessage(playerid, COLOR_WHITE, "You are not in a 24/7 business shop.");
    }
    SendClientMessage(playerid, COLOR_WHITE, "BUG #3");
    return 1;
}
As commented in the code, no dialog is shown, No errors/warnings are given though.


Re: Error with ShowPlayerDialog - MadafakaPro - 26.07.2012

show us OnDialogResponse


Re: Error with ShowPlayerDialog - maramizo - 26.07.2012

pawn Code:
if(dialogid == BUYHOUSELOCK)
    {
        if(response)
        {
            if(GetPlayerMoney(playerid) < PHouseLock(listitem)) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough cash!");
            if(PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID && PlayerInfo[playerid][pPhousekey2] != INVALID_HOUSE_ID)
            {
                if(listitem == 0)
                {
                    ShowPlayerDialog(playerid, BUYHOUSELOCK2, DIALOG_STYLE_LIST, "Purchasing House Lock", "House slot 1\nHouse slot 2","Choose","Cancel");
                }
                else
                {
                    ShowPlayerDialog(playerid, BUYHOUSELOCK3, DIALOG_STYLE_LIST, "Purchasing House Lock", "House slot 1\nHouse slot 2","Choose","Cancel");
                }
            }
            else if(PlayerInfo[playerid][pPhousekey2] == INVALID_HOUSE_ID && PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID)
            {
                PlayerInfo[playerid][pHouseLock] = listitem+1;
                GivePlayerCash(playerid, -PHouseLock(listitem));
                return SendClientMessage(playerid, COLOR_WHITE, "You have purchased the lock successfully for your first house slot!");
            }
            else if(PlayerInfo[playerid][pPhousekey2] != INVALID_HOUSE_ID && PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID)
            {
                PlayerInfo[playerid][pHouseLock2] = listitem+1;
                GivePlayerCash(playerid, -PHouseLock(listitem));
                return SendClientMessage(playerid, COLOR_WHITE, "You have purchased the lock successfully for your first second slot!");
            }
        }
    }
    if(dialogid == BUYHOUSELOCK2)
    {
        switch(listitem)
        {
            case 0:
            {
                PlayerInfo[playerid][pHouseLock] = 1;
                GivePlayerCash(playerid, -50000);
                return SendClientMessage(playerid, COLOR_WHITE, "You have purchased a door lock successfully for your first house slot!");
            }
            case 1:
            {
                PlayerInfo[playerid][pHouseLock2] = 1;
                GivePlayerCash(playerid, -50000);
                return SendClientMessage(playerid, COLOR_WHITE, "You have purchased a door lock successfully for your second house slot!");
            }
        }
    }
    if(dialogid == BUYHOUSELOCK3)
    {
        switch(listitem)
        {
            case 0:
            {
                PlayerInfo[playerid][pHouseLock] = 2;
                GivePlayerCash(playerid, -250000);
                return SendClientMessage(playerid, COLOR_WHITE, "You have purchased a central lock system successfully for your first house slot!");
            }
            case 1:
            {
                PlayerInfo[playerid][pHouseLock2] = 2;
                GivePlayerCash(playerid, -250000);
                return SendClientMessage(playerid, COLOR_WHITE, "You have purchased a central lock system successfully for your second house slot!");
            }
        }
    }
Irrelevant though, even if I did not have a dialogid here it would've still showed.


Re: Error with ShowPlayerDialog - maramizo - 26.07.2012

Quote:
Originally Posted by Littl3j0hNy
View Post
Maybe BizInfo[idx][bType] is not 1...
It is, I've tested a SendClientMessage and I recieved the message.


Re: Error with ShowPlayerDialog - MP2 - 26.07.2012

Are two topics really necessary? See your other topic:

https://sampforum.blast.hk/showthread.php?tid=363219


Re: Error with ShowPlayerDialog - maramizo - 26.07.2012

Quote:
Originally Posted by MP2
View Post
Are two topics necessary?

The array index ('idx') is probably out of bounds. Print it out.

pawn Code:
printf("Accessing array index %i", idx);
I have a strong feeling it will be negative, which will never work.
It is not out of bounds, as it reaches the ShowPlayerDialog, I've created a SendClientMessage in the same scope after the test for idx and it showed it.
Please post on this topic not the other one, as the other one was created by mistake.


Re: Error with ShowPlayerDialog - [KHK]Khalid - 26.07.2012

What's the defination of BUYHOUSELOCK? Keep in mind that max dialog id is 32767 as you've been told before.


Re: Error with ShowPlayerDialog - maramizo - 26.07.2012

Quote:
Originally Posted by HellSphinX
View Post
What's the defination of BUYHOUSELOCK? Keep in mind that max dialog id is 32767 as you've been told before.
Yes. that was my mistake... Again.
BUT This is NOT fixed yet!
It loads the first BUYHOUSELOCK, but it doesnt load the second one:
pawn Code:
if(dialogid == BUYHOUSELOCK)
    {
        if(response)
        {
            if(GetPlayerMoney(playerid) < PHouseLock(listitem)) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough cash!");
            if(PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID && PlayerInfo[playerid][pPhousekey2] != INVALID_HOUSE_ID)
            {
                if(listitem == 0)
                {
                    ShowPlayerDialog(playerid, BUYHOUSELOCK2, DIALOG_STYLE_LIST, "Purchasing House Lock", "House slot 1\nHouse slot 2","Choose","Cancel");
                }
                else
                {
                    ShowPlayerDialog(playerid, BUYHOUSELOCK3, DIALOG_STYLE_LIST, "Purchasing House Lock", "House slot 1\nHouse slot 2","Choose","Cancel");
                }
            }
            else if(PlayerInfo[playerid][pPhousekey2] == INVALID_HOUSE_ID && PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID)
            {
                PlayerInfo[playerid][pHouseLock] = listitem+1;
                GivePlayerCash(playerid, -PHouseLock(listitem));
                return SendClientMessage(playerid, COLOR_WHITE, "You have purchased the lock successfully for your first house slot!");
            }
            else if(PlayerInfo[playerid][pPhousekey2] != INVALID_HOUSE_ID && PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID)
            {
                PlayerInfo[playerid][pHouseLock2] = listitem+1;
                GivePlayerCash(playerid, -PHouseLock(listitem));
                return SendClientMessage(playerid, COLOR_WHITE, "You have purchased the lock successfully for your first second slot!");
            }
            else return SendClientMessage(playerid, COLOR_WHITE, "You do not own a house.");
        }
    }
Error must be there..


Re: Error with ShowPlayerDialog - [KHK]Khalid - 26.07.2012

Check the definations of BUYHOUSELOCK2/BUYHOUSELOCK3?