how to make math quiz system No. + NO. - No. + No. Ans. +1 score driect anwser
#1

Run a repeating timer always. Create a global variable to store the answer. When the timer function comes, declare 4 variables or an array of size 4. Randomize numbers and make the sum. Use the global variable as to know the answer from the equation. Under OnPlayerText, check if the text is equal to the answer.

can any one script and give me in pm pls +rep for my help
Reply
#2

I'm not sure what you're asking for, since you have precise instructions right there!
This is not a place to ask people to script for you. If you are not sure what functions to use for any of those, feel free to check the SA-MP Wiki.
Reply
#3

Hi

Try this-

PHP код:
#include <a_samp>

new isenableanswernumber[4];

#define COL_RED   "{FF0000}"
#define COL_WHITE "{FFFFFF}"
#define COL_GREEN "{33AA33}"

public OnFilterScriptInit()
{
    
SetTimer("mathquiz",80000true);
    return 
1;
}

public 
OnPlayerText(playerid,text[])
{
    new 
string[128];
    if(
isenable && text[0] && answer == strval(text))
    {
        new 
CName[24];
        
GetPlayerName(playeridCName24);
        
isenable false;
        
format(stringsizeof(string),"%s answered the right answer of math quiz which was "COL_RED"%d "COL_WHITE"and wons 3 Scores, 1000$ Cash",CName,answer);
        
SendClientMessageToAll(-1string);
        
SetPlayerScore(playeridGetPlayerScore(playerid)+3);
        
GivePlayerMoney(playerid1000);
        return 
0;
    }
    return 
1;
}

forward mathquiz();
public 
mathquiz()
{
    new 
string[128];
    if(!
isenable)
    {
        switch(
random(4))
        {
            case 
0:
            {
                
answer = (number[0]=random(1000)) + (number[1]=random(840));
                
format(stringsizeof(string),"[Quiz] First one who Solve "COL_GREEN"%d"COL_WHITE" + "COL_GREEN"%d"COL_WHITE" will get 3 Scores, 1000$ Cash",number[0], number[1]);
            }
            case 
1:
            {
                do
                {
                    
answer = (number[0]=random(500)) - (number[1]=random(500));
                }
                while(
number[0] < number[1]);
                
format(stringsizeof(string),"[Quiz] First one who Solve "COL_GREEN"%d"COL_WHITE" - "COL_GREEN"%d"COL_WHITE" will get 3 Scores, 1000$ Cash",number[0], number[1]);
            }
            case 
2:
            {
                
answer = (number[0]=random(100)) * (number[1]=random(80));
                
format(stringsizeof(string),"[Quiz] First one who Solve "COL_GREEN"%d"COL_WHITE" * "COL_GREEN"%d"COL_WHITE" will get 3 Scores, 1000$ Cash",number[0], number[1]);
            }
            case 
3:
            {
                do
                {
                    
answer = (number[0]=random(1000)+1) / (number[1]=random(600)+1);
                }
                while(
number[0] % number[1]);
                
format(stringsizeof(string),"[Quiz] First one who Solve "COL_GREEN"%d"COL_WHITE" / "COL_GREEN"%d"COL_WHITE" will get 3 Scores, 1000$ Cash",number[0], number[1]);
            }
        }
        
SendClientMessageToAll(-1string);
        
isenable true;
    }
    else
    {
        
isenable false;
        
format(stringsizeof(string),"No one solved the math quiz which was "COL_RED"%d"COL_WHITE", so no one wons 1Score, 10$"answer);
        
SendClientMessageToAll(-1string);
    }
    return 
1;

Thank You.
Reply
#4

PHP код:
new QuizStage[MAX_PLAYERS];
new 
QuizNumbers[MAX_PLAYERS][4]
public 
OnPlayerText(playerid,text[])
{
    switch(
QuizStage[playerid])
    {
        case 
0:
        {
            new 
number strval(text);
            
QuizNumbers[playerid][0] = number;
            
SendClientMessage(playerid, -1"Now enter another number");
            
QuizStage[playerid]++;
        }
        case 
1:
        {
            new 
number strval(text);
            
QuizNumbers[playerid][1] = number;
            
SendClientMessage(playerid, -1"Now enter another number");
            
QuizStage[playerid]++;
        }
        case 
2:
        {
            new 
number strval(text);
            
QuizNumbers[playerid][2] = number;
            
SendClientMessage(playerid, -1"Now enter another number");
            
QuizStage[playerid]++;
        }
        case 
3:
        {
            new 
number strval(text);
            
QuizNumbers[playerid][3] = number;
            
SendClientMessage(playerid, -1"Now tell me what it equals!");
            
QuizStage[playerid]++;
        }
        case 
4:
        {
            new 
answer QuizNumbers[playerid][0] + QuizNumbers[playerid][1] + QuizNumbers[playerid][2] + QuizNumbers[playerid][3];
            new 
input strval(text);
            if(
input == answer)
            {
                
SendClientMessage(playerid, -1"Congratulations you got it right!");
            }
            else 
SendClientMessage(playerid, -1"Damn, that's incorrect!");
            
QuizStage[playerid] = 999;
            
QuizNumbers[playerid][0] = 0;
            
QuizNumbers[playerid][1] = 0;
            
QuizNumbers[playerid][2] = 0;
            
QuizNumbers[playerid][3] = 0;
            return 
1;
        }
    }
    return 
1;

I think this is what you was asking for? Not too sure, it doesn't make sense to do something like this, but this is what I think you wanted.
(Not tested)
Reply
#5

You yourself gave the exact steps to solve the problem. Search the internet fo guides showing you how to declare variables and Timers in PAWNO. Thats not hard to do.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)