Hide Dialog
#1

I made a dialog for Redsands Casino, you can purchase drinks and other stuff. When they drink too much alcohol, they die from it. I made it so if people don't have much health, the drinks refill their health, therefore, the buying dialog is left open. At random times, they will die from alcohol poisoning, but the problem is when they die from it, the buy dialog is still open (I use DIALOG_STYLE_LIST). I want it to close when they die, but there is no function for it. How can I do that?
Reply
#2

Mind posting the code?
Reply
#3

Search ^^

pawn Код:
stock hideDialog( playerid )
    return ShowPlayerDialog( playerid, -1, 0, "","", "", "" ), 1;
Sergei's post.
Reply
#4

Should be self explanatory:

pawn Код:
// onplayerenterdynamiccp

    if(checkpointid == rsrobcp)
    {
        ShowPlayerDialog(playerid,9403,DIALOG_STYLE_LIST,"Purchase Items...","1. Beer ($500)\n2. Wine ($1000)\n3. Drugs (50g/$15,000)\n4. "#COL_RED"Casino Robbery","Purchase","Cancel");
    }

// ondialogresponse

        if(dialogid == 9403)
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Beer Purchased For $500. Don't Drink And Drive!");
                        //SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DRINK_BEER);
                        GivePlayerMoney(playerid,-500);
                        new Float: rhealth;
                        GetPlayerHealth(playerid,rhealth);
                        SetPlayerHealth(playerid,rhealth+15);
                        new rand = random(15);
                        if(rand >= 0 && rand <=10)
                        {
                            SetPlayerDrunkLevel(playerid,3000);
                            ApplyAnimation(playerid, "BAR", "dnk_stndM_loop", 3.0,0,0,0,0,0,0);
                            //SendClientMessage(playerid,red,"You Are A Little Tipsy. Drinking More May Result In Death!");
                        }
                        if(rand >=11 && rand <= 15)
                        {
                            new name[24],string[128];
                            GetPlayerName(playerid,name,24);
                            format(string,128,"%s (%d) Has Died From Alcohol Poisoning.",name,playerid);
                            SendClientMessageToAll(COLOR_BROWN,string);
                            GameTextForPlayer(playerid,"~r~died from ~n~alcohol poisoning",5000,3);
                            SetPlayerHealth(playerid,0);
                            SetPVarInt(playerid,"Alive",0);
                            SendDeathMessage(INVALID_PLAYER_ID,playerid,47);
                            if(GetPVarInt(playerid,"Alive") == 0)
                            {
                                SetPlayerColor(playerid,grey);
                            }
                        }
                        ShowPlayerDialog(playerid,9403,DIALOG_STYLE_LIST,"Purchase Items...","1. Beer ($500)\n2. Wine ($1000)\n3. Drugs (50g/$15,000)\n4. "#COL_RED"Casino Robbery","Purchase","Cancel");
                    }
                    case 1:
                    {
                        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Wine Purchased For $1,000. Don't Drink And Drive!");
                        //SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DRINK_WINE);
                        GivePlayerMoney(playerid,-1000);
                        new Float: rhealth;
                        GetPlayerHealth(playerid,rhealth);
                        SetPlayerHealth(playerid,rhealth+30);
                        new rand = random(15);
                        if(rand >= 0 && rand <=10)
                        {
                            SetPlayerDrunkLevel(playerid,3000);
                            ApplyAnimation(playerid, "BAR", "dnk_stndM_loop", 3.0,0,0,0,0,0,0);
                            //SendClientMessage(playerid,red,"You Are A Little Tipsy. Drinking More May Result In Death!");
                        }
                        if(rand >=11 && rand <= 15)
                        {
                            new name[24],string[128];
                            GetPlayerName(playerid,name,24);
                            format(string,128,"%s (%d) Has Died From Alcohol Poisoning.",name,playerid);
                            SendClientMessageToAll(COLOR_BROWN,string);
                            GameTextForPlayer(playerid,"~r~died from ~n~alcohol poisoning",5000,3);
                            SetPlayerHealth(playerid,0);
                            SetPVarInt(playerid,"Alive",0);
                            SendDeathMessage(INVALID_PLAYER_ID,playerid,47);
                            if(GetPVarInt(playerid,"Alive") == 0)
                            {
                                SetPlayerColor(playerid,grey);
                            }
                        }
                        ShowPlayerDialog(playerid,9403,DIALOG_STYLE_LIST,"Purchase Items...","1. Beer ($500)\n2. Wine ($1000)\n3. Drugs (50g/$15,000)\n4. "#COL_RED"Casino Robbery","Purchase","Cancel");
                    }
                    case 2:
                    {
                        ShowPlayerDialog(playerid,5,DIALOG_STYLE_LIST,"Purchase Drugs...","1. 50 Grams ($15,000)","Purchase","Cancel");
                    }
                    case 3:
                    {
                        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Casino Robbery Coming Soon!");
                    }
                }
            }
        }
Reply
#5

..

pawn Код:
stock hideDialog( playerid )
    return ShowPlayerDialog( playerid, -1, 0, "", "", "", "" ), 1;

public OnPlayerDeath( playerid, killerid ) {
    hideDialog( playerid );

    // More stuffs

    return 1;
}
Something like that?
Reply
#6

Ah thanks a lot, didn't see your code because I posted my code first
Reply
#7

Sorry for this double post, but Basicz, it doesn't work.

Any solutions?
Reply
#8

Quote:

An ID to assign this dialog to, so responses can be processed. Max dialogid is 32767. Using negative values will close any open dialog.

From wiki. Just like what Basicz said.
ShowPlayerDialog(playerid,-1,0,"","","","");
Reply
#9

For some reason, it doesn't work at all. I put that under OnPlayerDeath and under the part where the player dies from poisoning, and still stays open :S
Reply
#10

Try this:
pawn Код:
ShowPlayerDialog(playerid, -1, DIALOG_STYLE_MSGBOX, " ", " ", " ", " ");//space added
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)