[FilterScript] Simple Math Quiz System
#1

INTRO:
It's just a simple FilterScript which allow you to create math quiz....

COMMANDS:
/quiz,(rcon admin)
/qanswer.


LINKS:
Dini 1.6 : Dini 1.6 or Dini 2 : Dini 2
Sscanf : Sscanf
ZCMD : ZCMD
MerRandom : MerRandom

CODES:
PHP Code:
//Simple Math Quiz System by Usman
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <merrandom>
#define COLOR_DARKRED 0xAA3333FF
#define COLOR_GREY 0xAFAFAFFF
#define COLOR_BROWN 0x654321FF
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_RED 0xFF0000FF
#define COLOR_LRED 0xFF4747FF
new quiz, quizans, quizpr;
new 
mtimer[MAX_PLAYERS];
public 
OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Simple Math Quiz System by Usman");
    print(
"--------------------------------------\n");
    
    
SetTimer("timer_quiz", 400000, 1);
    return 
1;
}
CMD:quiz(playerid, params[])
{
    
//Add your admin level here i am not using any thing!
    
SendClientMessage(playerid, COLOR_YELLOW, "You have started the math quiz.");
    
quiz = 0;
    
timer_quiz();
    return 
1;
}
CMD:qanswer(playerid,params[])
{
    new 
playername[25], ans, str[256];
    if(
quiz == 0) return SendClientMessage(playerid, COLOR_RED, "Error: There is no math quiz right now or it might have been already solved.");
    
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    if (
mtimer[playerid] != 0) return SendClientMessage(playerid, COLOR_RED, "Error: You are muted smart ass!");
    if(
sscanf(params,"d", ans)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /qanswer [answer]");
    if(
ans != quizans) return SendClientMessage(playerid, COLOR_RED, "Wrong answer better luck next time!");
     
format(str, sizeof(str), "Well done {FF00FF}%s{FFFF00} you have answered an correct answer and won $%d.", playername, quizpr);
     
SendClientMessage(playerid, COLOR_YELLOW, str);
    
GivePlayerMoney(playerid, quizpr);
     
format(str, sizeof(str), "[Math Quiz]{FFFFFF}: {FF00FF}%s{FFFFFF} have answered the quiz with %d and won $%d.", playername, ans, quizpr);
    for (new 
i = 0; i < MAX_PLAYERS; i++)
    {
        if (
IsPlayerConnected(i))
        {
         
SendClientMessage(i, COLOR_RED, str);
        }
    }
    
quiz = 0;
    return 
1;
}
forward timer_quiz();
public 
timer_quiz()
{
    if(
quiz == 0)
    {
        new 
v, v1, v2, v3, mon;
        
v = random(50); v1 = random(20); v2 = random(30); v3 = random(80);
        
quiz = 1; quizans = v * v1 - v2 + v3;
        
mon = random(10000)+5000;
        
quizpr = mon;
        for (new 
i = 0; i < MAX_PLAYERS; i++)
        {
            if (
IsPlayerConnected(i))
            {
                new 
str[256];
                
format(str, sizeof(str), "[Math Quiz]{FFFFFF}: What is the answer of %dx%d-%d+%d ?? ({FF00FF}$%d{FFFFFF}) [/qanswer].", v, v1, v2, v3, mon);
                
SendClientMessage(i, COLOR_RED, str);
            }
        }
    }
    return 
1;
} 
Reply


Messages In This Thread
Simple Math Quiz System - by Usmanmemon - 25.12.2017, 10:19
Re: Simple Math Quiz System - by Wherethescripters - 25.12.2017, 10:27
Re: Simple Math Quiz System - by BulletRaja - 25.12.2017, 10:27
Re: Simple Math Quiz System - by Usmanmemon - 25.12.2017, 10:44

Forum Jump:


Users browsing this thread: 1 Guest(s)