Advertisement
Guest User

[FS] Shark-Killer (english version)

a guest
Oct 8th, 2015
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.33 KB | None | 0 0
  1. /*=============================================================================*
  2. * Sistema Shark-Killer  V 1.0                                                       *
  3. * Autor: NullBot                                                               *
  4. * Versión: 1.0                                                                 *
  5. * Versión SA-MP: 0.3.7                                                         *
  6. * Tipo de script: FilterScript                                                 *
  7. * Fecha: 1/10/2015                                                             *
  8. *=============================================================================*/
  9. /*------------------------------------------------------------------------------*/
  10. #define Version "1.0"
  11.  
  12. #include <a_samp>
  13. #define MAX_TIMEINWATER 10
  14. #define ROJO 0xE60000FF
  15. #define MAX_DEEP 10
  16.  
  17. /*-- ANTI DESCOMPILADOR --*/
  18. AntiDeAMX()
  19. {
  20.    new a[][] =
  21.    {
  22.       "Unarmed (Fist)",
  23.       "Brass K"
  24.    };
  25.    #pragma unused a
  26. }
  27.  
  28. /*-- Callbacks --*/
  29. public OnFilterScriptInit()
  30. {
  31.     AntiDeAMX();
  32.  
  33.     /* TIMERS */
  34.     SetTimer("TIMEINWATER", 968, true);
  35.  
  36.    
  37.     for(new i = 0, plys = GetMaxPlayers(); i < plys; i++)
  38.     {
  39.         SetPVarInt(i, "Spawn", 0);
  40.         SetPVarInt(i, "TimeSwiming", 0);
  41.         SetPVarInt(i, "Object_Shark", -1);
  42.     }
  43.  
  44.     print("\n");
  45.     print(" *-----------------------*");
  46.     printf(" # Shark-Killer     v%s #", Version);
  47.     print(" *-----------------------*");
  48.     print("\n");
  49.     return 1;
  50. }
  51.  
  52. public OnFilterScriptExit()
  53. {
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerConnect(playerid)
  58. {
  59.     SetPVarInt(playerid, "Spawn", 0);
  60.     SetPVarInt(playerid, "TimeSwiming", 0);
  61.     SetPVarInt(playerid, "Object_Shark", -1);
  62.  
  63.     return 1;
  64. }
  65.  
  66. public OnPlayerDisconnect(playerid, reason)
  67. {
  68.     if(IsPlayerNPC(playerid)) return 1;
  69.  
  70.  
  71.     return 1;
  72. }
  73.  
  74. public OnPlayerRequestClass(playerid, classid)
  75. {
  76.     SetPVarInt(playerid, "Spawn", 0);
  77.     return 1;
  78. }
  79.  
  80. public OnPlayerSpawn(playerid)
  81. {
  82.    
  83.     SetPVarInt(playerid, "Spawn", 1);
  84.     return 1;
  85. }
  86.  
  87. public OnPlayerDeath(playerid, killerid, reason)
  88. {
  89.     SetPVarInt(playerid, "Spawn", 0);
  90.     SetPVarInt(playerid,"TimeSwiming",0);
  91.     if(GetPVarInt(playerid, "Object_Shark") > -1 )
  92.         DestroyObject(GetPVarInt(playerid, "Object_Shark"));   
  93.        
  94.     SetPVarInt(playerid, "Object_Shark",-1);
  95.     SetCameraBehindPlayer(playerid);
  96.     return 1;
  97. }
  98.  
  99. public OnPlayerStateChange(playerid, newstate, oldstate)
  100. {
  101.  
  102.     return 1;
  103. }
  104.  
  105. public OnPlayerEnterVehicle(playerid, vehicleid)
  106. {
  107.     if(GetPVarInt(playerid, "Object_Shark") > -1)
  108.     {
  109.         SetPVarInt(playerid,"TimeSwiming",0);
  110.         SetCameraBehindPlayer(playerid);
  111.         DestroyObject(GetPVarInt(playerid, "Object_Shark"));   
  112.         SetPVarInt(playerid, "Object_Shark",-1);       
  113.                    
  114.     }
  115.     return 1;
  116. }
  117.  
  118. public OnPlayerUpdate(playerid)
  119. {
  120.     if(IsPlayerNPC(playerid)) return 1;
  121.  
  122.  
  123.     return 1;
  124. }
  125.  
  126. forward TIMEINWATER();
  127. public TIMEINWATER()
  128. {
  129.      
  130.       new Float: x, Float: y, Float: z;
  131.       for(new i = 0, plys = GetMaxPlayers(); i < plys; i++)
  132.       {
  133.         if(GetPVarInt(i,"Spawn") && !IsPlayerNPC(i) )
  134.           {
  135.              GetPlayerPos(i,x,y,z);
  136.              #pragma unused x
  137.              #pragma unused y
  138.              
  139.              if(z < MAX_DEEP)
  140.              {
  141.            
  142.                   if(GetPVarInt(i, "Object_Shark") == -1)
  143.                       MakeShark(i);                
  144.                      
  145.              }
  146.              
  147.              if(z < 0 && GetPVarInt(i, "Object_Shark") > -1)
  148.              {
  149.                     SetPVarInt(i,"TimeSwiming",GetPVarInt(i,"TimeSwiming") + 1);                                                               
  150.              }
  151.              
  152.              if(z > 1.2 && GetPVarInt(i, "Object_Shark") > -1  )
  153.              {
  154.                 SetPVarInt(i,"TimeSwiming",0);
  155.                 DestroyObject(GetPVarInt(i, "Object_Shark"));  
  156.                 SetPVarInt(i, "Object_Shark",-1);  
  157.                 SetCameraBehindPlayer(i);              
  158.              }
  159.            
  160.           }
  161.       }
  162. }
  163. forward MakeShark(playerid);
  164. public MakeShark(playerid)
  165. {
  166.     new Float: Px, Float: Py, Float: Pz;
  167.     GetPlayerPos(playerid,Px,Py,Pz);
  168.    
  169.     SetPlayerCameraPos(playerid, Px, Py, Pz-2);
  170.     SetPVarInt(playerid, "Object_Shark", CreateObject(1608,Px,Py,Pz-15.0,45.0,45.0,0.0,200.0));
  171.     PlayAudioStreamForPlayer(playerid, "http://sampleswap.org/samples-ghost/INSTRUMENTS%20multisampled/PADS%20and%20STRINGS/Heavy%20Strings/2415%5Bkb%5DHeavyStringsC-02.wav.mp3");
  172.     MoveObject( GetPVarInt(playerid,"Object_Shark"),Px,Py,Pz,3.0);
  173.     FollowCamera(playerid);
  174.    
  175.  
  176.  
  177.  
  178. }
  179. forward FollowCamera(playerid);
  180. public FollowCamera(playerid)
  181. {
  182.   if(GetPVarInt(playerid, "Object_Shark") > -1)
  183.   {
  184.      new Float: x, Float: y, Float: z;
  185.      
  186.      GetObjectPos(GetPVarInt(playerid, "Object_Shark"),x,y,z);
  187.      GetPlayerPos(playerid,x,y,z);   
  188.      
  189.      if( GetPVarInt(playerid,"TimeSwiming") < MAX_TIMEINWATER)
  190.         SetPlayerCameraLookAt(playerid, x, y, z,2);
  191.        
  192.      else SetCameraBehindPlayer(playerid)
  193.      return SetTimerEx("FollowCamera",795,false,"i",playerid);
  194.      
  195.   }  
  196.   else SetCameraBehindPlayer(playerid);  
  197.   return 1;
  198.  
  199. }
  200. public OnObjectMoved(objectid)
  201. {
  202.     new Float: x, Float: y, Float: z;    
  203.     for(new i = 0, plys = GetMaxPlayers(); i < plys; i++)
  204.     {  
  205.         if(GetPVarInt(i,"Object_Shark") > -1 && objectid == GetPVarInt(i,"Object_Shark") )     
  206.         {
  207.             GetObjectPos(objectid,x,y,z);
  208.             if (IsPlayerInRangeOfPoint(i, 2.0, x, y, z) && GetPVarInt(i,"Spawn") && GetPVarInt(i,"TimeSwiming")> 0 && !IsPlayerNPC(i) )
  209.             {
  210.                    
  211.                 SendClientMessage(i, ROJO, "Killed by a Shark!");
  212.                 SetCameraBehindPlayer(i);
  213.                 SetPVarInt(i,"TimeSwiming",0);
  214.                 SetPlayerHealth(i,0.0);
  215.                 DestroyObject(GetPVarInt(i, "Object_Shark"));  
  216.                 SetPVarInt(i, "Object_Shark",-1);                  
  217.            
  218.             }
  219.             if(GetPVarInt(i,"Object_Shark") != -1) 
  220.             {
  221.                 GetPlayerPos(i, x, y, z);
  222.                 SetPlayerFacingAngleToPlayer(i);               
  223.                 MoveObject( GetPVarInt(i,"Object_Shark"),x,y,z-1.5,4.5);   
  224.             }      
  225.         }  
  226.     }  
  227.     return 1;
  228. }
  229.  
  230. stock SetPlayerFacingAngleToPlayer(playerid)
  231. {
  232.     new
  233.         Float:X1,
  234.         Float:Y1,
  235.         Float:X2,
  236.         Float:Y2,
  237.         Float:Angle;
  238.  
  239.     GetPlayerPos(playerid, X1, Y1, Angle);
  240.     GetObjectPos(GetPVarInt(playerid,"Object_Shark"), X2, Y2,Angle);
  241.     GetAngle(X2, Y2,  X1, Y1, Angle);
  242.     SetObjectRot(GetPVarInt(playerid,"Object_Shark"),0.0,0.0,Angle+180);
  243.    
  244. }
  245.  
  246. //Por Zoutdaxv
  247. stock GetAngle(Float:X, Float:Y, Float:CurrentX, Float:CurrentY, &Float:Angle)
  248. {
  249.     Angle = atan2(Y-CurrentY, X-CurrentX);
  250.     Angle = floatsub(Angle, 90.0);
  251.     if(Angle < 0.0) Angle = floatadd(Angle, 360.0);
  252. }
  253. //------------------------------------------------------------------------------
  254. /*
  255.  
  256.               www.puramasacre.com
  257.  
  258. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement