Headache

[FS] Seguro del arma - Headache

Nov 7th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.15 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_VIOLETA 0xC2A2DAAA
  4. // -----------------------------------------------------------------------------
  5. new BigEar[MAX_PLAYERS];
  6. new Seguro[MAX_PLAYERS];
  7. // -----------------------------------------------------------------------------
  8. new GunNames[48][] = { // Nombre de armas.
  9.     "nada",
  10.     "puño americano",
  11.     "palo de golf",
  12.     "porra policial",
  13.     "navaja",
  14.     "bate de baseball",
  15.     "pala",
  16.     "palo de pool",
  17.     "katana",
  18.     "motosierra",
  19.     "consolador violeta",
  20.     "consolador corto blanco",
  21.     "consolador largo blanco",
  22.     "consolador",
  23.     "ramo de flores",
  24.     "bastón",
  25.     "granada explosiva",
  26.     "granada de humo",
  27.     "cóctel molotov",
  28.     "misil de hunter o hydra",
  29.     "fuego de hydra",
  30.     "propulsor",
  31.     "pistola 9mm",
  32.     "pistola 9mm silenciada",
  33.     "pistola desert eagle",
  34.     "escopeta normal",
  35.     "escopeta recortada",
  36.     "escopeta de combate",
  37.     "micro subfusil uzi",
  38.     "subfusil mp5",
  39.     "rifle automático ak47",
  40.     "rifle automático m4",
  41.     "micro subfusil tec9",
  42.     "rifle de caza",
  43.     "rifle de francotirador",
  44.     "lanzacohetes",
  45.     "lanzamisiles busca calor",
  46.     "lanzallamas",
  47.     "minigun",
  48.     "carga explosiva",
  49.     "detonador de carga explosiva",
  50.     "aerosol de gas pimienta",
  51.     "extintor de fuego",
  52.     "cámara fotográfica",
  53.     "gafas de visión nocturna",
  54.     "gafas de visión infrarroja",
  55.     "paracaídas",
  56.     "pistola falsa"
  57. };
  58. // -----------------------------------------------------------------------------
  59. public OnPlayerConnect(playerid)
  60. {
  61.     Seguro[playerid] = 0;
  62.     return 0;
  63. }
  64.  
  65. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  66. {
  67.     if(newkeys & KEY_FIRE)
  68.     {
  69.         if(Seguro[playerid] == 1)
  70.         {
  71.             new Float:PosX, Float:PosY, Float:PosZ;
  72.             GetPlayerPos(playerid, PosX, PosY, PosZ);
  73.             SetPlayerPos(playerid, PosX, PosY, PosZ+1);
  74.             SendClientMessage(playerid, 0x33AA3300, "Tu arma tiene el mecanismo de seguro activo, el disparo no se efectuará.");
  75.             return 1;
  76.         }
  77.         return 1;
  78.     }
  79.     return 0;
  80. }
  81.  
  82. public OnPlayerCommandText(playerid, cmdtext[])
  83. {
  84.     new cmd[256];
  85.     if(strcmp(cmd, "/seguro", true) == 0 || strcmp(cmd, "/seg", true) == 0)
  86.     {
  87.         new gunname[25];
  88.         new string[100];
  89.         GetWeaponNameEx(gunID, gunname, sizeof(gunname));
  90.         format(string, sizeof(string), "* %s le coloca el seguro a su %s.", PlayerName(playerid), gunname);
  91.         ProxDetector(30.0, playerid, string, COLOR_VIOLETA,COLOR_VIOLETA,COLOR_VIOLETA,COLOR_VIOLETA,COLOR_VIOLETA);
  92.         Seguro[playerid] = 1;
  93.         return 1;
  94.         }
  95.     }
  96.     if(strcmp(cmd, "/qseguro", true) == 0 || strcmp(cmd, "/qseg", true) == 0)
  97.     {
  98.         GetWeaponNameEx(gunID, gunname, sizeof(gunname));
  99.         format(string, sizeof(string), "* %s le quita el seguro a su %s.", PlayerName(playerid), gunname);
  100.         ProxDetector(30.0, playerid, string, COLOR_VIOLETA,COLOR_VIOLETA,COLOR_VIOLETA,COLOR_VIOLETA,COLOR_VIOLETA);
  101.         Seguro[playerid] = 0;
  102.         return 1;
  103.         }
  104.     }
  105.     return 0;
  106. }
  107. // -----------------------------------------------------------------------------
  108. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  109. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  110. {
  111.     if(IsPlayerConnected(playerid))
  112.     {
  113.         new Float:posx, Float:posy, Float:posz;
  114.         new Float:oldposx, Float:oldposy, Float:oldposz;
  115.         new Float:tempposx, Float:tempposy, Float:tempposz;
  116.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  117.         //radi = 2.0; //Trigger Radius
  118.         for(new i = 0; i < MAX_PLAYERS; i++)
  119.         {
  120.             if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  121.             {
  122.                 if(!BigEar[i])
  123.                 {
  124.                     GetPlayerPos(i, posx, posy, posz);
  125.                     tempposx = (oldposx -posx);
  126.                     tempposy = (oldposy -posy);
  127.                     tempposz = (oldposz -posz);
  128.                     if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  129.                     {
  130.                         SendClientMessage(i, col1, string);
  131.                     }
  132.                     else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  133.                     {
  134.                         SendClientMessage(i, col2, string);
  135.                     }
  136.                     else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  137.                     {
  138.                         SendClientMessage(i, col3, string);
  139.                     }
  140.                     else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  141.                     {
  142.                         SendClientMessage(i, col4, string);
  143.                     }
  144.                     else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  145.                     {
  146.                         SendClientMessage(i, col5, string);
  147.                     }
  148.                 }
  149.                 else
  150.                 {
  151.                     SendClientMessage(i, col1, string);
  152.                 }
  153.             }
  154.         }
  155.     }//not connected
  156.     return 1;
  157. }
  158.  
  159. stock GetWeaponNameEx(id, name[], len) return format(name,len, "%s", GunNames[id]);
  160.  
  161. stock PlayerName(playerid)
  162. {
  163.     new Nombre[24];
  164.     GetPlayerName(playerid,Nombre,24);
  165.     new N[24];
  166.     strmid(N,Nombre,0,strlen(Nombre),24);
  167.     for(new i = 0; i < MAX_PLAYER_NAME; i++)
  168.     {
  169.         if (N[i] == '_') N[i] = ' ';
  170.     }
  171.     return N;
  172. }
Advertisement
Add Comment
Please, Sign In to add comment