02.02.2009, 14:59
pawn Код:
#include <a_samp>
forward Drift(playerid,vehicleid);
new Drifting[MAX_PLAYERS];
new Float:x,Float:y,Float:z;
new Float:nx,Float:ny;
new Float:tang;
new Float:ann;
new string[256];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Testing Drift System");
print("--------------------------------------\n");
SetTimer("Drift",200,1);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerEnterVehicle(playerid,vehicleid)
{
Drifting[playerid] = 1;
return 1;
}
public OnPlayerExitVehicle(playerid,vehicleid)
{
Drifting[playerid] = 0;
return 1;
}
public Drift(playerid)
{
if(Drifting[playerid] != 0)
{
new vehicleid = GetPlayerVehicleID(playerid);
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid,nx,nx,10);
tang = atan2(nx-x,ny-y);
GetVehicleZAngle(vehicleid,ann);
format(string,sizeof(string),"Tangen: %f Ang %f", tang, ann);
GameTextForPlayer(playerid, string, 100, 6);
return 1;
}else return 0;
}
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid)) {
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}