SA-MP Forums Archive
Problem with FS which have a Dialog System - 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: Problem with FS which have a Dialog System (/showthread.php?tid=449062)



Problem with FS which have a Dialog System - Yordan_Kronos - 07.07.2013

Hello i have problem with fs, which have a dialog system. When i saw Dialog and i Click example on Buy Car, or Buy House, and nothing happens, just window disappears. How can i fix this problem ?


Re: Problem with FS which have a Dialog System - xganyx - 07.07.2013

i got that problem too. please help.


Re: Problem with FS which have a Dialog System - SwisherSweet - 07.07.2013

Search on ****** ondialogresponse most likely you did the return 1 and return 0 wrong also might be dialog id's


Re: Problem with FS which have a Dialog System - Yordan_Kronos - 07.07.2013

Thanks bro, Others SUggestions ?


Re: Problem with FS which have a Dialog System - exclide1 - 07.07.2013

Check that you have "return 0" OnDialogResponse in all of your filterscripts. Or put the filterscript in question first on the FS list in "server.cfg".


Re: Problem with FS which have a Dialog System - Josh_Main - 07.07.2013

Post your code


Re: Problem with FS which have a Dialog System - Yordan_Kronos - 07.07.2013

This is DialogResponse in my FS, for house

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
            case DIALOG_HOUSE:
            {
            if(!response) return 1;
            new
                string[200];
                switch(listitem)
                {
                case 0: {
                new id = Player[playerid][Houseid];
                if(id == 999) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have house");
                if(!IsPlayerInRangeOfPoint(playerid,3.0,House[id][EnterX],House[id][EnterY],House[id][EnterZ])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not near your house");
                format(House[id][Owner], 32, "Department");
                if(House[id][hCar] > 0) format(HouseOwner[House[id][hCar]],64,"Department");
                House[id][On_Sell] = 1;
                Player[playerid][Houseid] = 999;
                GivePlayerMoney(playerid,House[id][Price]/2);
                DestroyDynamicPickup(House[id][PickupU]);
                House[id][PickupU] = CreateDynamicPickup(1273, 23,  House[id][EnterX],House[id][EnterY],House[id][EnterZ],-1,-1,-1,100.0);
                DestroyDynamicMapIcon(House[id][Icon]);
                House[id][Icon] = CreateDynamicMapIcon(House[id][EnterX],House[id][EnterY],House[id][EnterZ], 31, 0, -1, -1, -1, 100.0);
                CheckHouse(id);
                UpdatePlayerInformation(playerid);
                format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"Department\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"%d\n{29CC3F}Level: "COL_WHITE"%d\n{29CC3F}Address: "COL_WHITE"%s\n (/buyhouse)",House[id][HouseName],House[id][Price],House[id][Level],House[id][Address]);
                UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
                }
                case 1: {
                ShowPlayerDialog(playerid,DIALOG_HOUSE+1,DIALOG_STYLE_INPUT,""COL_YELLOW"Rent house",""COL_BLUE"Type rent price","Put","Close"); }
                case 2:
                {
                new id = Player[playerid][Houseid];
                foreach (Player, i)
                {
                    if(i != playerid)
                    {
                    if(strcmp(House[id][Player_Rent],GetName(playerid), false ) == 0) {SCM(i,COLOR_RED,"You have been evicted from house");}
                    format(House[id][Player_Rent],48,"Nobody");
                    }
                    }
                    }
                case 3: {
                        ShowPlayerDialog(playerid,DIALOG_HOUSE+2,DIALOG_STYLE_INPUT,""COL_YELLOW"House name",""COL_WHITE"Type new name of house","Name","Close");
                        }
                case 4: {
                        ShowPlayerDialog(playerid,DIALOG_HOUSE+3,DIALOG_STYLE_INPUT,""COL_YELLOW"Lock Password (numbers only)",""COL_WHITE"Type new password","Insert","Close");
                        }
                    }
                }
           case DIALOG_HOUSE+1:
           {
            if(!response) return 1;
            new string[210];
            new id = Player[playerid][Houseid];
            if(strval(inputtext) <= 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Price can't be less 1");
            House[id][RentPrice] = strval(inputtext);
            format(string,sizeof(string),"New rent price is $%d",strval(inputtext)); SCM(playerid,-1,string);
            format(string,sizeof(string),"{E0BC1B}Owner: "COL_WHITE"%s\n{E0BC1B}House name: "COL_WHITE"%s\n{E0BC1B}Price: "COL_WHITE"%d\n{E0BC1B}Level: "COL_WHITE"%d\n{E0BC1B}Rent price: "COL_WHITE"%d\n{E0BC1B}Address: "COL_WHITE"%s\n (/renthouse)",House[id][Owner],House[id][HouseName],House[id][Price],House[id][Level],House[id][RentPrice],House[id][Address]);
            UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
            CheckHouse(id);
           }
           case DIALOG_HOUSE+2:
           {
            if(!response) return 1;
            new string[210];
            new id = Player[playerid][Houseid];
            format(House[id][HouseName], 32, "%s", inputtext);
            format(string,sizeof(string),"{E0BC1B}Owner: "COL_WHITE"%s\n{E0BC1B}House name: "COL_WHITE"%s\n{E0BC1B}Price: "COL_WHITE"%d\n{E0BC1B}Level: "COL_WHITE"%d\n{E0BC1B}Rent price: "COL_WHITE"%d\n{E0BC1B}Address: "COL_WHITE"%s\n (/renthouse)",House[id][Owner],House[id][HouseName],House[id][Price],House[id][Level],House[id][RentPrice],House[id][Address]);
            UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
            CheckHouse(id);
           }
           case DIALOG_HOUSE+3:
           {
            if(!response) return 1;
            new string[128];
            new id = Player[playerid][Houseid];
            if(strlen(inputtext) >= 5 || strlen(inputtext) < 4) return ShowPlayerDialog(playerid,DIALOG_HOUSE+3,DIALOG_STYLE_INPUT,""COL_WHITE"Lock Password",""COL_BLUE"Type new password","Insert","Close"),SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Just four numbers");
            format(House[id][LockPass],5,"%d",strval(inputtext));
            format(string,sizeof(string),"New password is %d",strval(inputtext)); SCM(playerid,-1,string);
            CheckHouse(id);
           }
           }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
forward LoadHouse(id, name[], value[]);
public LoadHouse(id, name[], value[])
{
    INI_Float("EnterX", House[id][EnterX]);
    INI_Float("EnterY", House[id][EnterY]);
    INI_Float("EnterZ", House[id][EnterZ]);
    INI_Float("ExitX", House[id][ExitX]);
    INI_Float("ExitY", House[id][ExitY]);
    INI_Float("ExitZ", House[id][ExitZ]);
    INI_String("HouseName", House[id][HouseName] , 32 );
    INI_String("Owner", House[id][Owner] , 32 );
    INI_Int("Price", House[id][Price]);
    INI_Int("Level", House[id][Level]);
    INI_Int("Interior", House[id][IntID]);
    INI_Int("VW", House[id][VW]);
    INI_Int("On_Sell", House[id][On_Sell]);
    INI_Int("Lock", House[id][Lock]);
    INI_Int("RentPrice", House[id][RentPrice]);
    INI_String("PlayerRent", House[id][Player_Rent] , 32 );
    INI_Int("Money", House[id][Money]);
    INI_Int("Gun1", House[id][Gun1]);
    INI_Int("Gun2", House[id][Gun2]);
    INI_Int("Ammo1", House[id][Ammo1]);
    INI_Int("Ammo2", House[id][Ammo2]);
    INI_String("LockPass", House[id][LockPass] , 5 );
    INI_Float("hCarX", House[id][hCarX]);
    INI_Float("hCarY", House[id][hCarY]);
    INI_Float("hCarZ", House[id][hCarZ]);
    INI_Float("hCarA", House[id][hCarA]);
    INI_Int("hCarC1", House[id][hCarC1]);
    INI_Int("hCarC2", House[id][hCarC2]);
    INI_Int("hCarID", House[id][hCarID]);
    INI_Int("hCarMoney", House[id][hCarMoney]);
    INI_Int("hCarGun1", House[id][hCarGun1]);
    INI_Int("hCarGun2", House[id][hCarGun2]);
    INI_Int("hCarAmmo1", House[id][hCarAmmo1]);
    INI_Int("hCarAmmo2", House[id][hCarAmmo2]);
    INI_String("PhoneNum", House[id][PhoneNum] , 5 );
    INI_String("Address", House[id][Address] , 48);
    INI_Int("DayEnter", House[id][DayEnter]);
    INI_Int("MonthEnter", House[id][MonthEnter]);

    return 1;
}
And this is my OnDialogResponse in my Gamemode

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new string[256];
    if(dialogid == 12346 || dialogid == 12347)
    {
        if(response)
        {
            if(strlen(inputtext))
            {
                new tmp[64];
                strmid(tmp, inputtext, 0, strlen(inputtext), 255);
                OnPlayerLogin_(playerid,tmp);//
            } //
            else
            {
                new loginstring[256];
                SendClientMessage(playerid, COLOR_WHITE, "SERVER: Трябва да въведеш твоята парола");
                format(loginstring,sizeof(loginstring),"{FFFFFF}[Bulgarian] {32cd32}[Red County] {FF0000}[Roleplay]\n{FFFFFF}Моля, въведи твоята парола.");
                ShowPlayerDialog(playerid,12347,DIALOG_STYLE_PASSWORD,"Влизане:",loginstring,"Влез","Излез");
            }
        }
        else
        {
            Kick(playerid);
        }
    }
    if(dialogid == 12345)
    {
        if(response)
        {
            if(strlen(inputtext))
            {
                format(string, sizeof(string), "%s.ini", PlayerName(playerid));
                if(dini_Exists(string))
                {
                    SendClientMessage(playerid, COLOR_YELLOW, "Това име е заето, сменето го с друго!");
                    return 1;
                }
                new tmp[64];
                strmid(tmp, inputtext, 0, strlen(inputtext), 255);
                OnPlayerRegister(playerid, tmp);
            }
            else
            {
                new regstring[256];
                format(regstring,sizeof(regstring),"{FFFFFF}[Bulgarian] {32cd32}[Red County] {FF0000}[Roleplay]\n{FFFFFF}Това име не е регистрирано. Въведи парола за да го регистрираш.");
                ShowPlayerDialog(playerid,12345,DIALOG_STYLE_PASSWORD,"Регистрация:",regstring,"Регистрирай","Излез");
            }
        }
        else
        {
            Kick(playerid);
        }
    }
    if(dialogid==525)
    {
        if(response)
        {
            SetPlayerPos(playerid, EvnTp[playerid][0],EvnTp[playerid][1],EvnTp[playerid][2]);
            ResetPlayerWeapons(playerid);
            SetPlayerColor(playerid, COLOR_EVENT);
            ResetPlayerWeaponsEx(playerid);
            SetPlayerVirtualWorld(playerid, 1);
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 100);
            SendClientMessage(playerid,0x00FF00FF, "Ти прие поканата си и оръжията ти бяха премахнати!");
        }
        else
        {
            SendClientMessage(playerid,COLOR_GRAD1, "Ти отказа поканата в евента!");
        }
    }
    if(dialogid == 30)//aoc
    {
        if(response)
        {//Main gate/ Water Gate/ Spec Gate/ View Gate/ Locker door / Up door
            if(listitem == 0)
            {
            }
            if(listitem == 1)
            {
            }
            if(listitem == 2)
            {
            }
            if(listitem == 3)
            {
            }
            if(listitem == 4)
            {
            }
            if(listitem == 5)
            {
            }
        }
        else
        {
        }
        return 1;
    }
    if(dialogid == 31)
    {
        if(response)
        {//Main gate/ Water Gate/ Spec Gate/ View Gate/ Locker door / Up door
            if(listitem == 0)
            {
            }
            if(listitem == 1)
            {
            }
            if(listitem == 2)
            {
            }
            if(listitem == 3)
            {
            }
            if(listitem == 4)
            {
            }
            if(listitem == 5)
            {
            }
            return 1;
        }
        else
        {
        }
    }
    return 1;
}



Re: Problem with FS which have a Dialog System - iggy1 - 07.07.2013

Like people have said, in ALL of your other scripts return 0 if the dialog is not found. When OnDialogResponse reaches a "return 1" it stops processing other dialogs across all loaded scripts.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if( dialogid == REG_DIALOG )
    {
        //dialog was found return 1
        return 1;
    }

    //more dialogs...

    //no dialogid matches, return 0 so other scripts can process this dialog
    return 0;
}
You must also do this in ALL loaded scripts (including the GM) or it will cause your dialogs to just close when you click them. I'm sure there's a note about that on the wiki.


Re: Problem with FS which have a Dialog System - Yordan_Kronos - 07.07.2013

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
            case DIALOG_HOUSE:
            {
            if(!response) return 1;
            new
                string[200];
                switch(listitem)
                {
                case 0: {
                new id = Player[playerid][Houseid];
                if(id == 999) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have house");
                if(!IsPlayerInRangeOfPoint(playerid,3.0,House[id][EnterX],House[id][EnterY],House[id][EnterZ])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not near your house");
                format(House[id][Owner], 32, "Department");
                if(House[id][hCar] > 0) format(HouseOwner[House[id][hCar]],64,"Department");
                House[id][On_Sell] = 1;
                Player[playerid][Houseid] = 999;
                GivePlayerMoney(playerid,House[id][Price]/2);
                DestroyDynamicPickup(House[id][PickupU]);
                House[id][PickupU] = CreateDynamicPickup(1273, 23,  House[id][EnterX],House[id][EnterY],House[id][EnterZ],-1,-1,-1,100.0);
                DestroyDynamicMapIcon(House[id][Icon]);
                House[id][Icon] = CreateDynamicMapIcon(House[id][EnterX],House[id][EnterY],House[id][EnterZ], 31, 0, -1, -1, -1, 100.0);
                CheckHouse(id);
                UpdatePlayerInformation(playerid);
                format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"Department\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"%d\n{29CC3F}Level: "COL_WHITE"%d\n{29CC3F}Address: "COL_WHITE"%s\n (/buyhouse)",House[id][HouseName],House[id][Price],House[id][Level],House[id][Address]);
                UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
                }
                case 1: {
                ShowPlayerDialog(playerid,DIALOG_HOUSE+1,DIALOG_STYLE_INPUT,""COL_YELLOW"Rent house",""COL_BLUE"Type rent price","Put","Close"); }
                case 2:
                {
                new id = Player[playerid][Houseid];
                foreach (Player, i)
                {
                    if(i != playerid)
                    {
                    if(strcmp(House[id][Player_Rent],GetName(playerid), false ) == 0) {SCM(i,COLOR_RED,"You have been evicted from house");}
                    format(House[id][Player_Rent],48,"Nobody");
                    }
                    }
                    }
                case 3: {
                        ShowPlayerDialog(playerid,DIALOG_HOUSE+2,DIALOG_STYLE_INPUT,""COL_YELLOW"House name",""COL_WHITE"Type new name of house","Name","Close");
                        }
                case 4: {
                        ShowPlayerDialog(playerid,DIALOG_HOUSE+3,DIALOG_STYLE_INPUT,""COL_YELLOW"Lock Password (numbers only)",""COL_WHITE"Type new password","Insert","Close");
                        }
                    }
                }
           case DIALOG_HOUSE+1:
           {
            if(!response) return 1;
            new string[210];
            new id = Player[playerid][Houseid];
            if(strval(inputtext) <= 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Price can't be less 1");
            House[id][RentPrice] = strval(inputtext);
            format(string,sizeof(string),"New rent price is $%d",strval(inputtext)); SCM(playerid,-1,string);
            format(string,sizeof(string),"{E0BC1B}Owner: "COL_WHITE"%s\n{E0BC1B}House name: "COL_WHITE"%s\n{E0BC1B}Price: "COL_WHITE"%d\n{E0BC1B}Level: "COL_WHITE"%d\n{E0BC1B}Rent price: "COL_WHITE"%d\n{E0BC1B}Address: "COL_WHITE"%s\n (/renthouse)",House[id][Owner],House[id][HouseName],House[id][Price],House[id][Level],House[id][RentPrice],House[id][Address]);
            UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
            CheckHouse(id);
           }
           case DIALOG_HOUSE+2:
           {
            if(!response) return 1;
            new string[210];
            new id = Player[playerid][Houseid];
            format(House[id][HouseName], 32, "%s", inputtext);
            format(string,sizeof(string),"{E0BC1B}Owner: "COL_WHITE"%s\n{E0BC1B}House name: "COL_WHITE"%s\n{E0BC1B}Price: "COL_WHITE"%d\n{E0BC1B}Level: "COL_WHITE"%d\n{E0BC1B}Rent price: "COL_WHITE"%d\n{E0BC1B}Address: "COL_WHITE"%s\n (/renthouse)",House[id][Owner],House[id][HouseName],House[id][Price],House[id][Level],House[id][RentPrice],House[id][Address]);
            UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
            CheckHouse(id);
           }
           case DIALOG_HOUSE+3:
           {
            if(!response) return 1;
            new string[128];
            new id = Player[playerid][Houseid];
            if(strlen(inputtext) >= 5 || strlen(inputtext) < 4) return ShowPlayerDialog(playerid,DIALOG_HOUSE+3,DIALOG_STYLE_INPUT,""COL_WHITE"Lock Password",""COL_BLUE"Type new password","Insert","Close"),SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Just four numbers");
            format(House[id][LockPass],5,"%d",strval(inputtext));
            format(string,sizeof(string),"New password is %d",strval(inputtext)); SCM(playerid,-1,string);
            CheckHouse(id);
           }
           }
    return 0;
}
Like This


Re: Problem with FS which have a Dialog System - iggy1 - 07.07.2013

Yes but don't forget you must do that in ALL of your scripts GM/FS.

You can also return 1, if the dialog was found to prevent further checks. (like in the code i posted above)