SA-MP Forums Archive
Hide Dialog - 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: Hide Dialog (/showthread.php?tid=271787)



Hide Dialog - grand.Theft.Otto - 25.07.2011

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?


Re: Hide Dialog - Kush - 25.07.2011

Mind posting the code?


Re: Hide Dialog - Basicz - 25.07.2011

Search ^^

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


Re: Hide Dialog - grand.Theft.Otto - 25.07.2011

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!");
                    }
                }
            }
        }



Re: Hide Dialog - Basicz - 25.07.2011

..

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

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

    // More stuffs

    return 1;
}
Something like that?


Re: Hide Dialog - grand.Theft.Otto - 25.07.2011

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


Re: Hide Dialog - grand.Theft.Otto - 25.07.2011

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

Any solutions?


Re: Hide Dialog - =WoR=Varth - 26.07.2011

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,"","","","");


Re: Hide Dialog - grand.Theft.Otto - 26.07.2011

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


Re: Hide Dialog - =WoR=Varth - 26.07.2011

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