Trivia Event
#1

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

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
Reply
#3

yes thanks. repped!
Reply
#4

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..
Reply
#5

you can use timers.
Reply
#6

can you show me like CutX please?
Reply
#7

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
Reply
#8

hmm..
Reply
#9

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"
Reply
#10

thanks! solved!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)