12.02.2009, 07:44
Quote:
|
Originally Posted by Rav
Well, it would be quite a big script, so I'm just going to give you a small scheme you can work off
Код:
// make some variable for each player
Float: LastVehiclePos[MAX_PLAYERS][3];
// foward timer function
forward CheckDrift(playerid);
// OnPlayerConnect
SetTimerEx("CheckDrift"477, 0, "i", playerid);
LastVehiclePos[playerid][0] = 0.0;
LastVehiclePos[playerid][1] = 0.0;
LastVehiclePos[playerid][2] = 0.0;
// custom function
public CheckDrift(playerid)
{
// sometimes the entire idea of running the timer is useless
if (!IsPlayerConnected(playerid))
return 1;
if (!IsPlayerInAnyVehicle(playerid))
return 1;
// the timer isn't automatically repeated, so lets set a new timer now
SetTimerEx("CheckDrift"477, 0, "i", playerid);
new vid = GetPlayerVehicleID(playerid);
new Float: angle;
GetVehicleZAngle (vid, angle); // stores the angle of the car in a variable
// now comes the tricky bit.. which I suck at.. and that is maths..
// you need to take the position of the car, how it's moved and convert it radially (make it an angle)
// this way you can compare the vehicle angle and the driving angle
// compare the absolute (always positive) value of the angles, if they're more than 30 degrees apart, someone is drifting
if (floatabs(DrivingAngle-Angle) > 30)
{
// you need to do something here, 1 check isn't enough to see a full drift, could just be someone turning their car etc..
}
// save new position of the car
GetVehiclePos(vid, LastVehiclePos[playerid][0], LastVehiclePos[playerid][1], LastVehiclePos[playerid][2]);
}
|
EDIT :I found this, can it help me?
http://forum.sa-mp.com/index.php?topic=87047.0

