Guest User

Hiddos

a guest
Nov 13th, 2010
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.20 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. forward OnPlayerEnterStreakRcVehicle(playerid, vehicleid);
  4. forward OnPlayerDetonateStreakRcVehicle(playerid, vehicleid);
  5. forward OnPlayerExitStreakRcVehicle(playerid);
  6. public OnPlayerDisconnect(playerid, reason)
  7. {
  8.     DestroyVehicle(GetPVarInt(playerid, "KSV"));
  9.     return 1;
  10. }
  11.  
  12. stock PutPlayerInStreakRcVehicle(playerid)
  13. {
  14.     new Float:Pos[4]; GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  15.     GetPlayerFacingAngle(playerid, Pos[3]);
  16.  
  17.     SetPVarFloat(playerid, "rcX", Pos[0]);
  18.     SetPVarFloat(playerid, "rcY", Pos[1]);
  19.     SetPVarFloat(playerid, "rcZ", Pos[2]);
  20.     SetPVarFloat(playerid, "rcA", Pos[3]);
  21.     new veh = CreateVehicle(441, Pos[0], Pos[1], Pos[2], Pos[3], -1, -1, 0);
  22.     PutPlayerInVehicle(playerid, veh, 0);
  23.     SetPVarInt(playerid, "KSV", veh);
  24.     CallLocalFunction("OnPlayerEnterStreakRcVehicle", "ii", playerid, veh);
  25. }
  26.  
  27. public OnVehicleDeath(vehicleid)
  28. {
  29.     for(new i; i < MAX_PLAYERS; i++)
  30.     {
  31.         if(GetPVarInt(i, "KSV") == vehicleid)
  32.         {
  33.             OnPlayerKeyStateChange(i, KEY_FIRE, 0);
  34.             break;
  35.         }
  36.     }
  37.     return 1;
  38. }
  39.  
  40. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  41. {
  42.     if(newkeys & KEY_FIRE && !(oldkeys & KEY_FIRE))
  43.     {
  44.         if(GetPVarInt(playerid, "rcTimer") > 0)
  45.         {
  46.             ReturnPlayerToNormalState(playerid);
  47.             KillTimer(GetPVarInt(playerid, "rcTimer"));
  48.             DeletePVar(playerid, "rcTimer");
  49.             return 1;
  50.         }
  51.        
  52.         if(GetPVarInt(playerid, "KSV")) //KillStreakVehicle
  53.         {
  54.             new Float:Pos[6]; GetVehiclePos(GetPVarInt(playerid, "KSV"), Pos[0], Pos[1], Pos[2]);
  55.             SetPlayerPos(playerid, GetPVarFloat(playerid, "rcX"), GetPVarFloat(playerid, "rcY"), GetPVarFloat(playerid, "rcZ"));
  56.             SetPlayerFacingAngle(playerid, GetPVarFloat(playerid, "rcA"));
  57. //3 Explosion for impact
  58.             CreateExplosion(Pos[0] + floatdiv(random(250), 100), Pos[1] + floatdiv(random(250), 100), Pos[2] + floatdiv(random(250), 100), 7, 12);
  59.             CreateExplosion(Pos[0] + floatdiv(random(250), 100), Pos[1] + floatdiv(random(250), 100), Pos[2] + floatdiv(random(250), 100), 7, 12);
  60.             CreateExplosion(Pos[0] + floatdiv(random(250), 100), Pos[1] + floatdiv(random(250), 100), Pos[2] + floatdiv(random(250), 100), 7, 12);
  61.            
  62.             new Float:angle = float( random( 360 ) );
  63.             Pos[3] = Pos[0] + 15 * floatsin(-angle, degrees);
  64.             Pos[4] = Pos[1] + 15 * floatcos(-angle, degrees);
  65.             Pos[5] = float( random( 18 ) );
  66.             SetPlayerCameraPos(playerid, Pos[3], Pos[4], Pos[5]);
  67.             SetPlayerCameraLookAt(playerid, Pos[0], Pos[1], Pos[2]);
  68.            
  69.             SetTimerEx("GoAwayWithVehicleDamnit", 500, 0, "i", GetPVarInt(playerid, "KSV"));
  70.             SetPVarInt(playerid, "rcTimer", SetTimerEx("ReturnPlayerToNormalState", 3250, 0, "i", playerid) + 1);
  71.             CallLocalFunction("OnPlayerDetonateStreakRcVehicle", "ii", playerid, GetPVarInt(playerid, "KSV"));
  72.             DeletePVar(playerid, "KSV");
  73.             return 1;
  74.         }
  75.     }
  76.     return 1;
  77. }
  78.  
  79. forward GoAwayWithVehicleDamnit(vehicleid);
  80. public GoAwayWithVehicleDamnit(vehicleid)
  81. {   //Major function, I know lolz
  82.     DestroyVehicle(vehicleid);
  83. }
  84.  
  85. forward ReturnPlayerToNormalState(playerid);
  86. public ReturnPlayerToNormalState(playerid)
  87. {
  88.     DeletePVar(playerid, "rcTimer");
  89.     SetCameraBehindPlayer(playerid);
  90.     CallLocalFunction("OnPlayerExitStreakRcVehicle", "i", playerid);
  91. }
Advertisement
Add Comment
Please, Sign In to add comment