SA-MP Forums Archive
Trivia Event - 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)
+--- Thread: Trivia Event (/showthread.php?tid=533486)



Trivia Event - Akcent_Voltaj - 24.08.2014

how can I make so each play can type once for answer if its wrong he cant answer twice too answer.. ideas please.


Re: Trivia Event - CutX - 24.08.2014

pawn Код:
//new bool var
new bool:answered[MAX_PLAERS];

//in your command...
if(answered[playerid]) return SendClientMessage(playerid,-1,"already answered...");
answered[playerid]=true;
don't forget to set it back 2 false after the event


Re: Trivia Event - Akcent_Voltaj - 24.08.2014

yes thanks. repped!


Re: Trivia Event - Akcent_Voltaj - 25.08.2014

how can I make so only 1 minute from trivia or bye..?? because there has to be an thing so if he dosent answer so after he cant answer..


Re: Trivia Event - Team_PRO - 25.08.2014

you can use timers.


Re: Trivia Event - Akcent_Voltaj - 25.08.2014

can you show me like CutX please?


Re: Trivia Event - Team_PRO - 25.08.2014

Here is example

pawn Код:
forward EndTrivia();

Timer for the Trivia:
pawn Код:
ReactionTest[0] = GetTickCount(); //Start Counting Down
timer2[3] = SetTimer("EndTrivia", 10000, false); //Timer for the Trivia, Timer sets to 1 mininute

If no one answers the Trivia:
pawn Код:
public EndTrivia()
{
    switch(typem)
    {
        case 0:
        {
            format(strg, sizeof(strg), "No one won the Trivia the answer is '%d'", answer);
            SendClientMessageToAll(YOUR_COLOR, strg);
        }
        case 1:
        {
            format(strg, sizeof(strg), "No one won the Trivia the answer is '%d'", answer);
            SendClientMessageToAll(YOUR_COLOR, strg);
        }
        case 2:
        {
            format(strg, sizeof(strg), "No one won the Trivia the answer is '%d'", answer);
            SendClientMessageToAll(YOUR_COLOR, strg);
        }
    }
    endm = 0;
    KillTimer(timer2[3]);
    return 1;
}
i am not better in explaining so hope you get my idea


Re: Trivia Event - Akcent_Voltaj - 25.08.2014

hmm..


Re: Trivia Event - CutX - 25.08.2014

Quote:
Originally Posted by Akcent_Voltaj
Посмотреть сообщение
how can I make so only 1 minute from trivia or bye..?? because there has to be an thing so if he dosent answer so after he cant answer..
never ever use timers for stuff like this, as it's just a waste of resources.
We can use the Unix timestamp (until January 19, 2038 ) instead.
here's an example of an script which allows the usage of rcon command "word" after the
"start" command has been issued for exactly 1 minute.

pawn Код:
#include <a_samp>

new ev_init;//var holding the timestamp of when "start" cmd has been issued

main(){}

public OnFilterScriptInit()
{
    print("dummy_2 has been loaded!");

    return 1;
}

public OnRconCommand(cmd[])
{
    if(!(strcmp(cmd,"start")))
    {
        ev_init = gettime();//take the current timestamp as start-time
        printf("event started: %d\n",ev_init);
    }
    else if(!(strcmp(cmd,"word")))
    {
        if(((gettime()) - (ev_init)) > 60) print("time is up! can't use that");//if current timestamp - start-time > 60 (1min) then time's up
        else print("works!");//if it's not, this will appear
    }
    return 1;
}
so simply what you need to do is create a variable for the start-time,
fill it with the current timestamp once you start the event and then
everytime when ppls answer just check if the timestamp of when they answered - event-start is greater than 60.
if it is, this means that time's up and you could just return a message saying something like "time is up! these kind of events only last for 1 minute"


Re: Trivia Event - Akcent_Voltaj - 26.08.2014

thanks! solved!