check if player is drifting
#1

Hello guys I want to make a simple drift system, but I have no idea how to check if player drifts! Can somebody explain me? I mean with piece of code and explanation. I need to know just how to check it.
Reply
#2

its very easy you compare vehicle angle to its moving vector angle and thats about it.
Reply
#3

Quote:
Originally Posted by codExpert
Посмотреть сообщение
its very easy you compare vehicle angle to its moving vector angle and thats about it.
code example?
Reply
#4

simple example of drifting system, haven't tested it yet
you have to add checks and other stuff there to make it really work like needed.
i just wrote simple optimized starting code of it.
PHP код:
//code made by : codExpert // 13.01.19
#include <YSI_Coding\y_timers>
//variables - needed to stop drifting angle spam you have to build this yourself
new Float:pVehLastAngle[MAX_PLAYERS];
//params resets
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger){
    
pVehLastAngle[playerid]=0.0;
    return 
1;
}
//functions related with system
bool:vehTypeCar(modelID){
    switch(
modelID){
        case 
480,533,439,555,536,575,534,567,535,566,576,412,445,504,401,518,527,542,507,562,585,419,526,604,466,492,474,546,517,410,
        
551,516,467,426,436,547,405,580,560,550,549,540,491,529,421,602,429,496,402,541,415,589,587,565,494,502,503,411,559,603,
        
475,506,451,558,477,418,404,479,458,561: return true;
    }
    return 
false;
}
GetAngleToXY(Float:XFloat:YFloat:CurrentXFloat:CurrentY, &Float:Angle){
    
Angle atan2(Y-CurrentYX-CurrentX);
    
Angle floatsub(Angle90.0);
    if(
Angle 0.0Angle floatadd(Angle360.0);
}
GetVehicleHeadingAngle(vehicleid, &Float:a){
    new 
Float:xFloat:yFloat:z;
    
GetVehicleVelocity(vehicleidxyz);
    
GetAngleToXY(xy0.00.0a);
}
//makes timer more accurate and easier to create
ptask PlayerDriftChecker[500](playerid){
    
//checks if player is driver
    
if( GetPlayerState(playerid)==PLAYER_STATE_DRIVER){
        new 
vehID=GetPlayerVehicleID(playerid);
            
vehModel=GetVehicleModel(vehID);
        
//checks if vehicle model type is car
        
if(vehTypeCar(vehModel)){
            new 
Float:vehAngle=GetVehicleZAngle(vehID),
                
Float:vehHeadingAngle,
                
Float:angleDifference;
            
GetVehicleHeadingAngle(vehIDvehHeadingAngle);
            
//checking the angle difference
            
if((angleDifference=floatabs(vehAngle-vehHeadingAngle)) > 45.0){
                new 
s[60];
                
format(s,60,"Drifting angle : %.2d",angleDifference);
                
SendClientMessage(playerid,-1,s);
            }
        }
    }

Reply
#5

The following Include (Drift Detection) should be what you are looking for:
https://sampforum.blast.hk/showthread.php?tid=649800
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)