12.05.2013, 05:14
Well, use timers to give these random messages. Then set a var to 'true' (for example) to check in OnPlayerUpdate who goes 140KM/H. If someone goes faster then 140KM/H while that var is true, immediately set the var to false and that player will win. Small examle:
Something like that (it's just an example !!)
pawn Код:
//Somewhere in the script
#define MAX_WAIT_TIME 1200000 //20 minutes (to calculate minutes: 1000 * 60 * minutes)
new bool:speedReactionTest = false; //The var to check for those tests
forward randomSpeedReactionTest(); //Forward for the callback (for the timer)
public OnGameModeInit()
{
//Standard stuff
SetTimer("randomSpeedReactionTest", random(MAX_WAIT_TIME), false); //Set first timer, DONt repeat, random timer-time with a max of MAX_WAIT_TIME (so it can also take 1 second when it starts!)
return 1;
}
public OnPlayerUpdate(playerid)
{
if (speedReactionTest) //If the speed reaction test is opened...
{
if (GetPlayerSpeed(playerid) > 140) //Improvised function 'GetPlayerSpeed()'! Replace this with an actual workin speed checker
{
SendClientMessageToAll(COLOR_WHITE, "I won!"); //Don't forget formatting and such.. too lazy for it
GivePlayerMoney(playerid, 10000); //Player won 10,000 for it
speedReactionTest = false; //Test is over
SetTimer("randomSpeedReactionTest", random(MAX_WAIT_TIME), false); //Set timer again
}
}
return 1;
}
public randomSpeedReactionTest()
{
speedReactionTest = true; //Test started
SendClientMessageToAll(COLOR_GREEN, "[Speed reaction test] The first one who goes faster then 140KM/H will win $10,000!");
return 1;
}