Maths Minigame
#1

Hi I need help making this script send a reminder for the question every 30 seconds or so, because if no one answers it never asks another question can anyone help me?

//Colors
#define MWHITE "{FFFFFF}"
#define MGREEN "{33FF33}"
#define MCOLOR_WHITE 0xFFFFFFAA
#define mred 0xFF0000AA
forward startmath(playerid);
forward endmath();
new bool:mathson;
new answer;
new stopper;

ongamemodeinit

//Maths Minigame
SetTimer("startmath",35000,1);
mathson = false;

//------------------------------Maths Start+Stop--------------------------------
COMMAND:domath(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
#pragma unused params
startmath(playerid);
}
else
{
return 0;
}
return 1;
}

COMMAND:ans(playerid,params[])
{
if(mathson == true)
{
if(!strlen(params)) return SendClientMessage(playerid,red,""#MWHITE"Usage: "#MGREEN"/Ans [Answer]");
new tehans;
tehans = strval(params);
if(tehans == answer)
{
new mname[16];
GetPlayerName(playerid,mname,16);
new str[128];
format(str,128,""#MGREEN"»["#MWHITE"WINNER"#MGREEN"]: "#MWHITE"%s: Has Won With The Answer "#MGREEN"%d!«",mname,answer);
SendClientMessageToAll(MCOLOR_WHITE,str);
mathson = false;
KillTimer(stopper);
GivePlayerMoney(playerid,10000);
SetPlayerScore(playerid, GetPlayerScore(playerid) + 50 );
}
else
{
SendClientMessage(playerid,0xAA3333AA,""#MGREEN"»" #MWHITE"OOOPS!!! Try Again "#MGREEN"«");
SetPlayerScore(playerid, GetPlayerScore(playerid) - 5 );
}
}
else
{
return SendClientMessage(playerid,0xAA3333AA,""#MWHITE"»M aths Quiz "#MGREEN"Isn't Running"#MWHITE"«");
}
return 1;
}
//--------------------------------Maths Minigame--------------------------------
public endmath()
{
mathson = false;
new string[128];
format(string,200,""#MGREEN"»["#MWHITE"ANSWER"#MGREEN"]: "#MWHITE"The answer was: "#MGREEN"%d!«",answer);
SendClientMessageToAll(MCOLOR_WHITE,string);
return 1;
}

public startmath(playerid)
{
if(mathson == false)
{
KillTimer(stopper);
mathson = true;
new rand1;
new rand2;
new rand3;
new rand4;
rand1 = random(222);
rand2 = random(111);
rand4 = random(50);
if(rand3 == 0)
{
answer = rand1 + rand2 + rand4;
new str[200];
format(str,200,""#MGREEN"»["#MWHITE"MATHS"#MGREEN"]: "#MWHITE"Answer %d+%d+%d to win $10000 and 50 points! Use "#MGREEN"/ans [Answer]«",rand1,rand2,rand4);
SendClientMessageToAll(MCOLOR_WHITE,str);
}
else if(rand3 == 1)
{
answer = rand1 + rand2 + rand4;
new str[200];
format(str,200,""#MGREEN"»["#MWHITE"MATHS"#MGREEN"]: "#MWHITE"Answer %d+%d-%d to win $10000 and 50 points! Use "#MGREEN"/ans [Answer]«",rand1,rand2,rand4);
SendClientMessageToAll(MCOLOR_WHITE,str);
}
stopper = SetTimer("endmaths",70000,0);
}
return 1;
}
Reply
#2

Use [pawn] tags and use proper indent please.
Reply
#3

Create a Var called Answered or something and just loop every 30 seconds if it's been answered. If not , run it again
Reply
#4

Can anyone give me an example I have just tried to SetTimerEx to see if I can make it loop, SetTimerEx("startmath",35000, true, "i");
Reply
#5

SetTimer("startmath", 30000, 1);
Reply
#6

Im not a good scripter I tried to learn a few years ago when I was younger and I stopped, the old timer was just like that it won't change it or make it work how can I do this or will no one give me some real help?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)