Get max speed
#1

I'm updating my drivers exam for my server, but I need to know how to get the highest kmh achieved at the end of the test, and if its above 60kmh the test fails.

Thing is that I don't know how to get the highest speed achieved, so if anyone would be kind enough to tell me how I get the highest speed achieved within 2 checkpoints, that'd be appreciated.

If it helps, using the gf script edit.
Reply
#2

In a timer, regularly check the player's speed and add it to a variable, but also check if their speed was higher than the varibale.

like:

pawn Код:
Timer()
{
     if(PlayerSpeed > SpeedVariable)
     {
          SpeedVariable = PlayerSpeed;
     }
     if(PlayerSpeed > 60)
     {
          Failed = true;
     }    
}
Reply
#3

Quote:
Originally Posted by Nimrod
Посмотреть сообщение
In a timer, regularly check the player's speed and add it to a variable, but also check if their speed was higher than the varibale.

like:

pawn Код:
Timer()
{
     if(PlayerSpeed > SpeedVariable)
     {
          SpeedVariable = PlayerSpeed;
     }
     if(PlayerSpeed > 60)
     {
          Failed = true;
     }    
}
Under what callback does that go?
Reply
#4

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
Under what callback does that go?
Bumpie
Reply
#5

http://pastebin.com/aLPeaSfT

Use it on a timer.

pawn Код:
if (GetPlayerSpeed(i) >= 55.0){
    // Failure
}
Reply
#6

You can do something like this:

pawn Код:
new bool: g_SpeedTestFail[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
     if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == VEHICLE_STATE_DRIVER && DrivingTest[playerid] == true)
     {
           if(GetPlayerVehicleSpeed(playerid) >= 62)
           {
               g_SpeedTestFail[playerid] = true;
           }
     }
     return 1;
}
Reply
#7

Make sure you have the correct speed calculation.

Код:
return floatsqroot((velocity[0] * velocity[0]) + (velocity[1] * velocity[1]) + (velocity[2] * velocity[2])) * 100.0;
This is incorrect is should be this.

Код:
return floatsqroot((velocity[0] * velocity[0]) + (velocity[1] * velocity[1]) + (velocity[2] * velocity[2])) * 180.0;
That should give real scale results.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)