Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright wups
- #define FILTERSCRIPT
- #include <a_samp>
- #include <foreach>
- new Float:PVAngle[MAX_PLAYERS],
- LastHandBreak[MAX_PLAYERS],
- bool:HandBreak[MAX_PLAYERS];
- //Y_Less:
- #if !defined abs
- #define abs(%1) \
- (((%1) < 0) ? (-(%1)) : ((%1)))
- #endif
- #if !defined PRESSED
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #endif
- #if !defined RELEASED
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- #endif
- public OnPlayerConnect(playerid)
- {
- HandBreak[playerid]=false;
- LastHandBreak[playerid]=0;
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if(PRESSED(KEY_HANDBRAKE))
- {
- HandBreak[playerid]=true;
- }
- else if(RELEASED(KEY_HANDBRAKE))
- {
- HandBreak[playerid]=false;
- LastHandBreak[playerid]=GetTickCount();
- }
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate==PLAYER_STATE_DRIVER)
- GetVehicleZAngle(GetPlayerVehicleID(playerid),PVAngle[playerid]);
- return 1;
- }
- forward CheckForPIT();
- public CheckForPIT()
- {
- new vehicleid,
- victim=-1,
- Float:angle,
- Float:diff,
- CPlayer;
- foreach(Player, playerid)
- {
- vehicleid = GetPlayerVehicleID(playerid);
- if(vehicleid && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- CPlayer = GetClosestPlayer(playerid,4.0);
- if(CPlayer == INVALID_PLAYER_ID) continue;
- GetVehicleZAngle(vehicleid,angle);
- if (angle > 360.0)
- angle -= 360.0;
- else if (angle < 0.0)
- angle += 360.0;
- diff = abs(angle-PVAngle[playerid]);
- if(diff > 45.0 && (HandBreak[playerid] || ((GetTickCount()-500) < LastHandBreak[playerid])))
- {
- victim=playerid;
- break;
- }
- PVAngle[playerid]=angle;
- }
- }
- if(victim != -1) OnPitManeuver(victim,CPlayer);
- return 1;
- }
- stock OnPitManeuver(victim,suspect)
- {
- SendClientMessage(victim,0xFF0000FF," * You have been hit with a PIT Maneuver!");
- SendClientMessage(suspect,0xFF0000FF,", * You've done a PIT Maneuver!");
- return 1;
- }
- stock GetClosestPlayer(playerid,Float:radius = 999.999)
- {
- new Float:dis[2];
- new returnid;
- returnid = INVALID_PLAYER_ID;
- dis[0] = radius;
- new Float:coo[6];
- GetPlayerPos(playerid,coo[0],coo[1],coo[2]);
- foreach(Player, i) if(i != playerid)
- {
- GetPlayerPos(i,coo[3],coo[4],coo[5]);
- dis[1] = floatround(floatsqroot((coo[0]-coo[3])*(coo[0]-coo[3])+(coo[1]-coo[4])*(coo[1]-coo[4])+(coo[2]-coo[5])*(coo[2]-coo[5])));
- if(dis[1]< dis[0])
- {
- dis[0] = dis[1];
- returnid = i;
- }
- }
- return returnid;
- }
Advertisement
Add Comment
Please, Sign In to add comment