Speed Reaction Test
#1

Hello, How can i make a Speed Reaction Test Like :

Reaction Test:The first Player to Drive Faster than 140 KM/H wins!

Then the first player to go faster than 140 KM/H wins the money?

Please Help, Thanks.
Reply
#2

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:
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;
}
Something like that (it's just an example !!)
Reply
#3

Do i have to change "GetPlayerSpeed" Function to working speed checker like "GetPlayerVelocity" ?
Reply
#4

pawn Код:
stock GetVehicleSpeed(vehicleid)
{
        if(vehicleid != INVALID_VEHICLE_ID)
        {
                new Float:Pos[3],Float:VS ;
                GetVehicleVelocity(vehicleid, Pos[0], Pos[1], Pos[2]);
                VS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
                return floatround(VS,floatround_round);
        }
        return INVALID_VEHICLE_ID;
}
stock GetPlayerSpeed(playerid)
{
        if(playerid != INVALID_PLAYER_ID)
        {
                new Float:Pos[3],Float:PS;
                GetPlayerVelocity(playerid, Pos[0], Pos[1], Pos[2]);
                PS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
                return floatround(PS,floatround_round);
        }
        return INVALID_PLAYER_ID;
}
Change if (GetPlayerSpeed(playerid) > 140) to
pawn Код:
if (GetVehicleSpeed(GetPlayerVehicleID(playerid)) > 140)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)