Use a command only once
#7

Use an array.

Example (obviously this might not work and isn't the most efficient example, but it should give you an idea on how to do it):

pawn Code:
#include <a_samp>

#define RAND_DIALOG0     0
#define RAND_DIALOG1     1
// etc

new bool: pDialogUsed[MAX_PLAYERS][5];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/randomdialog", cmdtext, true, 10) == 0)
    {
        jump:
   
        switch(random(5))
        {
            case 0:
            {
                if(pDialogUsed[playerid][0] == false)
                {
                    ShowPlayerDialog(playerid, RAND_DIALOG0, DIALOG_STYLE_MSGBOX, "Insert Info Here", "Random Dialog 0", "Select", "Select");
                }
           
                else goto jump;
            }
           
            case 1:
            {
            // etc
            }

        }

        return 1;
    }
   
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == RAND_DIALOG0)
    {
        if(response || !response)
        {
            pDialogUsed[playerid][0] = true;
            // do some stuff
        }

        return 1;
    }

    return 0;
}
Don't expect fully working code neither, this is a sub section to ask help with scripting, not for people to make your scripts for you.
Reply


Messages In This Thread
Use a command only once - by EddD - 04.08.2014, 16:19
Re: Use a command only once - by xHanks - 04.08.2014, 16:22
Respuesta: Use a command only once - by EddD - 04.08.2014, 16:25
Respuesta: Use a command only once - by EddD - 04.08.2014, 16:45
Re: Use a command only once - by SickAttack - 04.08.2014, 17:03
Respuesta: Use a command only once - by EddD - 04.08.2014, 19:01
Re: Use a command only once - by Dignity - 04.08.2014, 19:10

Forum Jump:


Users browsing this thread: 1 Guest(s)