Advertisement
bruno_travi

Explosivos13

Aug 24th, 2014
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.51 KB | None | 0 0
  1. //=================== | INCLUDES | ====================
  2. #include <a_samp>
  3. #include <zcmd>
  4. #include <streamer>
  5.  
  6. //==================== | MACROS | =====================
  7. #define CALL::%0(%1) forward %0(%1); public %0(%1)
  8.  
  9. //==================== | DEFINES | ====================
  10. #define MAX_SMOKE 100
  11. #define COR_ROXOCLARO 0xC2A2DAFF
  12. #define COR_VERMELHO 0xCD5C5CFF
  13.  
  14. //=================== | VARIÁVEIS | ===================
  15. new Armas[MAX_PLAYERS][13][2];
  16. new bool:Mask[MAX_PLAYERS];
  17. //GRANADA SMOKE
  18. enum SMKInfo
  19. {
  20.     ObjSmoke,
  21.     EfeitoSmoke,
  22.     Float:SPosX,
  23.     Float:SPosY,
  24.     Float:SPosZ,
  25.     SWorld,
  26.     SInterior
  27. }
  28.  
  29. new SmokeInfo[MAX_SMOKE][SMKInfo];
  30.  
  31. new bool:GranadaSmoke[MAX_PLAYERS];
  32. new bool:RespirandoSmoke[MAX_PLAYERS];
  33.  
  34. new Float:DisX[MAX_PLAYERS], Float:DisY[MAX_PLAYERS], Float:DisZ[MAX_PLAYERS];
  35.  
  36. //BOMBA C4
  37. new bool:GranadaC4[MAX_PLAYERS];
  38. new bool:AcionadorC4[MAX_PLAYERS];
  39. new ObjC4[MAX_PLAYERS];
  40. new Float:PosC4[3][MAX_PLAYERS];
  41.  
  42. //=============== | SA-MP CALLBACKS | =================
  43. public OnFilterScriptInit()
  44. {
  45.     print("  Explosivos13 Carregado!");
  46.     return 1;
  47. }
  48.  
  49. public OnPlayerConnect(playerid)
  50. {
  51.     RespirandoSmoke[playerid] = false;
  52.     Mask[playerid] = false;
  53.     SetTimerEx("CheckProx", 1000, true, "i", playerid);
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerDeath(playerid, killerid, reason)
  58. {
  59.     RespirandoSmoke[playerid] = false;
  60.     GranadaSmoke[playerid] = false;
  61.     GranadaC4[playerid] = false;
  62.     AcionadorC4[playerid] = false;
  63.     Mask[playerid] = false;
  64.     return 1;
  65. }
  66.  
  67. public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
  68. {
  69.     if(newkeys == KEY_FIRE && GranadaSmoke[playerid] == true)
  70.     {
  71.         GranadaSmoke[playerid] = false;
  72.         ApplyAnimation(playerid, "GANGS", "DRUGS_BUY", 4.1, 0, 1, 1, 1, 1, 1);
  73.         SetTimerEx("PlantarSmoke1", 900, 0, "i", playerid);
  74.     }
  75.  
  76.     if(newkeys == KEY_FIRE && GranadaC4[playerid] == true)
  77.     {
  78.         GranadaC4[playerid] = false;
  79.         ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 0, 1, 1, 1, 1, 1);
  80.         SetTimerEx("PlantarC4", 1000, 0, "i", playerid);
  81.     }
  82.  
  83.     if(newkeys == KEY_FIRE && AcionadorC4[playerid] == true)
  84.     {
  85.         ApplyAnimation(playerid, "BD_FIRE", "BD_Fire1", 4.1, 0, 1, 1, 1, 1, 1);
  86.         if(IsPlayerAttachedObjectSlotUsed(playerid, 1)) RemovePlayerAttachedObject(playerid, 1);
  87.         AcionadorC4[playerid] = false;
  88.         CreateExplosion(PosC4[0][playerid], PosC4[1][playerid], PosC4[2][playerid], 7, 3.0);
  89.         DestroyDynamicObject(ObjC4[playerid]);
  90.         SetTimerEx("SetarArmas", 300, false, "i", playerid);
  91.     }
  92.  
  93.     return 1;
  94. }
  95.  
  96. //==================== | MINHAS CALLBACKS | ====================
  97. CALL::GuardarArmas(playerid)
  98. {
  99.     new weapons[13][2];
  100.  
  101.     for (new i = 0; i <= 12; i++)
  102.     {
  103.         GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
  104.         Armas[playerid][i][0] = weapons[i][0];
  105.         Armas[playerid][i][1] = weapons[i][1];
  106.     }
  107.     ResetPlayerWeapons(playerid);
  108.     return 1;
  109. }
  110.  
  111. CALL::SetarArmas(playerid)
  112. {
  113.     for (new i = 0; i <= 12; i++)
  114.     {
  115.         GivePlayerWeapon(playerid, Armas[playerid][i][0], Armas[playerid][i][1]);
  116.     }
  117. }
  118.  
  119. CALL::CheckProx(playerid)
  120. {
  121.     if(Mask[playerid] == true) return 1;
  122.     if(RespirandoSmoke[playerid] == false || !IsPlayerInAnyVehicle(playerid))
  123.     {
  124.         for(new i = 0; i < sizeof(SmokeInfo); i++)
  125.         {
  126.             if(IsPlayerInRangeOfPoint(playerid, 6.0, SmokeInfo[i][SPosX], SmokeInfo[i][SPosY], SmokeInfo[i][SPosZ]))
  127.             {
  128.                 if(GetPlayerVirtualWorld(playerid) == SmokeInfo[i][SWorld] && GetPlayerInterior(playerid) == SmokeInfo[i][SInterior])
  129.                 {
  130.                     RespirandoSmoke[playerid] = true;
  131.                     ApplyAnimation(playerid, "PED", "gas_cwr", 4.1, 0, 1, 1, 1, 1, 1);
  132.                     DisX[playerid] = SmokeInfo[i][SPosX];
  133.                     DisY[playerid] = SmokeInfo[i][SPosY];
  134.                     DisZ[playerid] = SmokeInfo[i][SPosZ];
  135.                     SetTimerEx("AnimSmoke", 100, false, "i", playerid);
  136.                     break;
  137.                 }
  138.             }
  139.         }
  140.     }
  141.     return 1;
  142. }
  143.  
  144. CALL::PlantarSmoke1(playerid)
  145. {
  146.     ApplyAnimation(playerid, "BOMBER", "BOM_Plant_2Idle", 4.1, 0, 1, 1, 1, 1, 1);
  147.     SetTimerEx("PlantarSmoke2", 400, 0, "i", playerid);
  148.     return 1;
  149. }
  150.  
  151. CALL::PlantarSmoke2(playerid)
  152. {
  153.     ApplyAnimation(playerid, "BD_FIRE", "BD_Fire1", 4.1, 0, 1, 1, 1, 1, 1);//stop animes (clearanimatios fail D: )
  154.     if(IsPlayerAttachedObjectSlotUsed(playerid, 1)) RemovePlayerAttachedObject(playerid, 1);
  155.     SetarArmas(playerid);
  156.  
  157.     new Float:X, Float:Y, Float:Z;
  158.     new worldid = GetPlayerVirtualWorld(playerid);
  159.     new interiorid = GetPlayerInterior(playerid);
  160.     GetPlayerPos(playerid, X, Y, Z);
  161.  
  162.     for(new i = 0; i < sizeof(SmokeInfo); i++)
  163.     {
  164.         if(SmokeInfo[i][SPosX] == 0.0 && SmokeInfo[i][SPosY] == 0.0 && SmokeInfo[i][SPosZ] == 0.0)
  165.         {
  166.             SmokeInfo[i][ObjSmoke] = CreateDynamicObject(343, X, Y, Z-0.90, 0.0, 90.0, 0.0, worldid, interiorid);
  167.             SmokeInfo[i][EfeitoSmoke] = CreateDynamicObject(18715, X, Y, Z-0.90, 0.0, 0.0, 0.0, worldid, interiorid);
  168.             SmokeInfo[i][SPosX] = X;
  169.             SmokeInfo[i][SPosY] = Y;
  170.             SmokeInfo[i][SPosZ] = Z;
  171.             SmokeInfo[i][SWorld] = worldid;
  172.             SmokeInfo[i][SInterior] = interiorid;
  173.             SetTimerEx("RemoveSmoke", 30000, false, "ddddd", SmokeInfo[i][ObjSmoke], SmokeInfo[i][EfeitoSmoke], i, i, i);
  174.             break;
  175.         }
  176.     }
  177.     return 1;
  178. }
  179.  
  180. CALL::RemoveSmoke(granaid, smokeid, SmokeX, SmokeY, SmokeZ)
  181. {
  182.     DestroyDynamicObject(granaid);
  183.     DestroyDynamicObject(smokeid);
  184.     SmokeInfo[SmokeX][SPosX] = 0.0;
  185.     SmokeInfo[SmokeY][SPosY] = 0.0;
  186.     SmokeInfo[SmokeZ][SPosZ] = 0.0;
  187.     return 1;
  188. }
  189.  
  190. CALL::AnimSmoke(playerid)
  191. {
  192.     new Float:X, Float:Y, Float:Z;
  193.     GetPlayerPos(playerid, X, Y, Z);
  194.     if(IsPlayerInRangeOfPoint(playerid, 6.0, DisX[playerid], DisY[playerid], DisZ[playerid]) && RespirandoSmoke[playerid] == true)
  195.     {
  196.         ApplyAnimation(playerid, "PED", "gas_cwr", 4.1, 0, 1, 1, 1, 1, 1);
  197.         SetTimerEx("AnimSmoke", 100, false, "i", playerid);
  198.         return 1;
  199.     }
  200.     RespirandoSmoke[playerid] = false;
  201.     ApplyAnimation(playerid, "PED", "IDLE_tired", 4.1, 0, 1, 1, 1, 1, 1);
  202.     SetTimerEx("StopAnim", 600, false, "i", playerid);
  203.     return 1;
  204. }
  205.  
  206. CALL::StopAnim(playerid)
  207. {
  208.     ApplyAnimation(playerid, "BD_FIRE", "BD_Fire1", 4.1, 0, 1, 1, 1, 1, 1);
  209.     return 1;
  210. }
  211.  
  212. CALL::PlantarC4(playerid)
  213. {
  214.     ApplyAnimation(playerid, "BD_FIRE", "BD_Fire1", 4.1, 0, 1, 1, 1, 1, 1);//stop animes (clearanimatios fail D: )
  215.     if(IsPlayerAttachedObjectSlotUsed(playerid, 1)) RemovePlayerAttachedObject(playerid, 1);
  216.     new Float:X, Float:Y, Float:Z;
  217.     new worldid = GetPlayerVirtualWorld(playerid);
  218.     new interiorid = GetPlayerInterior(playerid);
  219.     GetPlayerPos(playerid, X, Y, Z);
  220.     ObjC4[playerid] = CreateDynamicObject(1654, X, Y, Z-0.90, 0.0, 90.0, 0.0, worldid, interiorid);
  221.     PosC4[0][playerid] = X;
  222.     PosC4[1][playerid] = Y;
  223.     PosC4[2][playerid] = Z;
  224.     AcionadorC4[playerid] = true;
  225.     SetPlayerAttachedObject(playerid, 1, 364, 5, 0.074481, 0.121008, -0.062193, 145.491744, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000); // bomb - Acionador C4
  226.     return 1;
  227. }
  228.  
  229. //==================== | COMANDOS | ====================
  230. CMD:granada(playerid)
  231. {
  232.     if(GranadaC4[playerid] == true || AcionadorC4[playerid] == true) return SendClientMessage(playerid, -1, "-Erro- Você já está com as mãos ocupadas");
  233.     GuardarArmas(playerid);
  234.     SetPlayerAttachedObject(playerid, 1, 343, 6, 0.078793, 0.008405, -0.007976, 13.225624, 5.088777, 74.662277, 1.000000, 1.000000, 1.000000 ); // teargas - Bomba de fumaça
  235.     GranadaSmoke[playerid] = true;
  236.     return 1;
  237. }
  238.  
  239. CMD:c4(playerid)
  240. {
  241.     if(GranadaSmoke[playerid] == true || AcionadorC4[playerid] == true) return SendClientMessage(playerid, -1, "-Erro- Você já está com as mãos ocupadas");
  242.     GuardarArmas(playerid);
  243.     SetPlayerAttachedObject( playerid, 1, 1654, 5, 0.123819, 0.016621, 0.000729, 336.107452, 351.245513, 52.185253, 1.000000, 1.000000, 1.000000 ); // dynamite - Bomba C4
  244.     GranadaC4[playerid] = true;
  245.     return 1;
  246. }
  247.  
  248. CMD:mask(playerid)
  249. {
  250.     if(RespirandoSmoke[playerid] == true) return 1;
  251.     if(Mask[playerid] == false)
  252.     {
  253.         ApplyAnimation(playerid, "FIGHT_B", "FightB_block", 4.1, 0, 1, 1, 1, 1, 1);
  254.         SetTimerEx("StopAnim", 400, false, "i", playerid);
  255.         SetPlayerAttachedObject(playerid, 0, 19036, 2, 0.091755, 0.030188, 0.001176, 94.722915, 90.211921, 0.000000, 1.000000, 1.000000, 1.000000); // HockeyMask1 - Mask
  256.         Mask[playerid] = true;
  257.     }
  258.     else
  259.     {
  260.         ApplyAnimation(playerid, "FIGHT_B", "FightB_block", 4.1, 0, 1, 1, 1, 1, 1);
  261.         SetTimerEx("StopAnim", 400, false, "i", playerid);
  262.         if(IsPlayerAttachedObjectSlotUsed(playerid, 0)) RemovePlayerAttachedObject(playerid, 0);
  263.         Mask[playerid] = false;
  264.     }
  265.     return 1;
  266. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement