Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- CREDITS:
- mick88 - Got the idea from mick88, and I somewhat learned from his Cruise Control FS
- NealPeteros - Created the whole script from basic scratch
- SAMP Community - Providing the necessary needs for this filterscript(Self-explainable)
- PAWN - Programming Language used for this filterscript(Self-explainable)
- PAWNO - Provided program that is responsible for PAWN, and all contents of this filterscript(Self-explainable)
- */
- #define FILTERSCRIPT
- #include <a_samp>
- //Colors
- #define COLOR_MESSAGE_YELLOW 0xFFDD00AA
- #define COLOR_GREY 0xAFAFAFAA
- #define startkey KEY_FIRE // Change to desired key (DEFAULT: LALT)
- #define endkey KEY_HANDBRAKE // Change to desired key (DEFAULT: SPACE)
- // Variables
- new Float:PlayerSpeed[MAX_PLAYERS];
- new Float:PlayerAngle[MAX_PLAYERS];
- //forwards
- forward VelocityControl(playerid);
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- // Do something here
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if ((newkeys & startkey) && !(oldkeys & startkey) && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- new vid = GetPlayerVehicleID(playerid);
- if (GetCarSpeed(vid) == 0) return false;
- new Float:x, Float:y, Float:z;
- GetVehicleVelocity(vid, x, y, z);
- GetVehicleZAngle(vid, PlayerAngle[playerid]);
- FloatDistance(0, 0, x, y, PlayerSpeed[playerid]);
- SetTimerEx("VelocityControl", 500, false, "d", playerid);
- GameTextForPlayer(playerid, "Velocity Control Enabled", 3000, 5);
- }
- else if (PlayerSpeed[playerid] != 0.00 && (newkeys & endkey))
- {
- PlayerSpeed[playerid] = 0.00;
- }
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- /* Custom Callbacks */
- public VelocityControl(playerid)
- {
- new veh = GetPlayerVehicleID(playerid);
- new Float:x, Float:y, Float:z;
- GetVehicleVelocity(veh, x, y, z);
- new keys, akey, bkey;
- GetPlayerKeys(playerid, keys, akey, bkey);
- new Float:angle, Float:heading, Float:speed;
- GetVehicleZAngle(veh, angle);
- GetVehicleFacingAngle(veh, heading);
- FloatDistance(0, 0, x, y, speed);
- if (!(keys & startkey) || PlayerSpeed[playerid] == 0.00 || GetPlayerState(playerid) != PLAYER_STATE_DRIVER || (speed < 0.7 * PlayerSpeed[playerid]) || z > 1 || (floatabs(angle - heading) > 50 && floatabs(angle - heading) < 310))
- {
- PlayerSpeed[playerid] = 0.00;
- GameTextForPlayer(playerid, "Velocity Control Disabled", 3000, 5);
- return false;
- }
- GetVehicleZAngle(veh, PlayerAngle[playerid]);
- GetSpeedXY(veh, x, y, PlayerSpeed[playerid]);
- SetVehicleVelocity(veh, x, y, z);
- return SetTimerEx("VelocityControl", 500, false, "d", playerid);
- }
- /* Stocks */
- GetCarSpeed(vehid)
- {
- new Float:Vx, Float:Vy, Float:Vz;
- GetVehicleVelocity(vehid, Vx, Vy, Vz);
- new Float:rtn;
- rtn = floatsqroot(floatpower(Vx*100,2) + floatpower(Vy*100,2));
- rtn = floatsqroot(floatpower(rtn,2) + floatpower(Vz*100,2));
- return floatround(rtn);
- }
- FloatDistance(Float:ax, Float:ay, Float:bx,Float:by, &Float:distance)
- {
- distance = floatsqroot(floatpower(bx-ax,2)+floatpower(by-ay,2));
- return floatround(distance);
- }
- GetSpeedXY(vehicleid, &Float:x, &Float:y, Float:speed)
- {
- new Float:a;
- x = 0.0;
- y = 0.0;
- GetVehicleZAngle(vehicleid, a);
- x += (speed * floatsin(-a, degrees));
- y += (speed * floatcos(-a, degrees));
- }
- GetAngleToXY(Float:X, Float:Y, Float:CurrentX, Float:CurrentY, &Float:Angle)
- {
- Angle = atan2(Y-CurrentY, X-CurrentX);
- Angle = floatsub(Angle, 90.0);
- if(Angle < 0.0) Angle = floatadd(Angle, 360.0);
- }
- GetVehicleFacingAngle(vehicleid, &Float:a)
- {
- new Float:x, Float:y, Float:z;
- GetVehicleVelocity(vehicleid, x, y, z);
- GetAngleToXY(x, y, 0, 0, a);
- }
Add Comment
Please, Sign In to add comment