how to make math quiz system No. + NO. - No. + No. Ans. +1 score driect anwser
#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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)