Guest User

Stinger.

a guest
Aug 27th, 2014
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.59 KB | None | 0 0
  1. /*
  2. STINGER SCRIPT BY GROVE!
  3.  
  4. GO TO LINE 40 FOR THE OnPlayerCrossStinger CALLBACK AND HAVE FUN :P
  5.  
  6. (c)Jay 2008
  7.  
  8. To add a Stinger, Usage:
  9.  
  10. CreateStinger(stingerid,Float:x,Float:y,Float:z);
  11.  
  12. */
  13. #include <a_samp>
  14. #define MAX_STINGER 2 //just increase it if you add more than 20 stingers.
  15. #define white 0xFFFFFFAA
  16. new MAXPLAYERS;
  17. forward PlayerToPoint(Float:radi,playerid,Float:x,Float:y,Float:z);
  18. forward stinger();
  19. forward StopVehicle(playerid);
  20. new sting[MAX_STINGER], Float:Rot[4][MAX_STINGER];
  21.  
  22. public OnFilterScriptInit()
  23. {
  24.  
  25.     //STINGERS:
  26.  
  27.     CreateStinger(0,332.2, 2503.8, 15.8);
  28.     CreateStinger(1,332.2+15, 2503.8+15, 15.8);
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. //--
  38.     print("Stinger script 0.1 by Grove Loaded");
  39.     SetTimer("stinger",40,1); //checks if the player is near a stinger
  40.     MAXPLAYERS = GetMaxPlayers();
  41. }
  42. public OnFilterScriptExit()
  43. {
  44.     for(new i = 0; i < MAX_STINGER; i++)
  45.     {
  46.         DestroyObject(sting[i]);
  47.     }
  48.     print("Stinger script 0.1 by Grove unloaded!");
  49. }
  50.  
  51. stock CreateStinger(id,Float:X,Float:Y,Float:Z)
  52. {
  53.     sting[id] = CreateObject(1593,X,Y,Z,0,0,0);
  54.     GetObjectPos(sting[id],Rot[1][id],Rot[2][id],Rot[3][id]);
  55.     return id;
  56. }
  57.  
  58. OnPlayerCrossStinger(playerid,stingerid) //do what you like here :)
  59. {
  60.     if(!IsPlayerInAnyVehicle(playerid)) return false;
  61.     PlayerPlaySound(playerid,32000,0,0,0); //sound for popping tyres NOT SUPPORTED IN SA:MP
  62.     SetVehicleToRespawn((GetPlayerVehicleID(playerid)));
  63.     GameTextForPlayer(playerid,"~r~Pop goes the weasel!",5000,5);
  64.     //Perhaps here, you could freeze the vehicle, and remove the player from it!
  65.     #pragma unused stingerid
  66.  
  67.  
  68. /*    new string[256];
  69.     format(string,256,"DEBUG: stinger id: %d.",stingerid);
  70.     SendClientMessage(playerid,white,string);
  71. */
  72.     return true;
  73. }
  74.  
  75.  
  76. public stinger()
  77. {
  78.     for(new i = 0; i < MAX_STINGER; i++)
  79.     {
  80.         for(new pi = 0; pi <MAXPLAYERS; pi++)
  81.         {
  82.             if(PlayerToPoint(1.2,pi,Rot[1][i],Rot[2][i],Rot[3][i]))
  83.             {
  84.                 OnPlayerCrossStinger(pi,i);
  85.             }
  86.         }
  87.     }
  88. }
  89.  
  90. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  91.     {
  92.     new Float:oldposx, Float:oldposy, Float:oldposz;
  93.     new Float:tempposx, Float:tempposy, Float:tempposz;
  94.     GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  95.     tempposx = (oldposx -x);
  96.     tempposy = (oldposy -y);
  97.     tempposz = (oldposz -z);
  98.     if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  99.     {
  100.         return 1;
  101.     }
  102.     return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment