Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- new burnout[MAX_PLAYERS],timer;
- public OnFilterScriptInit()
- {
- timer = SetTimer("BOtimer",100,true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- KillTimer(timer);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- burnout[playerid]=0;
- return 1;
- }
- forward BOtimer();
- public BOtimer()
- {
- for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
- {
- if(IsPlayerConnected(playerid) && GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
- {
- new keys,leftright,updown;
- GetPlayerKeys(playerid,keys,updown,leftright);
- if(keys == 40)
- {
- burnout[playerid]++;
- }else if(burnout[playerid]>10 && keys == 8){
- if(burnout[playerid]>35) burnout[playerid]=35;
- new Float:speed[2],vehicleid=GetPlayerVehicleID(playerid);
- GetXYInFrontOfVehicle(vehicleid,speed[0],speed[1],0.007*burnout[playerid]);
- AccelerateTowardsAPoint(vehicleid,speed[0],speed[1]);
- burnout[playerid]=0;
- }
- }
- }
- }
- stock GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
- { // Created by Y_Less
- new Float:a;
- GetVehiclePos(vehicleid, x, y, a);
- GetVehicleZAngle(vehicleid, a);
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- }
- stock AccelerateTowardsAPoint(vehicleid,Float:x,Float:y)
- {
- new Float:pos[6];
- GetVehicleVelocity(vehicleid,pos[4],pos[5],pos[2]);
- GetVehiclePos(vehicleid,pos[0],pos[1],pos[3]);
- if(GivesSpeed(pos[4],pos[5],pos[2],x-pos[0],y-pos[1],pos[2]))
- SetVehicleVelocity(vehicleid,x-pos[0],y-pos[1],pos[2]);
- }
- stock GivesSpeed(Float:x,Float:y,Float:z,Float:newx,Float:newy,Float:newz) // Checks if one velocity is bigger than another.
- {
- if(floatsqroot(floatpower(floatabs(x),2)+floatpower(floatabs(y),2)+floatpower(floatabs(z),2))<floatsqroot(floatpower(floatabs(newx),2)+floatpower(floatabs(newy),2)+floatpower(floatabs(newz),2))) return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement