Advertisement
hush

[FilterScript] kWeapons v1.0.1

Feb 26th, 2013
1,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 16.29 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.    
  72.     // ~~~~~~~~~~~~~ Dialog de armas brancas ~~~~~~~~~~~~~
  73.     switch(dialogid) {
  74.         case ArmasBrancas: {
  75.             if(response) {
  76.                 switch(listitem) {
  77.                     case 0: {
  78.                             GivePlayerWeapon(playerid, 1, 1);
  79.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Soco Inglês por: $100!");
  80.                             GivePlayerMoney(playerid, -100); }
  81.  
  82.                     case 1: {
  83.                             GivePlayerWeapon(playerid, 5, 1);
  84.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Baseball por: $100!");
  85.                             GivePlayerMoney(playerid, -100); }
  86.  
  87.                     case 2: {
  88.                             GivePlayerWeapon(playerid, 9, 1);
  89.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Serra Elétrica por: $500!");
  90.                             GivePlayerMoney(playerid, -500); }
  91.  
  92.                     case 3: {
  93.                             GivePlayerWeapon(playerid, 2, 1);
  94.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Gold por: $100!");
  95.                             GivePlayerMoney(playerid, -100); }
  96.  
  97.                     case 4: {
  98.                             GivePlayerWeapon(playerid, 8, 1);
  99.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Katana por: $100!");
  100.                             GivePlayerMoney(playerid, -100); }
  101.  
  102.                     case 5: {
  103.                             GivePlayerWeapon(playerid, 4, 1);
  104.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Faca por: $50!");
  105.                             GivePlayerMoney(playerid, -50); }
  106.  
  107.                     case 6: {
  108.                             GivePlayerWeapon(playerid, 3, 1);
  109.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Cacete por: $100!");
  110.                             GivePlayerMoney(playerid, -100); }
  111.  
  112.                     case 7: {
  113.                             GivePlayerWeapon(playerid, 9, 1);
  114.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Brilhar(Taco de Snooker/Sinuca) por: $30!");
  115.                             GivePlayerMoney(playerid, -30); }
  116.  
  117.                     case 8: {
  118.                             GivePlayerWeapon(playerid, 9, 1);
  119.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Pá por: $20!");
  120.                             GivePlayerMoney(playerid, -20); }
  121.                 }
  122.             }
  123.         }
  124.     }
  125.  
  126.     // ~~~~~~~~~~~~~ Dialog das pistolas ~~~~~~~~~~~~~
  127.     switch(dialogid) {
  128.         case Pistolas: {
  129.             if(response) {
  130.                 switch(listitem) {
  131.                     case 0: {
  132.                             IDOfWeapon[playerid] = 22;
  133.                             AmountsOfAmmunition(playerid); }
  134.  
  135.                     case 1: {
  136.                             IDOfWeapon[playerid] = 23;
  137.                             AmountsOfAmmunition(playerid); }
  138.  
  139.                     case 2: {
  140.                             IDOfWeapon[playerid] = 24;
  141.                             AmountsOfAmmunition(playerid); }
  142.                 }
  143.             }
  144.         }
  145.     }
  146.    
  147.     // ~~~~~~~~~~~~~ Dialog das Escopetas ~~~~~~~~~~~~~
  148.     switch(dialogid) {
  149.         case Escopetas: {
  150.             if(response) {
  151.                 switch(listitem) {
  152.                     case 0: {
  153.                             IDOfWeapon[playerid] = 25;
  154.                             AmountsOfAmmunition(playerid); }
  155.  
  156.                     case 1: {
  157.                             IDOfWeapon[playerid] = 26;
  158.                             AmountsOfAmmunition(playerid); }
  159.  
  160.                     case 2: {
  161.                             IDOfWeapon[playerid] = 27;
  162.                             AmountsOfAmmunition(playerid); }
  163.                 }
  164.             }
  165.         }
  166.     }
  167.  
  168.     // ~~~~~~~~~~~~~ Dialog das SubMetralhadoras ~~~~~~~~~~~~~
  169.     switch(dialogid) {
  170.         case SubMetralhadoras: {
  171.             if(response) {
  172.                 switch(listitem) {
  173.                     case 0: {
  174.                             IDOfWeapon[playerid] = 28;
  175.                             AmountsOfAmmunition(playerid); }
  176.  
  177.                     case 1: {
  178.                             IDOfWeapon[playerid] = 29;
  179.                             AmountsOfAmmunition(playerid); }
  180.  
  181.                     case 2: {
  182.                             IDOfWeapon[playerid] = 32;
  183.                             AmountsOfAmmunition(playerid); }
  184.                 }
  185.             }
  186.         }
  187.     }
  188.  
  189.     // ~~~~~~~~~~~~~ Dialog do Fuzis de Assalto ~~~~~~~~~~~~~
  190.     switch(dialogid) {
  191.         case FuzisDeAssalto: {
  192.             if(response) {
  193.                 switch(listitem) {
  194.                     case 0: {
  195.                             IDOfWeapon[playerid] = 30;
  196.                             AmountsOfAmmunition(playerid); }
  197.  
  198.                     case 1: {
  199.                             IDOfWeapon[playerid] = 31;
  200.                             AmountsOfAmmunition(playerid); }
  201.                 }
  202.             }
  203.         }
  204.     }
  205.  
  206.     // ~~~~~~~~~~~~~ Dialog dos Rifles ~~~~~~~~~~~~~
  207.     switch(dialogid) {
  208.         case Rifles: {
  209.             if(response) {
  210.                 switch(listitem) {
  211.                     case 0: {
  212.                             IDOfWeapon[playerid] = 33;
  213.                             AmountsOfAmmunition(playerid); }
  214.  
  215.                     case 1: {
  216.                             IDOfWeapon[playerid] = 34;
  217.                             AmountsOfAmmunition(playerid); }
  218.                 }
  219.             }
  220.         }
  221.     }
  222.  
  223.     // ~~~~~~~~~~~~~ Dialog dos Explosivos ~~~~~~~~~~~~~
  224.     switch(dialogid) {
  225.         case Explosivos: {
  226.             if(response) {
  227.                 switch(listitem) {
  228.                     case 0: {
  229.                             IDOfWeapon[playerid] = 16;
  230.                             AmountsOfAmmunition(playerid); }
  231.  
  232.                     case 1: {
  233.                             IDOfWeapon[playerid] = 39;
  234.                             AmountsOfAmmunition(playerid); }
  235.  
  236.                     case 2: {
  237.                             IDOfWeapon[playerid] = 17;
  238.                             AmountsOfAmmunition(playerid); }
  239.                 }
  240.             }
  241.         }
  242.     }
  243.  
  244.     // ~~~~~~~~~~~~~ Dialog dos Presentes~~~~~~~~~~~~~
  245.     switch(dialogid) {
  246.         case Presentes: {
  247.             if(response) {
  248.                 switch(listitem) {
  249.                     case 0: {
  250.  
  251.                             GivePlayerWeapon(playerid, 15, 1);
  252.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Bengala por: $50!");
  253.                             GivePlayerMoney(playerid, -50); }
  254.  
  255.                     case 1: {
  256.                             GivePlayerWeapon(playerid, 14, 1);
  257.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Buquer de Flor por: $20!");
  258.                             GivePlayerMoney(playerid, -20); }
  259.  
  260.                     case 2: {
  261.                             GivePlayerWeapon(playerid, 12, 1);
  262.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $150!");
  263.                             GivePlayerMoney(playerid, -150); }
  264.  
  265.                     case 3: {
  266.                             IDOfWeapon[playerid] = 11;
  267.                             GivePlayerWeapon(playerid, 11, 1);
  268.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $150!");
  269.                             GivePlayerMoney(playerid, -150); }
  270.  
  271.                     case 4: {
  272.                             IDOfWeapon[playerid] = 10;
  273.                             GivePlayerWeapon(playerid, 4, 1);
  274.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $200!");
  275.                             GivePlayerMoney(playerid, -200); }
  276.  
  277.                     case 5: {
  278.                             GivePlayerWeapon(playerid, 13, 1);
  279.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador Prata por: $250!");
  280.                             GivePlayerMoney(playerid, -250); }
  281.                 }
  282.             }
  283.         }
  284.     }
  285.    
  286.     // ~~~~~~~~~~~~~ Dialog de Outras Armas/Utilitarios ~~~~~~~~~~~~~
  287.     switch(dialogid) {
  288.         case Outros: {
  289.             if(response) {
  290.                 switch(listitem) {
  291.                     case 0: {
  292.                             IDOfWeapon[playerid] = 43;
  293.                             AmountsOfAmmunition(playerid); }
  294.  
  295.                     case 1: {
  296.                             IDOfWeapon[playerid] = 42;
  297.                             AmountsOfAmmunition(playerid); }
  298.  
  299.                     case 2: {
  300.                             IDOfWeapon[playerid] = 41;
  301.                             AmountsOfAmmunition(playerid); }
  302.  
  303.                     case 3: {
  304.                             GivePlayerWeapon(playerid, 46, 1);
  305.                             SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um paraquedas por: $500!");
  306.                             GivePlayerMoney(playerid, -500); }
  307.                 }
  308.             }
  309.         }
  310.     }
  311.  
  312.     // ~~~~~~~~~~~~~ Dialog de vida e colete ~~~~~~~~~~~~~
  313.     switch(dialogid) {
  314.         case VidaEColete: {
  315.             if(response) {
  316.                 switch(listitem) {
  317.                     case 0: {
  318.                             HealthOrArmour[playerid] = 1;
  319.                             AmountsOfHealthAndArmour(playerid); }
  320.  
  321.                     case 1: {
  322.                             HealthOrArmour[playerid] = 2;
  323.                             AmountsOfHealthAndArmour(playerid); }
  324.  
  325.                 }
  326.             }
  327.         }
  328.     }
  329.    
  330.     // ~~~~~~~~~~~~~ Dialog da porcentagem de vida ~~~~~~~~~~~~~
  331.     switch(dialogid) {
  332.         case AmountOfHealth: {
  333.             if(response) {
  334.                 new
  335.                     Float:Health,
  336.                     FinalPrice = strval(inputtext)*PriceOfHealthAndArmour,
  337.                     string[129];
  338.                
  339.                 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!");
  340.                 if(GetPlayerMoney(playerid) < FinalPrice) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você não tem dinheiro para comprar essa porcentagem de vida!");
  341.                 if(!IsNumeric(inputtext)) return AmountsOfHealthAndArmour(playerid);
  342.                 if(strval(inputtext) > 100) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} A porcentagem deverá ser entre 1 e 100!");
  343.                 GetPlayerHealth(playerid, Health);
  344.                 SetPlayerHealth(playerid, Health+strval(inputtext));
  345.                 GivePlayerMoney(playerid, -FinalPrice);
  346.                 format(string, sizeof(string), "{FF0000}[kWeapons]:{FFFFFF} Você encheu a sua vida com %i % por $%i!", strval(inputtext), FinalPrice);
  347.                 SendClientMessage(playerid, -1, string);
  348.                 return 1;
  349.             }
  350.         }
  351.     }
  352.    
  353.     // ~~~~~~~~~~~~~ Dialog da porcentagem de colete ~~~~~~~~~~~~~
  354.     switch(dialogid) {
  355.         case AmountOfArmour: {
  356.             if(response) {
  357.                 new
  358.                     Float:Armour,
  359.                     FinalPrice = strval(inputtext)*PriceOfHealthAndArmour,
  360.                     string[129];
  361.  
  362.                 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!");
  363.                 if(GetPlayerMoney(playerid) < FinalPrice) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você não tem dinheiro para comprar essa porcentagem de colete!");
  364.                 if(!IsNumeric(inputtext)) return AmountsOfHealthAndArmour(playerid);
  365.                 if(strval(inputtext) > 100) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} A porcentagem deverá ser entre 1 e 100!");
  366.                 GetPlayerArmour(playerid, Armour);
  367.                 SetPlayerArmour(playerid, Armour+strval(inputtext));
  368.                 GivePlayerMoney(playerid, -FinalPrice);
  369.                 format(string, sizeof(string), "{FF0000}[kWeapons]:{FFFFFF} Você encheu o seu colete com %i % por $%i!", strval(inputtext), FinalPrice);
  370.                 SendClientMessage(playerid, -1, string);
  371.                 return 1;
  372.             }
  373.         }
  374.     }
  375.  
  376.     // ~~~~~~~~~~~~~ Dialog da quantia de munição ~~~~~~~~~~~~~
  377.     switch(dialogid) {
  378.         case AmountOfAmmunition: {
  379.             if(response) {
  380.                 new
  381.                     FinalPrice = strval(inputtext)*PriceOfAmmo,
  382.                     string[129];
  383.  
  384.                 if(GetPlayerMoney(playerid) < FinalPrice) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você não tem dinheiro para comprar essa quantia de munição!");
  385.                 if(!IsNumeric(inputtext)) return AmountsOfAmmunition(playerid);
  386.                 GivePlayerWeapon(playerid, IDOfWeapon[playerid], strval(inputtext));
  387.                 GivePlayerMoney(playerid, -FinalPrice);
  388.                 format(string, sizeof(string), "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma arma com %i munições por $%i!", strval(inputtext), FinalPrice);
  389.                 SendClientMessage(playerid, -1, string);
  390.                 return 1;
  391.             }
  392.         }
  393.     }
  394.     return 0;
  395. }
  396.  
  397. // ~~~~~~~~~~~~~ Criamos nosso comando ~~~~~~~~~~~~~
  398. CMD:armas(playerid) {
  399. 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");
  400. return 1; }
  401.  
  402. // ~~~~~~~~~~~~~ Dialog da quantia de munição ~~~~~~~~~~~~~
  403. stock AmountsOfAmmunition(playerid) {
  404.     new string[129];
  405.     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);
  406.     ShowPlayerDialog(playerid, AmountOfAmmunition, DIALOG_STYLE_INPUT, "{FF0000}[kWeapons]:{FFFFFF} Quantidade de munições:", string, "Comprar", "Cancelar");
  407.     return 1;
  408. }
  409.  
  410. // ~~~~~~~~~~~~~ Dialog da porcentagem de vida e colete ~~~~~~~~~~~~~
  411. stock AmountsOfHealthAndArmour(playerid) {
  412.     new string[129];
  413.     switch(HealthOrArmour[playerid]) {
  414.         case 1: {
  415.                 format(string, sizeof(string), "Insira a porcentagem de vida que você deseja.\nCada porcentagem está custando: {FF0000}$%i\n\nUtilize somente números*", PriceOfHealthAndArmour);
  416.                 ShowPlayerDialog(playerid, AmountOfHealth, DIALOG_STYLE_INPUT, "{FF0000}[kWeapons]:{FFFFFF} Porcentagem de vida:", string, "Comprar", "Cancelar"); }
  417.  
  418.         case 2: {
  419.                 format(string, sizeof(string), "Insira a porcentagem de colete que você deseja.\nCada porcentagem está custando: {FF0000}$%i\n\nUtilize somente números*", PriceOfHealthAndArmour);
  420.                 ShowPlayerDialog(playerid, AmountOfArmour, DIALOG_STYLE_INPUT, "{FF0000}[kWeapons]:{FFFFFF} Porcentagem de colete:", string, "Comprar", "Cancelar"); }
  421.     }
  422.     return 1;
  423. }
  424.  
  425. // ~~~~~~~~~~~~~ Verificamos se é número ~~~~~~~~~~~~~
  426. stock IsNumeric(const string[]) {
  427.     for (new i = 0, j = strlen(string); i < j; i++)
  428.     {
  429.         if (string[i] > '9' || string[i] < '0') return 0;
  430.     }
  431.     return 1;
  432. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement