Advertisement
Guest User

Untitled

a guest
Mar 10th, 2010
1,473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.17 KB | None | 0 0
  1. /*
  2.  
  3.                         ===================================
  4.                                      Tear-Gas system
  5.                                      By Carlton.
  6.                         ===================================
  7.  
  8. */
  9.  
  10.  
  11. new TearGas[MAX_PLAYERS], TearGasTimer[MAX_PLAYERS], TearObject[MAX_PLAYERS], TearGasObject[MAX_PLAYERS];
  12.  
  13. TearGas_OnPlayerConnect(playerid) {
  14.     TearGas[playerid] = 0;
  15. }
  16.  
  17. GivePlayerTearGas(playerid, amount) {
  18.     TearGas[playerid] += amount;
  19. }
  20.  
  21. SetPlayerTearGas(playerid, amount) {
  22.     TearGas[playerid] = amount;
  23. }
  24.  
  25. GetPlayerTearGas(playerid) return TearGas[playerid];
  26.  
  27. GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  28. {
  29.     new Float:a;
  30.     GetPlayerPos(playerid, x, y, a);
  31.     GetPlayerFacingAngle(playerid, a);
  32.     if (GetPlayerVehicleID(playerid))
  33.     {
  34.         GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  35.     }
  36.     x += (distance * floatsin(-a, degrees));
  37.     y += (distance * floatcos(-a, degrees));
  38. }
  39.  
  40. TearGasOnPlayerKeyStateChange(playerid, newkeys)
  41. {
  42.     if (newkeys & KEY_FIRE) {
  43.         if(GetPlayerTearGas(playerid) >= 1) {
  44.         ApplyAnimation(playerid,"GRENADE","WEAPON_throwu",4.1,0,1,1,0,0);
  45.         new Float:x, Float:y, Float:z;
  46.     GetPlayerPos(playerid, x, y, z);
  47.         GetXYInFrontOfPlayer(playerid, x, y, 10.0);
  48.         TearObject[playerid] = CreateObject(343, x, y, z, 0, 0, 96);
  49.         TearGasTimer[playerid] = SetTimer("TearGasEfft", 1000, 1);
  50.         SetTimerEx("StopTheEffect", 15000, 0, "d", playerid);
  51.         MoveObject(TearObject[playerid], x, y, z-2, 1.00);
  52.         new Float:tx, Float:ty, Float:tz;
  53.     GetObjectPos(TearObject[playerid], tx, ty, tz);
  54.         TearGasObject[playerid] = CreateObject(2780, tx, ty, tz-4, 0, 0, 96);
  55.         GivePlayerTearGas(playerid, -1);
  56.         }
  57.     }
  58. }
  59.  
  60. forward TearGasEfft();
  61. public TearGasEfft()
  62. {
  63.     for(new i=0; i < MAX_PLAYERS; i++)
  64.     {
  65.         new Float:tx, Float:ty, Float:tz;
  66.         GetObjectPos(TearGasObject[i], tx, ty, tz);
  67.         if(IsPlayerInRangeOfPoint(i, 8.0, tx, ty, tz))
  68.         {
  69.             ApplyAnimation(i,"CRACK","crckdeth4",4.1,0,1,1,1,1);
  70.         }
  71.     }
  72. }
  73.  
  74. forward StopTheEffect(playerid);
  75. public StopTheEffect(playerid)
  76. {
  77.     KillTimer(TearGasTimer[playerid]);
  78.         DestroyObject(TearObject[playerid]);
  79.     DestroyObject(TearGasObject[playerid]);
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement