SHARE
TWEET

[INC] Include SamP Arma Especial - Rocket System

Chip7 Jun 16th, 2012 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*VISITE NOSSO SITE: http://www.sampknd.com/
  2.   SAMP KND MELHOR BLOG DE SAMP DO BRASIL
  3. */
  4.  
  5. #include <a_samp>
  6.  
  7. #define KEY_AIM 128
  8.  
  9. new Missel[MAX_OBJECTS], m;
  10.  
  11. enum WeaponInfo
  12. {
  13.     Ammo1,
  14.     Ammo2,
  15.     bool:Have,
  16.     bool:Lauch,
  17.     Timer,
  18.     bool:Wating
  19. }
  20.  
  21. new WI[MAX_PLAYERS][WeaponInfo];
  22.  
  23. // Filter by Gustavo Bonomo
  24.  
  25. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  26. {
  27.     if(newkeys & KEY_YES && GetPlayerWeapon(playerid) == 27 && WI[playerid][Have] == true && WI[playerid][Wating] == false)
  28.     {
  29.         if(WI[playerid][Lauch] == false)
  30.         {
  31.             new ammo, weapon;
  32.             GetPlayerWeaponData(playerid, 3, weapon, ammo);
  33.             WI[playerid][Ammo2] = ammo;
  34.             RemovePlayerWeapon(playerid, 27);
  35.             WI[playerid][Lauch] = true;
  36.             GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
  37.             GameTextForPlayer(playerid, "ON", 1000, 4);
  38.             ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
  39.         }
  40.         else
  41.         {
  42.             RemovePlayerWeapon(playerid, 27);
  43.             WI[playerid][Lauch] = false;
  44.             GivePlayerWeapon(playerid, 27, WI[playerid][Ammo2]);
  45.             GameTextForPlayer(playerid, "OFF", 1000, 4);
  46.             ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
  47.         }
  48.     }
  49.     else if((newkeys & KEY_FIRE && newkeys & KEY_AIM || newkeys == KEY_FIRE) && GetPlayerWeapon(playerid) == 27 && WI[playerid][Have] == true && WI[playerid][Lauch] == true && WI[playerid][Wating] == false)
  50.     {
  51.         new target = GetPlayerTargetPlayer(playerid);
  52.         LancarMissel(playerid, target);
  53.         RemovePlayerWeapon(playerid, 27);
  54.         WI[playerid][Wating] = true;
  55.         WI[playerid][Ammo1] --;
  56.         GivePlayerWeapon(playerid, 27, WI[playerid][Ammo2]);
  57.         GameTextForPlayer(playerid, "OFF", 1000, 4);
  58.         ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
  59.         SetTimerEx("Liberar", 5000, false, "i", playerid);
  60.     }
  61.     return 1;
  62. }
  63.  
  64. #if defined _ALS_OnPlayerKeyStateChange
  65.     #undef OnPlayerKeyStateChange
  66. #else
  67.     #define _ALS_OnPlayerKeyStateChange
  68. #endif
  69. #define OnPlayerKeyStateChange gb_OnPlayerKeyStateChange
  70. forward gb_OnPlayerKeyStateChange();
  71.  
  72. forward Liberar(playerid);
  73. public Liberar(playerid)
  74. {
  75.     RemovePlayerWeapon(playerid, 27);
  76.     WI[playerid][Wating] = false;
  77.     GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
  78.     GameTextForPlayer(playerid, "ON", 1000, 4);
  79.     ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
  80.     return 1;
  81. }
  82.  
  83. forward AtualizarMissel(playerid, objid);
  84. public AtualizarMissel(playerid, objid)
  85. {
  86.     new Float:PosT[3];
  87.     GetPlayerPos(playerid, PosT[0], PosT[1], PosT[2]);
  88.     if(ObjectToPoint(2.0, objid, PosT[0], PosT[1], PosT[2]))
  89.     {
  90.         CreateExplosion(PosT[0], PosT[1], PosT[2], 5, 10.0);
  91.         DestroyObject(objid);
  92.         KillTimer(WI[playerid][Timer]);
  93.     }
  94.     else if(PosT[0] != GetPVarFloat(playerid, "playerX") || PosT[1] != GetPVarFloat(playerid, "playerY") || PosT[2] != GetPVarFloat(playerid, "playerZ"))
  95.     {
  96.         SetPVarFloat(playerid, "playerX", PosT[0]), SetPVarFloat(playerid, "playerY", PosT[1]), SetPVarFloat(playerid, "playerZ", PosT[2]);
  97.         StopObject(objid);
  98.         MoveObject(objid, PosT[0], PosT[1], PosT[2], 10.0);
  99.     }
  100.     return 1;
  101. }
  102.  
  103. forward FinalizarMissel(objid);
  104. public FinalizarMissel(objid)
  105. {
  106.     new Float:Pos[3];
  107.     GetObjectPos(objid, Pos[0], Pos[1], Pos[2]);
  108.     CreateExplosion(Pos[0], Pos[1], Pos[2], 5, 10.0);
  109.     DestroyObject(objid);
  110.     return 1;
  111. }
  112.  
  113. stock LancarMissel(playerid, target)
  114. {
  115.     m++;
  116.     new Float:PosT[3], Float:PosP[3];
  117.     GetPlayerPos(playerid, PosP[0], PosP[1], PosP[2]);
  118.     if(target != INVALID_PLAYER_ID)
  119.     {
  120.         GetPlayerPos(target, PosT[0], PosT[1], PosT[2]);
  121.         Missel[m] = CreateObject(354, PosP[0], PosP[1], PosP[2], 0.0, 0.0, 0.0);
  122.         MoveObject(Missel[m], PosT[0], PosT[1], PosT[2], 10.0);
  123.         SetPVarFloat(playerid, "playerX", PosT[0]), SetPVarFloat(playerid, "playerY", PosT[1]), SetPVarFloat(playerid, "playerZ", PosT[2]);
  124.         WI[playerid][Timer] = SetTimerEx("AtualizarMissel", 250, true, "ii", target, Missel[m]);
  125.         SetTimerEx("FinalizarMissel", 5000, false, "i", Missel[m]);
  126.     }
  127.     else
  128.     {
  129.         new Float:fP[3], Float:fV[3], Float:PosO[3];
  130.         GetPlayerCameraPos(playerid, fP[0], fP[1], fP[2]);
  131.         GetPlayerCameraFrontVector(playerid, fV[0], fV[1], fV[2]);
  132.         PosO[0] = fP[0] + floatmul(fV[0], 60.0);
  133.         PosO[1] = fP[1] + floatmul(fV[1], 60.0);
  134.         PosO[2] = fP[2] + floatmul(fV[2], 60.0);
  135.         Missel[m] = CreateObject(354, PosP[0], PosP[1], PosP[2], 0.0, 0.0, 0.0);
  136.         MoveObject(Missel[m], PosO[0], PosO[1], PosO[2], 10.0);
  137.         SetTimerEx("FinalizarMissel", 5000, false, "i", Missel[m]);
  138.     }
  139.     return 1;
  140. }
  141.  
  142. stock RemovePlayerWeapon(playerid, weaponid)
  143. {
  144.     if(!IsPlayerConnected(playerid) || weaponid < 0 || weaponid > 50)
  145.         return;
  146.  
  147.     new
  148.         saveweapon[13],
  149.         saveammo[13];
  150.  
  151.     for(new slot = 0; slot < 13; slot++)
  152.         GetPlayerWeaponData(playerid, slot, saveweapon[slot], saveammo[slot]);
  153.  
  154.     ResetPlayerWeapons(playerid);
  155.  
  156.     for(new slot; slot < 13; slot++)
  157.     {
  158.         if(saveweapon[slot] == weaponid || saveammo[slot] == 0)
  159.             continue;
  160.  
  161.         GivePlayerWeapon(playerid, saveweapon[slot], saveammo[slot]);
  162.     }
  163.  
  164.     GivePlayerWeapon(playerid, 0, 1);
  165. }
  166.  
  167. stock ObjectToPoint(Float:radi, objectid, Float:x, Float:y, Float:z)
  168. {
  169.     new Float:oldposx, Float:oldposy, Float:oldposz;
  170.     new Float:tempposx, Float:tempposy, Float:tempposz;
  171.     GetObjectPos(objectid, oldposx, oldposy, oldposz);
  172.     tempposx = (oldposx -x);
  173.     tempposy = (oldposy -y);
  174.     tempposz = (oldposz -z);
  175.     if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  176.     {
  177.         return 1;
  178.     }
  179.     return 0;
  180. }
  181.  
  182. stock GivePlayerSpecialWeapon(playerid, ammu)
  183. {
  184.     WI[playerid][Have] = true;
  185.     WI[playerid][Ammo1] = ammu;
  186.     new ammo, weapon;
  187.     GetPlayerWeaponData(playerid, 3, weapon, ammo);
  188.     WI[playerid][Ammo2] = ammo;
  189.     RemovePlayerWeapon(playerid, 27);
  190.     GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
  191.     return 1;
  192. }
  193.  
  194. stock ResetPlayerSpecialWeapon(playerid)
  195. {
  196.     Have[playerid] = false;
  197.     Lauch[playerid] = false;
  198.     Ammo[playerid] = 0;
  199.     RemovePlayerWeapon(playerid, 27);
  200.     return 1;
  201. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top