Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ShopAPI>
- #include <sdktools>
- public Plugin myinfo =
- {
- name = "HidonMath",
- author = "JuSTaR",
- description = "Hidonim Math",
- version = "1.0",
- url = "https://www.fxp.co.il/"
- }
- const int MAX_NUMBER = 999;
- const int MIN_NUMBER = 100;
- const int PRIZE = 100;
- Handle:HudTimer;
- int DisplayTime = 60;
- float TimerTick = 1.0;
- char DisplayMsg[64];
- char Answer[8];
- public OnPluginStart()
- {
- RegConsoleCmd("say", LookForAnswer);
- RegAdminCmd("start_hidon_math", Start_Hidon_Math, ADMFLAG_RCON);
- RegAdminCmd("stop_hidon_math", Stop_Hidon_Math, ADMFLAG_RCON);
- }
- public Action Stop_Hidon_Math(int client, int args)
- {
- Reset_Hidon_Math();
- }
- public Action Start_Hidon_Math(int client, int args)
- {
- if (HudTimer != null)
- Reset_Hidon_Math();
- int num1 = GetRandomInt(MIN_NUMBER, MAX_NUMBER);
- int num2 = GetRandomInt(MIN_NUMBER, MAX_NUMBER);
- Format(DisplayMsg, sizeof(DisplayMsg), "%s%d%s%d%s", "[ Math Hidon ]\nHow much is: ", num1, " + ", num2, "?");
- IntToString(num1 + num2, Answer, sizeof(Answer));
- HudTimer = CreateTimer(TimerTick, SetHud, _, TIMER_REPEAT);
- PrintToChatAll("[ Math Hidon ] How much is: %d + %d?", num1, num2);
- }
- public Action SetHud(Handle:timer)
- {
- SetHudTextParams(-1.0, 0.15, 1.0, GetRandomInt(0, 255), GetRandomInt(0, 255), GetRandomInt(0, 255), 255, 1, TimerTick, 0.0, 0.0);
- if (DisplayTime > 0)
- ShowHud(DisplayMsg);
- else
- {
- Reset_Hidon_Math();
- PrintToChatAll("[ Math Hidon ] The answer was %s. Nobody answered correctly.. what a shame..", Answer);
- }
- DisplayTime--;
- }
- public void ShowHud(char msg[64])
- {
- for(new i = 1; i <= MaxClients; i++) // display hud
- if(IsClientInGame(i) && !IsFakeClient(i))
- ShowHudText(i, -1, msg);
- }
- public void Reset_Hidon_Math()
- {
- if (HudTimer != null)
- {
- KillTimer(HudTimer);
- HudTimer = null;
- }
- DisplayTime = 60;
- }
- public Action LookForAnswer(int client, int args)
- {
- if (HudTimer != null)
- {
- char arg[64];
- GetCmdArg(1, arg, sizeof(arg));
- if (StrEqual(arg, Answer, false))
- {
- int first_color[4];
- int second_color[4];
- for (int i = 0; i < 4; i++)
- {
- first_color[i] = GetRandomInt(0, 255);
- second_color[i] = GetRandomInt(0, 255);
- }
- Reset_Hidon_Math();
- SetHudTextParamsEx(-1.0, 0.15, 15.0, first_color, second_color, 2, 1.0, 0.3, 0.3);
- Format(DisplayMsg, sizeof(DisplayMsg), "%s%N%s%d%s", "[ Math Hidon ]\n", client, " has won ", PRIZE, " Points!");
- ShowHud(DisplayMsg);
- PrintToChatAll("[ Math Hidon ] %N has answered [ %s ], and won %d Points!", client, Answer, PRIZE);
- Native_GivePoints(client, PRIZE);
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment