hush

[FilterScript] kWeapons v1.0.2

Feb 27th, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 15.36 KB | None | 0 0
  1. /*
  2.  * kWeapons v1.0.1 - Criado e idealizado por Kusty!
  3.  * Com códigos obtidos atraves do Fórum SA-MP e da Wiki SA-MP.
  4.  * Não retire os créditos.
  5. */
  6.  
  7. #include <a_samp>
  8. #include <zcmd>
  9.  
  10. // ~~~~~~~~~~~~~ Dialogs ~~~~~~~~~~~~~
  11. #define ChoiceOfWeapons     1420
  12. #define AmountOfAmmunition  1421
  13. #define AmountOfHealth      1422
  14. #define AmountOfArmour      1423
  15.  
  16. #define ArmasBrancas        1424
  17. #define Pistolas            1425
  18. #define Escopetas           1426
  19. #define SubMetralhadoras    1427
  20. #define FuzisDeAssalto      1428
  21. #define Rifles              1429
  22. #define Explosivos          1430
  23. #define Presentes           1431
  24. #define Outros              1432
  25. #define VidaEColete         1433
  26.  
  27. #define PriceOfAmmo  (50) // Defina aqui o preço de uma munição.
  28. #define PriceOfHealthAndArmour  (10) // Defina aqui o preço de uma porcentagem de vida e colete.
  29.  
  30. new HealthOrArmour[MAX_PLAYERS]; // Definimos se é vida ou colete.
  31. new IDOfWeapon[MAX_PLAYERS]; // Armazenamos o ID das armas. Idealização por: histire.
  32.  
  33. // ~~~~~~~~~~~~~ Public's ~~~~~~~~~~~~~
  34. public OnFilterScriptInit()
  35. {
  36.     print("\n============== [ kWeapons ] ================");
  37.     print(" Sistema de armas carregado com sucesso! ");
  38.     print("============================================\n");
  39.     return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44.     print("\n============== [ kWeapons ] ================");
  45.     print(" Sistema de armas descarregado com sucesso! ");
  46.     print("============================================\n");
  47.     return 1;
  48. }
  49.  
  50. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  51. {
  52.     // ~~~~~~~~~~~~~ Dialog de escolha da categoria ~~~~~~~~~~~~~
  53.     switch(dialogid) {
  54.         case ChoiceOfWeapons: {
  55.             if(response) {
  56.                 switch(listitem) {
  57.                     case 0: ShowPlayerDialog(playerid, ArmasBrancas, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Armas brancas:", "Soco Inglês\nTaco de Baseball\nSerra Elétrica\nTaco de Golf\nKatana\nFaca\nCacetete\nTaco de Brilhar\nPá", "Selecionar", "Cancelar");
  58.                     case 1: ShowPlayerDialog(playerid, Pistolas, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Pistolas:", "9mm\n9mm com silenciador\nDesert Eagle", "Selecionar", "Cancelar");
  59.                     case 2: ShowPlayerDialog(playerid, Escopetas, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Escopetas:", "Escopeta\nEscopeta de cano cerrado\nSPAS 12", "Selecionar", "Cancelar");
  60.                     case 3: ShowPlayerDialog(playerid, SubMetralhadoras, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Sub-Metralhadoras", "Micro Uzi\nSMG\nTec-9", "Selecionar", "Cancelar");
  61.                     case 4: ShowPlayerDialog(playerid, FuzisDeAssalto, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Fuzis de Assalto:", "AK-47\nM4", "Selecionar", "Cancelar");
  62.                     case 5: ShowPlayerDialog(playerid, Rifles, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Rifles", "Rifle\nRifle de francoatirador", "Selecionar", "Cancelar");
  63.                     case 6: ShowPlayerDialog(playerid, Explosivos, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Explosivos:", "Granada\nCarga Explosiva\nGranada de Gás", "Selecionar", "Cancelar");
  64.                     case 7: ShowPlayerDialog(playerid, Presentes, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Presentes:", "Bengala\nFlores\nVibrador\nVibrador 2\nVibrador Duplo\nVibrador Prata", "Selecionar", "Cancelar");
  65.                     case 8: ShowPlayerDialog(playerid, Outros, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Outros:", "Câmera\nExtintor\nSpray de graffiti\nParaquedas", "Selecionar", "Cancelar");
  66.                     case 9: ShowPlayerDialog(playerid, VidaEColete, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Vida e colete:", "Vida\nColete", "Selecionar", "Cancelar");
  67.             }
  68.         }
  69.     }
  70.    
  71.     // ~~~~~~~~~~~~~ Dialog de armas brancas ~~~~~~~~~~~~~
  72.     case ArmasBrancas: {
  73.         if(response) {
  74.             switch(listitem) {
  75.                 case 0: {
  76.                         GivePlayerWeapon(playerid, 1, 1);
  77.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Soco Inglês por: $100!");
  78.                         GivePlayerMoney(playerid, -100); }
  79.  
  80.                 case 1: {
  81.                         GivePlayerWeapon(playerid, 5, 1);
  82.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Baseball por: $100!");
  83.                         GivePlayerMoney(playerid, -100); }
  84.  
  85.                 case 2: {
  86.                         GivePlayerWeapon(playerid, 9, 1);
  87.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Serra Elétrica por: $500!");
  88.                         GivePlayerMoney(playerid, -500); }
  89.  
  90.                 case 3: {
  91.                         GivePlayerWeapon(playerid, 2, 1);
  92.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Gold por: $100!");
  93.                         GivePlayerMoney(playerid, -100); }
  94.  
  95.                 case 4: {
  96.                         GivePlayerWeapon(playerid, 8, 1);
  97.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Katana por: $100!");
  98.                         GivePlayerMoney(playerid, -100); }
  99.  
  100.                 case 5: {
  101.                         GivePlayerWeapon(playerid, 4, 1);
  102.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Faca por: $50!");
  103.                         GivePlayerMoney(playerid, -50); }
  104.  
  105.                 case 6: {
  106.                         GivePlayerWeapon(playerid, 3, 1);
  107.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Cacete por: $100!");
  108.                         GivePlayerMoney(playerid, -100); }
  109.  
  110.                 case 7: {
  111.                         GivePlayerWeapon(playerid, 9, 1);
  112.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Brilhar(Taco de Snooker/Sinuca) por: $30!");
  113.                         GivePlayerMoney(playerid, -30); }
  114.  
  115.                 case 8: {
  116.                         GivePlayerWeapon(playerid, 9, 1);
  117.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Pá por: $20!");
  118.                         GivePlayerMoney(playerid, -20); }
  119.             }
  120.         }
  121.     }
  122.  
  123.     // ~~~~~~~~~~~~~ Dialog das pistolas ~~~~~~~~~~~~~
  124.     case Pistolas: {
  125.         if(response) {
  126.             switch(listitem) {
  127.                 case 0: {
  128.                         IDOfWeapon[playerid] = 22;
  129.                         AmountsOfAmmunition(playerid); }
  130.  
  131.                 case 1: {
  132.                         IDOfWeapon[playerid] = 23;
  133.                         AmountsOfAmmunition(playerid); }
  134.  
  135.                 case 2: {
  136.                         IDOfWeapon[playerid] = 24;
  137.                         AmountsOfAmmunition(playerid); }
  138.             }
  139.         }
  140.     }
  141.    
  142.     // ~~~~~~~~~~~~~ Dialog das Escopetas ~~~~~~~~~~~~~
  143.     case Escopetas: {
  144.         if(response) {
  145.             switch(listitem) {
  146.                 case 0: {
  147.                         IDOfWeapon[playerid] = 25;
  148.                         AmountsOfAmmunition(playerid); }
  149.  
  150.                 case 1: {
  151.                         IDOfWeapon[playerid] = 26;
  152.                         AmountsOfAmmunition(playerid); }
  153.  
  154.                 case 2: {
  155.                         IDOfWeapon[playerid] = 27;
  156.                         AmountsOfAmmunition(playerid); }
  157.             }
  158.         }
  159.     }
  160.  
  161.     // ~~~~~~~~~~~~~ Dialog das SubMetralhadoras ~~~~~~~~~~~~~
  162.     case SubMetralhadoras: {
  163.         if(response) {
  164.             switch(listitem) {
  165.                 case 0: {
  166.                         IDOfWeapon[playerid] = 28;
  167.                         AmountsOfAmmunition(playerid); }
  168.  
  169.                 case 1: {
  170.                         IDOfWeapon[playerid] = 29;
  171.                         AmountsOfAmmunition(playerid); }
  172.  
  173.                 case 2: {
  174.                         IDOfWeapon[playerid] = 32;
  175.                         AmountsOfAmmunition(playerid); }
  176.             }
  177.         }
  178.     }
  179.  
  180.     // ~~~~~~~~~~~~~ Dialog do Fuzis de Assalto ~~~~~~~~~~~~~
  181.     case FuzisDeAssalto: {
  182.         if(response) {
  183.             switch(listitem) {
  184.                 case 0: {
  185.                         IDOfWeapon[playerid] = 30;
  186.                         AmountsOfAmmunition(playerid); }
  187.  
  188.                 case 1: {
  189.                         IDOfWeapon[playerid] = 31;
  190.                         AmountsOfAmmunition(playerid); }
  191.             }
  192.         }
  193.     }
  194.  
  195.     // ~~~~~~~~~~~~~ Dialog dos Rifles ~~~~~~~~~~~~~
  196.     case Rifles: {
  197.         if(response) {
  198.             switch(listitem) {
  199.                 case 0: {
  200.                         IDOfWeapon[playerid] = 33;
  201.                         AmountsOfAmmunition(playerid); }
  202.  
  203.                 case 1: {
  204.                         IDOfWeapon[playerid] = 34;
  205.                         AmountsOfAmmunition(playerid); }
  206.             }
  207.         }
  208.     }
  209.  
  210.     // ~~~~~~~~~~~~~ Dialog dos Explosivos ~~~~~~~~~~~~~
  211.     case Explosivos: {
  212.         if(response) {
  213.             switch(listitem) {
  214.                 case 0: {
  215.                         IDOfWeapon[playerid] = 16;
  216.                         AmountsOfAmmunition(playerid); }
  217.  
  218.                 case 1: {
  219.                         IDOfWeapon[playerid] = 39;
  220.                         AmountsOfAmmunition(playerid); }
  221.  
  222.                 case 2: {
  223.                         IDOfWeapon[playerid] = 17;
  224.                         AmountsOfAmmunition(playerid); }
  225.             }
  226.         }
  227.     }
  228.  
  229.     // ~~~~~~~~~~~~~ Dialog dos Presentes~~~~~~~~~~~~~
  230.     case Presentes: {
  231.         if(response) {
  232.             switch(listitem) {
  233.                 case 0: {
  234.                         GivePlayerWeapon(playerid, 15, 1);
  235.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Bengala por: $50!");
  236.                         GivePlayerMoney(playerid, -50); }
  237.  
  238.                 case 1: {
  239.                             GivePlayerWeapon(playerid, 14, 1);
  240.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Buquer de Flor por: $20!");
  241.                             GivePlayerMoney(playerid, -20); }
  242.  
  243.                     case 2: {
  244.                             GivePlayerWeapon(playerid, 12, 1);
  245.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $150!");
  246.                             GivePlayerMoney(playerid, -150); }
  247.  
  248.                     case 3: {
  249.                             IDOfWeapon[playerid] = 11;
  250.                             GivePlayerWeapon(playerid, 11, 1);
  251.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $150!");
  252.                             GivePlayerMoney(playerid, -150); }
  253.  
  254.                     case 4: {
  255.                             IDOfWeapon[playerid] = 10;
  256.                             GivePlayerWeapon(playerid, 4, 1);
  257.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $200!");
  258.                             GivePlayerMoney(playerid, -200); }
  259.  
  260.                     case 5: {
  261.                             GivePlayerWeapon(playerid, 13, 1);
  262.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador Prata por: $250!");
  263.                             GivePlayerMoney(playerid, -250); }
  264.             }
  265.         }
  266.     }
  267.    
  268.     // ~~~~~~~~~~~~~ Dialog de Outras Armas/Utilitarios ~~~~~~~~~~~~~
  269.     case Outros: {
  270.         if(response) {
  271.             switch(listitem) {
  272.                 case 0: {
  273.                         IDOfWeapon[playerid] = 43;
  274.                         AmountsOfAmmunition(playerid); }
  275.  
  276.                 case 1: {
  277.                         IDOfWeapon[playerid] = 42;
  278.                         AmountsOfAmmunition(playerid); }
  279.  
  280.                 case 2: {
  281.                         IDOfWeapon[playerid] = 41;
  282.                         AmountsOfAmmunition(playerid); }
  283.  
  284.                 case 3: {
  285.                         GivePlayerWeapon(playerid, 46, 1);
  286.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um paraquedas por: $500!");
  287.                         GivePlayerMoney(playerid, -500); }
  288.             }
  289.         }
  290.     }
  291.  
  292.     // ~~~~~~~~~~~~~ Dialog de vida e colete ~~~~~~~~~~~~~
  293.     case VidaEColete: {
  294.         if(response) {
  295.             switch(listitem) {
  296.                 case 0: {
  297.                         HealthOrArmour[playerid] = 1;
  298.                         AmountsOfHealthAndArmour(playerid); }
  299.  
  300.                 case 1: {
  301.                         HealthOrArmour[playerid] = 2;
  302.                         AmountsOfHealthAndArmour(playerid); }
  303.             }
  304.         }
  305.     }
  306.    
  307.     // ~~~~~~~~~~~~~ Dialog da porcentagem de vida ~~~~~~~~~~~~~
  308.     case AmountOfHealth: {
  309.         if(response) {
  310.                 new
  311.                     Float:Health,
  312.                     FinalPrice = strval(inputtext)*PriceOfHealthAndArmour,
  313.                     string[129];
  314.                
  315.                 if(100-Health > strval(inputtext)) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Sua vida está cheia ou não há espaço para essa porcentagem de vida!");
  316.                 if(GetPlayerMoney(playerid) < FinalPrice) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você não tem dinheiro para comprar essa porcentagem de vida!");
  317.                 if(!IsNumeric(inputtext)) return AmountsOfHealthAndArmour(playerid);
  318.                 if(strval(inputtext) > 100) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} A porcentagem deverá ser entre 1 e 100!");
  319.                 GetPlayerHealth(playerid, Health);
  320.                 SetPlayerHealth(playerid, Health+strval(inputtext));
  321.                 GivePlayerMoney(playerid, -FinalPrice);
  322.                 format(string, sizeof(string), "{FF0000}[kWeapons]:{FFFFFF} Você encheu a sua vida com %i % por $%i!", strval(inputtext), FinalPrice);
  323.                 SendClientMessage(playerid, -1, string);
  324.         }
  325.     }
  326.    
  327.     // ~~~~~~~~~~~~~ Dialog da porcentagem de colete ~~~~~~~~~~~~~
  328.     case AmountOfArmour: {
  329.         if(response) {
  330.             new
  331.                 Float:Armour,
  332.                 FinalPrice = strval(inputtext)*PriceOfHealthAndArmour,
  333.                 string[129];
  334.  
  335.             if(100-Armour > strval(inputtext)) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Seu colete está cheio ou não há espaço para essa porcentagem de colete!");
  336.             if(GetPlayerMoney(playerid) < FinalPrice) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você não tem dinheiro para comprar essa porcentagem de colete!");
  337.             if(!IsNumeric(inputtext)) return AmountsOfHealthAndArmour(playerid);
  338.             if(strval(inputtext) > 100) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} A porcentagem deverá ser entre 1 e 100!");
  339.             GetPlayerArmour(playerid, Armour);
  340.             SetPlayerArmour(playerid, Armour+strval(inputtext));
  341.             GivePlayerMoney(playerid, -FinalPrice);
  342.             format(string, sizeof(string), "{FF0000}[kWeapons]:{FFFFFF} Você encheu o seu colete com %i % por $%i!", strval(inputtext), FinalPrice);
  343.             SendClientMessage(playerid, -1, string);
  344.         }
  345.     }
  346.  
  347.     // ~~~~~~~~~~~~~ Dialog da quantia de munição ~~~~~~~~~~~~~
  348.     case AmountOfAmmunition: {
  349.         if(response) {
  350.             new
  351.                 FinalPrice = strval(inputtext)*PriceOfAmmo,
  352.                 string[129];
  353.  
  354.             if(GetPlayerMoney(playerid) < FinalPrice) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você não tem dinheiro para comprar essa quantia de munição!");
  355.             if(!IsNumeric(inputtext)) return AmountsOfAmmunition(playerid);
  356.             GivePlayerWeapon(playerid, IDOfWeapon[playerid], strval(inputtext));
  357.             GivePlayerMoney(playerid, -FinalPrice);
  358.             format(string, sizeof(string), "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma arma com %i munições por $%i!", strval(inputtext), FinalPrice);
  359.             SendClientMessage(playerid, -1, string);
  360.             return 1;
  361.             }
  362.         }
  363.     }
  364.     return 0;
  365. }
  366.  
  367. // ~~~~~~~~~~~~~ Criamos nosso comando ~~~~~~~~~~~~~
  368. CMD:armas(playerid) {
  369. ShowPlayerDialog(playerid, ChoiceOfWeapons, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Escolha a categoria de armas:", "Armas brancas\nPistolas\nEscopetas\nSub-Metralhadoras\nFuzis de Assalto\nRifles\nExplosivos\nPresentes\nOutros\nVida e Colete", "Selecionar", "Cancelar");
  370. return 1; }
  371.  
  372. // ~~~~~~~~~~~~~ Dialog da quantia de munição ~~~~~~~~~~~~~
  373. stock AmountsOfAmmunition(playerid) {
  374.     new string[129];
  375.     format(string, sizeof(string), "Insira a quantidade de munições que você deseja.\nCada munição está custando: {FF0000}$%i\n\nUtilize somente números*", PriceOfAmmo);
  376.     ShowPlayerDialog(playerid, AmountOfAmmunition, DIALOG_STYLE_INPUT, "{FF0000}[kWeapons]:{FFFFFF} Quantidade de munições:", string, "Comprar", "Cancelar");
  377.     return 1;
  378. }
  379.  
  380. // ~~~~~~~~~~~~~ Dialog da porcentagem de vida e colete ~~~~~~~~~~~~~
  381. stock AmountsOfHealthAndArmour(playerid) {
  382.     new string[129];
  383.     switch(HealthOrArmour[playerid]) {
  384.         case 1: {
  385.                 format(string, sizeof(string), "Insira a porcentagem de vida que você deseja.\nCada porcentagem está custando: {FF0000}$%i\n\nUtilize somente números*", PriceOfHealthAndArmour);
  386.                 ShowPlayerDialog(playerid, AmountOfHealth, DIALOG_STYLE_INPUT, "{FF0000}[kWeapons]:{FFFFFF} Porcentagem de vida:", string, "Comprar", "Cancelar"); }
  387.  
  388.         case 2: {
  389.                 format(string, sizeof(string), "Insira a porcentagem de colete que você deseja.\nCada porcentagem está custando: {FF0000}$%i\n\nUtilize somente números*", PriceOfHealthAndArmour);
  390.                 ShowPlayerDialog(playerid, AmountOfArmour, DIALOG_STYLE_INPUT, "{FF0000}[kWeapons]:{FFFFFF} Porcentagem de colete:", string, "Comprar", "Cancelar"); }
  391.     }
  392.     return 1;
  393. }
  394.  
  395. // ~~~~~~~~~~~~~ Verificamos se é número ~~~~~~~~~~~~~
  396. stock IsNumeric(const string[]) {
  397.     for (new i = 0, j = strlen(string); i < j; i++)
  398.     {
  399.         if (string[i] > '9' || string[i] < '0') return 0;
  400.     }
  401.     return 1;
  402. }
Advertisement
Add Comment
Please, Sign In to add comment