Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Create ReactionContest or Question by command!
- Idea in Zher0's script.
- Created by BuzZ
- Credits to
- Zher0
- Y_Less
- BuzZ
- */
- #include <a_samp>
- #include <sscanf2>
- #include <YSI\y_commands>
- #define PRIZE_PER_CONTEST 1000 //When player types the contest first he gets the $$$ amount putted in the define
- #define PRIZE_PER_CONTEST_SCO 5 //When player types the contest first he gets the score amount putted in the define
- #define COLOR_ORANGE 0xFF8000FF
- #define COLOR_YELLOW 0xFFFF00FF
- #define QUESTION_TIMER 1000*30 //30 seconds - The time where typing contest ends (CHANGE IT)
- #define TYPING_TIMER 1000*30 //30 seconds - The time where typing contest ends (CHANGE IT)
- new bool:Starts = false,
- TypeGame = -1,
- targetanswer[128],
- targetword[128],
- Timer,
- question[128];
- forward KillTest();
- #if defined FILTERSCRIPT
- #else
- public OnFilterScriptInit()
- {
- print("\n");
- print("Create Reaction Contest or Question by command!");
- print("All Rights Reserved (c) 2013");
- print("[FS] Loaded!");
- print("\n");
- Starts = false;
- TypeGame = -1;
- KillTimer(Timer);
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n");
- print("Create Reaction Contest or Question by command!");
- print("All Rights Reserved (c) 2013");
- print("[FS] Unloaded!");
- print("\n");
- Starts = false;
- TypeGame = -1;
- KillTimer(Timer);
- return 1;
- }
- #endif
- public OnPlayerText(playerid, text[])
- {
- new str[128];
- if(Starts == true)
- {
- if(TypeGame == 0) //Question
- {
- if(strcmp(text, targetanswer, true) == 0)
- {
- format(str, sizeof(str), "ANSWER: Player %s[%d] answer the question '%s' the answer is '%s'", pName(playerid), playerid, question, targetanswer);
- SendClientMessageToAll(COLOR_ORANGE, str);
- format(str, sizeof(str), "REACTIONTEST: Player %s[%d] wins '$%d + %d score'", pName(playerid), playerid, PRIZE_PER_CONTEST, PRIZE_PER_CONTEST_SCO);
- SendClientMessageToAll(COLOR_YELLOW, str);
- GivePlayerMoney(playerid, PRIZE_PER_CONTEST);
- SetPlayerScore(playerid, GetPlayerScore(playerid) + PRIZE_PER_CONTEST_SCO);
- Starts = false;
- TypeGame = -1;
- KillTimer(Timer);
- return 0;
- }
- }
- if(TypeGame == 1) //Typing
- {
- if(strcmp(text, targetword, true) == 0)
- {
- format(str, sizeof(str), "REACTIONTEST: Player %s[%d] wins '$%d + %d score' for typing '%s' as first", pName(playerid), playerid, PRIZE_PER_CONTEST, PRIZE_PER_CONTEST_SCO, targetword);
- SendClientMessageToAll(COLOR_YELLOW, str);
- GivePlayerMoney(playerid, PRIZE_PER_CONTEST);
- SetPlayerScore(playerid, GetPlayerScore(playerid) + PRIZE_PER_CONTEST_SCO);
- Starts = false;
- TypeGame = -1;
- KillTimer(Timer);
- return 0;
- }
- }
- }
- return 1;
- }
- public KillTest()
- {
- new str[128];
- if(Starts == true)
- {
- if(TypeGame == 0)
- {
- format(str, sizeof(str), "QUESTION: No one answers the question '%s', The answer is '%s'", question, targetanswer);
- SendClientMessageToAll(COLOR_YELLOW, str);
- Starts = false;
- TypeGame = -1;
- }
- if(TypeGame == 1)
- {
- format(str, sizeof(str), "TYPING: No one types the word '%s'", targetword);
- SendClientMessageToAll(COLOR_YELLOW, str);
- Starts = false;
- TypeGame = -1;
- }
- }
- KillTimer(Timer);
- return 1;
- }
- YCMD:startquestion(playerid, params[], help)
- {
- #pragma unused help
- new str[128];
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Invalid: You're not allowed to use this command!");
- if(Starts == true) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: There is current contest starting, Please wait...");
- if(sscanf(params, "p<,>s[128]s[128]", question, targetanswer)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /startquestion [question] [answer]");
- format(str, sizeof(str), "QUESTION: '%s', First who answer it gets '$%d + %d score'", question, PRIZE_PER_CONTEST, PRIZE_PER_CONTEST_SCO);
- SendClientMessageToAll(COLOR_YELLOW, str);
- SendClientMessageToAll(-1, "QUESTION: You only have 30 seconds to answer it");
- SendClientMessage(playerid, -1, "Question has been started, The question timer will end about 30 seconds");
- Starts = true;
- TypeGame = 0;
- Timer = SetTimer("KillTest", QUESTION_TIMER, false);
- return 1;
- }
- YCMD:starttype(playerid, params[], help)
- {
- #pragma unused help
- new str[128];
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Invalid: You're not allowed to use this command!");
- if(Starts == true) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: There is current contest starting, Please wait...");
- if(sscanf(params, "s[128]", targetword)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /starttype [word]");
- format(str, sizeof(str), "REACTION: First who types '%s', gets '$%d + %d score'", targetword, PRIZE_PER_CONTEST, PRIZE_PER_CONTEST_SCO);
- SendClientMessageToAll(COLOR_YELLOW, str);
- SendClientMessageToAll(-1, "QUESTION: You only have 30 seconds to answer it");
- SendClientMessage(playerid, -1, "Question has been started, The type timer will end about 30 seconds");
- Starts = true;
- TypeGame = 1;
- Timer = SetTimer("KillTest", TYPING_TIMER, false);
- return 1;
- }
- //==============================================================================
- stock pName(playerid)
- {
- new getname[24];
- GetPlayerName(playerid, getname, 24);
- return getname;
- }
Advertisement
Add Comment
Please, Sign In to add comment