Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- new SpeedBoost[MAX_PLAYERS];
- stock IsKeyJustDown(key, newkeys, oldkeys)
- {
- if((newkeys & key) && !(oldkeys & key))
- return 1;
- return 0;
- }
- stock IsKeyReleased(key, newkeys, oldkeys)
- {
- if(!(newkeys & key) && (oldkeys & key))
- return 1;
- return 0;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- SpeedBoost[playerid] = 1;
- }
- }
- if(IsKeyReleased(KEY_FIRE, newkeys, oldkeys))
- {
- if(SpeedBoost[playerid] > 0)
- {
- new Float:vx, Float:vy, Float:vz, vehicleid = GetPlayerVehicleID(playerid);
- GetVehicleVelocity(vehicleid, vx, vy, vz);
- if(floatabs(vx) < 3 && floatabs(vy) < 3 && floatabs(vz) < 3)
- {
- SetVehicleVelocity(vehicleid, vx * 0.95, vy * 0.95, vz * 0.95);
- }
- SpeedBoost[playerid] = 0;
- }
- }
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- if(SpeedBoost[playerid] > 0)
- {
- new Float:vx, Float:vy, Float:vz, vehicleid = GetPlayerVehicleID(playerid);
- GetVehicleVelocity(vehicleid, vx, vy, vz);
- if(floatabs(vx) < 3 && floatabs(vy) < 3 && floatabs(vz) < 3)
- {
- SetVehicleVelocity(vehicleid, vx * 1.05, vy * 1.05, vz * 1.05);
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement