[HELP]Drifting System(almost done)
#1

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));
}
Yep, guys, i was checking, the angle, changes a lot, from 10 to 300, but, the atan2 thing, when drifting, it stays betwenn, 172 - 175, like, what am i supposed to do now?
Reply
#2

What's your problem?
Reply
#3

i need to know when his drifting, or anyway to get like, exact things, because what is up there could be working, but is just confunsing me
Reply
#4

I think you should do something in OnPlayerUpdate,get the current angel and speed,put the data to preiovus angel and speed
then make a timer in OnFilterscriptInit
then the function check player if is in vehicle,and do some math to infer if is drifting
May someone know the current data to infer,but we dont knowXD
I dont think GetPlayerFacingAngel could work in drift system
Reply
#5

on drifting bassicaly you have to keep your angle something like \ not | so it sould have some radius you can't have a EXACT angle depends on the curve.(i tell you this from my experience)
Reply
#6



Quote:
Originally Posted by AlExAlExAlEx
on drifting bassicaly you have to keep your angle something like \ not | so it sould have some radius you can't have a EXACT angle depends on the curve.(i tell you this from my experience)
If i cant express currently,sorry for bad expressionXD
'/'means expect position that infer by current vehicle angel+instantaneouns speed is different with real position,that called zig(?)
When the offset move to the enough extent,that called drift
So you need to know angel and instantaneous ,or some more to calculate
I dont know if is right,just my opion.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)