SA-MP Forums Archive
Drift System - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Drift System (/showthread.php?tid=65382)



Drift System - LibertyWorld - 12.02.2009

I really dont know where to ask.

I searched and didnt find anything.

I saw on some servers when you drift you get points.

Like a textdraw that shows how many points you got for drifting is there any available.

If not can someone explain me a bit how am i supposed to make it.

Thanks


Re: Drift System - [RP]Rav - 12.02.2009

I think it's a matter of comparing the angle of the car with the direction someone is going in.. for example if the angle is 90 (facing east), but the car's 'y-position' changes positively (car is moving north) that person is drifting


Re: Drift System - LibertyWorld - 12.02.2009

Quote:
Originally Posted by Rav
I think it's a matter of comparing the angle of the car with the direction someone is going in.. for example if the angle is 90 (facing east), but the car's 'y-position' changes positively (car is moving north) that person is drifting
Can you please show me some examples, because i dont have any idea how to make it.

and i also saw in a server when you get nos it stays only for like 1-2 seconds after it stops but its infinity.
how to make that also?

Thanks


Re: Drift System - [RP]Rav - 12.02.2009

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]);
}



Re: Drift System - LibertyWorld - 12.02.2009

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]);
}
Sorry, i dont know how to make it...

EDIT :I found this, can it help me?

http://forum.sa-mp.com/index.php?topic=87047.0


Re: Drift System - [RP]Rav - 12.02.2009

well, I don't do entire scripts on request, sorry..


Re: Drift System - LibertyWorld - 12.02.2009

I found this, can it help me?

http://forum.sa-mp.com/index.php?topic=87047.0


Re: Drift System - [RP]Rav - 12.02.2009

doesn't look like it..


Re: Drift System - LibertyWorld - 12.02.2009

and how about this

i saw in a server when you get nos it stays only for like 1-2 seconds after it stops but its infinity.
how to make that?


Re: Drift System - watkijkje - 12.02.2009

Quote:
Originally Posted by plɹoʍ ʎʇɹǝqıl
and how about this

i saw in a server when you get nos it stays only for like 1-2 seconds after it stops but its infinity.
how to make that?
http://forum.sa-mp.com/index.php?action=search;advanced