AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How all array set to FALSE when all are true? (https://forums.alliedmods.net/showthread.php?t=233025)

spag 01-08-2014 15:47

How all array set to FALSE when all are true?
 
How all array set to FALSE when all are true?

My code: when start Show_Question random get number from MAX_NUM_OF_QUESTIONS, of total is 3 number, and then check if that number is false, he gives true and print that number question... when all 3 number are true i need set all to false, because my code stop work when all num are true..

This code didnt' work.. help.. And sorry for my bad english..



Code:

#define TASKID_QUESTION 33523

#define MAX_NUM_OF_CHAR 190

#define MAX_NUM_OF_QUESTIONS 3

new const Questions[MAX_NUM_OF_QUESTIONS][] =
{
        "Lietuvos sostine?",
        "Laikinoji Lietuvos sostine?",
        "Dabartiniai metai?"
}

new const Answers[][] =
{
        "Vilnius",
        "Kaunas",
        "2014"
}

new bool: AlreadyUsed[MAX_NUM_OF_QUESTIONS]

new Used_Question[1][MAX_NUM_OF_CHAR]
new Used_Answer[1][MAX_NUM_OF_CHAR]
new bool:reset = true;


public Show_Question()
{
        new Num = random_num(0, MAX_NUM_OF_QUESTIONS - 1);
 
        for (new i; i < sizeof(AlreadyUsed); i++)
        {
                if (!AlreadyUsed[i])
                {
                        reset = false;
                        server_print("[Debug] AlreadyUsed[%d] = false", i);
 
                        break;
                }
        }
 
        if (reset)
                arrayset(AlreadyUsed, false, sizeof(AlreadyUsed));
       
        if (!AlreadyUsed[Num])
        {
                AlreadyUsed[Num] = true

                copy(Used_Question[0], MAX_NUM_OF_CHAR - 1, Questions[Num])
                copy(Used_Answer[0], MAX_NUM_OF_CHAR - 1, Answers[Num])

                set_hudmessage(0, 255, 0, -1.0, 0.35, 0, 6.0, 10.0, 0.1, 0.2, 4);
                ShowSyncHudMsg(0, g_SyncHudMsg, "%s Klausimas: %s", g_szPrefix, Used_Question[0]);
                ColorChat(0, NORMAL, "!g%s!n Klausimas: !t%s", g_szPrefix, Used_Question[0]);

                set_task(10.0, "Show_Question", TASKID_QUESTION)
        }
        else
                set_task(0.1, "Show_Question");

        return PLUGIN_HANDLED
}


hornet 01-08-2014 19:35

Re: How all array set to FALSE when all are true?
 
After line new Num add in reset = true.

This way if it doesn't find a non used question it will reset.

spag 01-09-2014 13:30

Re: How all array set to FALSE when all are true?
 
Thank you very much!


All times are GMT -4. The time now is 10:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.