Advertisement
iPLEOMAX

shark.pwn

Sep 9th, 2011
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.74 KB | None | 0 0
  1.  
  2. /*-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-*/
  3. /* Shark FilterScript V1 by iPLEOMAX, 2011                 */
  4. /*                                                         */
  5. /* This System is based on my upcoming include:            */
  6. /* PlayerSpectateObject (Alternative way/idea)             */
  7. /*                                                         */
  8. /* NOTE:                                                   */
  9. /* Give/Keep the Credits if you use anything from here!    */
  10. /*-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-*/
  11.  
  12. #include <a_samp>
  13.  
  14. new
  15.     Shark[MAX_PLAYERS][3],
  16.     Float:SharkSPD[MAX_PLAYERS],
  17.     bool:SharkMoving[MAX_PLAYERS],
  18.     bool:SharkEnabled[MAX_PLAYERS]
  19. ;
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     print("  TheShark by iPLEOMAX.");
  24.     return true;
  25. }
  26.  
  27. public OnFilterScriptExit()
  28. {
  29.     return true;
  30. }
  31.  
  32. public OnPlayerDeath(playerid, killerid, reason)
  33. {
  34.     DisableShark(playerid, false);
  35.     return true;
  36. }
  37.  
  38. public OnPlayerDisconnect(playerid, reason)
  39. {
  40.     DisableShark(playerid, false);
  41.     return true;
  42. }
  43.  
  44. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  45. {
  46.     if (newkeys & KEY_FIRE && SharkEnabled[playerid])
  47.     {
  48.         if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 594) { SharkSPD[playerid] = 1.0; }
  49.     } else if (newkeys == 0) { SharkSPD[playerid] = 0.3; }
  50.  
  51.     if (newkeys & KEY_CROUCH && SharkEnabled[playerid])
  52.     {
  53.         if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 594)
  54.         {
  55.             new Float:P[3];
  56.             GetVehiclePos(GetPlayerVehicleID(playerid), P[0], P[1], P[2]);
  57.             if(P[2] < -0.1)
  58.             {
  59.                 GetVehicleVelocity(GetPlayerVehicleID(playerid), P[0], P[1], P[2]);
  60.                 SetVehicleVelocity(GetPlayerVehicleID(playerid), P[0], P[1], 0.3);
  61.             }
  62.         }
  63.     }
  64.    
  65.     if (newkeys & 8 && !SharkMoving[playerid] && SharkEnabled[playerid])
  66.     {
  67.         if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 594)
  68.         {
  69.             SharkMoving[playerid] = true;
  70.             Shark[playerid][2] = SetTimerEx("MoveShark", 300, true, "d", playerid);
  71.         }
  72.     } else if (newkeys == 0) { KillTimer(Shark[playerid][2]); SharkMoving[playerid] = false; }
  73.    
  74.     return true;
  75. }
  76.  
  77. public OnPlayerCommandText(playerid, cmdtext[])
  78. {
  79.     if(!strcmp(cmdtext, "/shark", true, 6))
  80.     {
  81.         if(GetPlayerAnimationIndex(playerid))
  82.         {
  83.             new animlib[32], animname[32];
  84.             GetAnimationName(GetPlayerAnimationIndex(playerid), animlib, sizeof animlib , animname, sizeof animname);
  85.             if(strcmp(animlib, "SWIM", true)) return SendClientMessage(playerid, 0xFF0000FF, "You need to be on water to use this command.");
  86.         }
  87.         if(SharkEnabled[playerid])
  88.         {
  89.             DisableShark(playerid, true);
  90.         } else {
  91.             new Float:P[4];
  92.             GetPlayerPos(playerid, P[0], P[1], P[2]);
  93.             SetPlayerPos(playerid, P[0], P[1], 0.30);
  94.             GetPlayerFacingAngle(playerid, P[3]);
  95.             Shark[playerid][0] = CreateVehicle(594, P[0], P[1], P[2], P[3], -1, -1, 0);
  96.             LinkVehicleToInterior(Shark[playerid][0], 10);
  97.             PutPlayerInVehicle(playerid, Shark[playerid][0], 0);
  98.             Shark[playerid][1] = CreateObject(1608,0,0,0,0,0,0,80);
  99.             AttachObjectToVehicle(Shark[playerid][1], GetPlayerVehicleID(playerid),0,0,0.7,8,0,0);
  100.             SetPlayerHealth(playerid, 0x107FFF);
  101.             SetVehicleHealth(playerid, 0x107FFF);
  102.             SharkEnabled[playerid] = true;
  103.             SendClientMessage(playerid, 0x00FFFFFF, ".:: Shark by iPLEOMAX ::.");
  104.             SendClientMessage(playerid, 0xFFFFFFFF, "- Hold 'UP' arrow key to move shark forward.");
  105.             SendClientMessage(playerid, 0xFFFFFFFF, "- Hold 'DOWN' arrow key to do nothing, do sharks move backward? o_O");
  106.             SendClientMessage(playerid, 0xFFFFFFFF, "- Hold 'Handbrake' while going Left/Right to make accurate turns.");
  107.             SendClientMessage(playerid, 0xFFFFFFFF, "- Hold 'Fire Key' to move faster.");
  108.             SendClientMessage(playerid, 0xFFFFFFFF, "- Press the 'Horn' Key to Jump.");
  109.         }
  110.         return true;
  111.     }
  112.     return false;
  113. }
  114.  
  115. forward MoveShark(playerid);
  116. public MoveShark(playerid)
  117. {
  118.     new Float:P[4];
  119.     GetVehicleVelocity(GetPlayerVehicleID(playerid), P[0], P[1], P[2]);
  120.     GetVehicleZAngle(GetPlayerVehicleID(playerid), P[3]);
  121.     SetVehicleVelocity(GetPlayerVehicleID(playerid), floatsin(-P[3], degrees)
  122.                         * SharkSPD[playerid], floatcos(P[3], degrees)
  123.                         * SharkSPD[playerid] , P[2]+0.02);
  124.     return true;
  125. }
  126.  
  127. forward DisableShark(playerid, bool:other);
  128. public DisableShark(playerid, bool:other)
  129. {
  130.     SharkSPD[playerid] = 0.3;
  131.     DestroyObject(Shark[playerid][1]);
  132.     DestroyVehicle(Shark[playerid][0]);
  133.     KillTimer(Shark[playerid][2]);
  134.     SharkEnabled[playerid] = false;
  135.     SharkMoving[playerid] = false;
  136.     if(other)
  137.     {
  138.         new Float:P[3];
  139.         GetPlayerPos(playerid, P[0], P[1], P[2]);
  140.         SetPlayerPos(playerid, P[0], P[1], P[2]+3);
  141.         SetPlayerHealth(playerid, 100.0);
  142.     }
  143.     return true;
  144. }
  145.  
  146. /* -=-=-=-=-=-=-=- End of code! -=-=-=-=-=-=-=- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement