Use a command only once
#1

I need an example only.

as I can recall a DIALOG only once?.
the second time you call it is not possible.
Reply
#2

You can make a global variables, for example:

pawn Code:
//On the top of gamemode
new Cancall[MAX_PLAYERS];

//Then in your script you will add:
if(Cancall[playerid] == 1) { //script here and then add in your script the next
Cancall[playerid] = 0;
Reply
#3

the problem is that the DIALOG are random.
and do not do that with random DIALOG.

as it would be with that?
Reply
#4

please help me
Reply
#5

pawn Code:
#define MAX_DIALOGS_USED 10
new bool:DialogUsed[MAX_PLAYERS][MAX_DIALOGS_USED];

// Disalow a player to use the dialog 5 again:
DialogUsed[playerid][5] = true;

// Checking:
if(DialogUsed[playerid][5] == true) SendClientMessage(playerid, 0xFFFFFFFF, "You can't use the dialog 5 again!")
Reply
#6

your code does not work.

the problem is it i have DIALOG at random.

What I want :

when leaving a function of a random system. this function does not return that came out.

How I can make a TOP 5 of the functions, but in order?. example

First random function was SetPlayerPos - and then write on the screen. "SetPlayerPos - one of five '
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)