SA-MP Forums Archive
[HELP]Drifting System(almost done) - 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: [HELP]Drifting System(almost done) (/showthread.php?tid=64148)



[HELP]Drifting System(almost done) - faloleroy - 02.02.2009

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?


Re: [HELP]Drifting System(almost done) - MenaceX^ - 02.02.2009

What's your problem?


Re: [HELP]Drifting System(almost done) - faloleroy - 02.02.2009

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


Re: [HELP]Drifting System(almost done) - yezizhu - 03.02.2009

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


Re: [HELP]Drifting System(almost done) - AlExAlExAlEx - 03.02.2009

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)


Re: [HELP]Drifting System(almost done) - yezizhu - 03.02.2009



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.