Advertisement
MarioBlack

Tazer

Sep 5th, 2020
1,871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.54 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4.  
  5. #define COLOR_PURPLE  0xC2A2DAAA
  6. #define SACAR_TAZER (5000)
  7. new AmmoTazer[MAX_PLAYERS];
  8. new bool:ActivarTazer[MAX_PLAYERS]=false;
  9. new bool:PlayerTazeado[MAX_PLAYERS]=false;
  10. new TerminarTazeado[MAX_PLAYERS];
  11.  
  12. COMMAND:tazer(playerid, params[]) {
  13.     new string[128], name[MAX_PLAYER_NAME+1];
  14.     GetPlayerName(playerid, name, sizeof(name));
  15.     AmmoTazer[playerid] = GetPlayerAmmo(playerid);
  16.     switch(GetPlayerWeapon(playerid)) {
  17.         case 22: { //9mm
  18.             GivePlayerWeapon(playerid, 23, AmmoTazer[playerid]);
  19.             ActivarTazer[playerid] = true;
  20.             format(string, sizeof(string), "* %s carga su tazer.", name);
  21.             ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  22.         }
  23.         case 23: { //Silenced 9mm
  24.             GivePlayerWeapon(playerid, 22, AmmoTazer[playerid]);
  25.             ActivarTazer[playerid] = false;
  26.             format(string, sizeof(string), "* %s apaga su tazer.", name);
  27.             ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  28.         }
  29.     }
  30.     return 1;
  31. }
  32.  
  33. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
  34. {
  35.     if(issuerid != INVALID_PLAYER_ID) {
  36.         if(ActivarTazer[issuerid] == true && GetPlayerWeapon(issuerid) == 23 && PlayerTazeado[playerid] == false) {
  37.             SetPlayerHealth(playerid, (0-amount));
  38.             TogglePlayerControllable(playerid, false);
  39.             PlayerTazeado[playerid] = true;
  40.             TerminarTazeado[playerid]=SetTimerEx("TocarTazer", SACAR_TAZER, false, "i", playerid);
  41.             new string[128];
  42.             format(string, sizeof(string), "Tazeado %i Milisegundos.", SACAR_TAZER);
  43.             GameTextForPlayer(playerid, string, 3000, 1);
  44.             ApplyAnimation(playerid, "CRACK","crckdeth2",4.1,0,1,1,1,1,1);
  45.         }
  46.     }
  47.     return 1;
  48. }
  49.  
  50. forward TocarTazer(playerid);
  51. public TocarTazer(playerid) {
  52.     TogglePlayerControllable(playerid, true);
  53.     PlayerTazeado[playerid] = false;
  54.     GameTextForPlayer(playerid, "Tazer Quitado.", 3000, 1);
  55.     KillTimer(TerminarTazeado[playerid]);
  56.     ClearAnimations(playerid);
  57.     return 1;
  58. }
  59.  
  60. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  61. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  62. {
  63.     if(IsPlayerConnected(playerid))
  64.     {
  65.         new Float:posx, Float:posy, Float:posz;
  66.         new Float:oldposx, Float:oldposy, Float:oldposz;
  67.         new Float:tempposx, Float:tempposy, Float:tempposz;
  68.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  69.         for(new i = 0; i < MAX_PLAYERS; i++)
  70.         {
  71.             if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  72.             {
  73.                 GetPlayerPos(i, posx, posy, posz);
  74.                 tempposx = (oldposx -posx);
  75.                 tempposy = (oldposy -posy);
  76.                 tempposz = (oldposz -posz);
  77.                 if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16))) // If the player is within 16 meters
  78.                 {
  79.                     SendClientMessage(i, col1, string);
  80.                 }
  81.                 else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8))) // within 8 meters
  82.                 {
  83.                     SendClientMessage(i, col2, string);
  84.                 }
  85.                 else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4))) //4 meters
  86.                 {
  87.                     SendClientMessage(i, col3, string);
  88.                 }
  89.                 else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2))) //2 meters
  90.                 {
  91.                     SendClientMessage(i, col4, string);
  92.                 }
  93.                 else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) //1 meter
  94.                 {
  95.                     SendClientMessage(i, col5, string);
  96.                 }
  97.             }
  98.             else
  99.             {
  100.                 SendClientMessage(i, col1, string);
  101.             }
  102.         }
  103.     }
  104.     return 1;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement