Advertisement
hush

[FilterScript] kWeapons

Feb 26th, 2013
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.75 KB | None | 0 0
  1. /*
  2.  * kWeapons feito 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.  
  9. // ~~~~~~~~~~~~~ Dialogs ~~~~~~~~~~~~~
  10. #define ChoiceOfWeapons     1420
  11. #define AmountOfAmmunition  1421
  12.  
  13. #define ArmasBrancas        1422
  14. #define Pistolas            1423
  15. #define Escopetas           1424
  16. #define SubMetralhadoras    1425
  17. #define FuzisDeAssalto      1426
  18. #define Rifles              1427
  19. #define Explosivos          1428
  20. #define Presentes           1429
  21. #define Outros              1430
  22.  
  23. #define PriceOfAmmo  (50) // Defina aqui o preço de uma munição.
  24.  
  25. new IDOfWeapon[MAX_PLAYERS]; // Armazenamos o ID das armas. Idealização por: histire.
  26.  
  27. // ~~~~~~~~~~~~~ Public's ~~~~~~~~~~~~~
  28. public OnFilterScriptInit()
  29. {
  30.     print("\n============== [ kWeapons ] ================");
  31.     print(" Sistema de armas carregado com sucesso! ");
  32.     print("============================================\n");
  33.     return 1;
  34. }
  35.  
  36. public OnFilterScriptExit()
  37. {
  38.     print("\n============== [ kWeapons ] ================");
  39.     print(" Sistema de armas descarregado com sucesso! ");
  40.     print("============================================\n");
  41.     return 1;
  42. }
  43.  
  44. // ~~~~~~~~~~~~~ Criamos nosso comando ~~~~~~~~~~~~~
  45. public OnPlayerCommandText(playerid, cmdtext[])
  46. {
  47.     if(!strcmp(cmdtext, "/armas", true)) {
  48.         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", "Selecionar", "Cancelar");
  49.         return 1; }
  50.     return 0;
  51. }
  52.  
  53. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  54. {
  55.     // ~~~~~~~~~~~~~ Dialog de escolha da categoria ~~~~~~~~~~~~~
  56.     if(dialogid == ChoiceOfWeapons) {
  57.         if(response) {
  58.             switch(listitem) {
  59.                 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");
  60.                 case 1: ShowPlayerDialog(playerid, Pistolas, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Pistolas:", "9mm\n9mm com silenciador\nDesert Eagle", "Selecionar", "Cancelar");
  61.                 case 2: ShowPlayerDialog(playerid, Escopetas, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Escopetas:", "Escopeta\nEscopeta de cano cerrado\nSPAS 12", "Selecionar", "Cancelar");
  62.                 case 3: ShowPlayerDialog(playerid, SubMetralhadoras, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Sub-Metralhadoras", "Micro Uzi\nSMG\nTec-9", "Selecionar", "Cancelar");
  63.                 case 4: ShowPlayerDialog(playerid, FuzisDeAssalto, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Fuzis de Assalto:", "AK-47\nM4", "Selecionar", "Cancelar");
  64.                 case 5: ShowPlayerDialog(playerid, Rifles, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Rifles", "Rifle\nRifle de francoatirador", "Selecionar", "Cancelar");
  65.                 case 6: ShowPlayerDialog(playerid, Explosivos, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Explosivos:", "Granada\nCarga Explosiva\nGranada de Gás", "Selecionar", "Cancelar");
  66.                 case 7: ShowPlayerDialog(playerid, Presentes, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Presentes:", "Bengala\nFlores\nVibrador\nVibrador 2\nVibrador Duplo\nVibrador Prata", "Selecionar", "Cancelar");
  67.                 case 8: ShowPlayerDialog(playerid, Outros, DIALOG_STYLE_LIST, "{FF0000}[kWeapons]:{FFFFFF} Outros:", "Câmera\nExtintor\nSpray de graffiti\nParaquedas", "Selecionar", "Cancelar");
  68.             }
  69.         }
  70.     }
  71.    
  72.     // ~~~~~~~~~~~~~ Dialog de armas brancas ~~~~~~~~~~~~~
  73.     if(dialogid == ArmasBrancas) {
  74.         if(response) {
  75.             switch(listitem) {
  76.                 case 0: {
  77.                         GivePlayerWeapon(playerid, 1, 1);
  78.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Soco Inglês por: $100!");
  79.                         GivePlayerMoney(playerid, -100); }
  80.  
  81.                 case 1: {
  82.                         GivePlayerWeapon(playerid, 5, 1);
  83.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Baseball por: $100!");
  84.                         GivePlayerMoney(playerid, -100); }
  85.  
  86.                 case 2: {
  87.                         GivePlayerWeapon(playerid, 9, 1);
  88.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Serra Elétrica por: $500!");
  89.                         GivePlayerMoney(playerid, -500); }
  90.  
  91.                 case 3: {
  92.                         GivePlayerWeapon(playerid, 2, 1);
  93.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Gold por: $100!");
  94.                         GivePlayerMoney(playerid, -100); }
  95.  
  96.                 case 4: {
  97.                         GivePlayerWeapon(playerid, 8, 1);
  98.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Katana por: $100!");
  99.                         GivePlayerMoney(playerid, -100); }
  100.  
  101.                 case 5: {
  102.                         GivePlayerWeapon(playerid, 4, 1);
  103.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Faca por: $50!");
  104.                         GivePlayerMoney(playerid, -50); }
  105.  
  106.                 case 6: {
  107.                         GivePlayerWeapon(playerid, 3, 1);
  108.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Cacete por: $100!");
  109.                         GivePlayerMoney(playerid, -100); }
  110.  
  111.                 case 7: {
  112.                         GivePlayerWeapon(playerid, 9, 1);
  113.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Taco de Brilhar(Taco de Snooker/Sinuca) por: $30!");
  114.                         GivePlayerMoney(playerid, -30); }
  115.  
  116.                 case 8: {
  117.                         GivePlayerWeapon(playerid, 9, 1);
  118.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Pá por: $20!");
  119.                         GivePlayerMoney(playerid, -20); }
  120.             }
  121.         }
  122.     }
  123.  
  124.     // ~~~~~~~~~~~~~ Dialog das pistolas ~~~~~~~~~~~~~
  125.     if(dialogid == Pistolas) {
  126.         if(response) {
  127.             switch(listitem) {
  128.                 case 0: {
  129.                         IDOfWeapon[playerid] = 22;
  130.                         AmountsOfAmmunition(playerid); }
  131.  
  132.                 case 1: {
  133.                         IDOfWeapon[playerid] = 23;
  134.                         AmountsOfAmmunition(playerid); }
  135.  
  136.                 case 2: {
  137.                         IDOfWeapon[playerid] = 24;
  138.                         AmountsOfAmmunition(playerid); }
  139.             }
  140.         }
  141.     }
  142.    
  143.     // ~~~~~~~~~~~~~ Dialog das Escopetas ~~~~~~~~~~~~~
  144.     if(dialogid == Escopetas) {
  145.         if(response) {
  146.             switch(listitem) {
  147.                 case 0: {
  148.                         IDOfWeapon[playerid] = 25;
  149.                         AmountsOfAmmunition(playerid); }
  150.  
  151.                 case 1: {
  152.                         IDOfWeapon[playerid] = 26;
  153.                         AmountsOfAmmunition(playerid); }
  154.  
  155.                 case 2: {
  156.                         IDOfWeapon[playerid] = 27;
  157.                         AmountsOfAmmunition(playerid); }
  158.             }
  159.         }
  160.     }
  161.  
  162.     // ~~~~~~~~~~~~~ Dialog das SubMetralhadoras ~~~~~~~~~~~~~
  163.     if(dialogid == SubMetralhadoras) {
  164.         if(response) {
  165.             switch(listitem) {
  166.                 case 0: {
  167.                         IDOfWeapon[playerid] = 28;
  168.                         AmountsOfAmmunition(playerid); }
  169.  
  170.                 case 1: {
  171.                         IDOfWeapon[playerid] = 29;
  172.                         AmountsOfAmmunition(playerid); }
  173.  
  174.                 case 2: {
  175.                         IDOfWeapon[playerid] = 32;
  176.                         AmountsOfAmmunition(playerid); }
  177.             }
  178.         }
  179.     }
  180.  
  181.     // ~~~~~~~~~~~~~ Dialog do Fuzis de Assalto ~~~~~~~~~~~~~
  182.     if(dialogid == FuzisDeAssalto) {
  183.         if(response) {
  184.             switch(listitem) {
  185.                 case 0: {
  186.                         IDOfWeapon[playerid] = 30;
  187.                         AmountsOfAmmunition(playerid); }
  188.  
  189.                 case 1: {
  190.                         IDOfWeapon[playerid] = 31;
  191.                         AmountsOfAmmunition(playerid); }
  192.             }
  193.         }
  194.     }
  195.  
  196.     // ~~~~~~~~~~~~~ Dialog dos Rifles ~~~~~~~~~~~~~
  197.     if(dialogid == Rifles) {
  198.         if(response) {
  199.             switch(listitem) {
  200.                 case 0: {
  201.                         IDOfWeapon[playerid] = 33;
  202.                         AmountsOfAmmunition(playerid); }
  203.  
  204.                 case 1: {
  205.                         IDOfWeapon[playerid] = 34;
  206.                         AmountsOfAmmunition(playerid); }
  207.             }
  208.         }
  209.     }
  210.  
  211.     // ~~~~~~~~~~~~~ Dialog dos Explosivos ~~~~~~~~~~~~~
  212.     if(dialogid == Explosivos) {
  213.         if(response) {
  214.             switch(listitem) {
  215.                 case 0: {
  216.                         IDOfWeapon[playerid] = 16;
  217.                         AmountsOfAmmunition(playerid); }
  218.  
  219.                 case 1: {
  220.                         IDOfWeapon[playerid] = 39;
  221.                         AmountsOfAmmunition(playerid); }
  222.  
  223.                 case 2: {
  224.                         IDOfWeapon[playerid] = 17;
  225.                         AmountsOfAmmunition(playerid); }
  226.             }
  227.         }
  228.     }
  229.  
  230.     // ~~~~~~~~~~~~~ Dialog dos Presentes~~~~~~~~~~~~~
  231.     if(dialogid == Presentes) {
  232.         if(response) {
  233.             switch(listitem) {
  234.                 case 0: {
  235.                        
  236.                         GivePlayerWeapon(playerid, 15, 1);
  237.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma Bengala por: $50!");
  238.                         GivePlayerMoney(playerid, -50); }
  239.  
  240.                 case 1: {
  241.                         GivePlayerWeapon(playerid, 14, 1);
  242.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Buquer de Flor por: $20!");
  243.                         GivePlayerMoney(playerid, -20); }
  244.  
  245.                 case 2: {
  246.                         GivePlayerWeapon(playerid, 12, 1);
  247.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $150!");
  248.                         GivePlayerMoney(playerid, -150); }
  249.  
  250.                 case 3: {
  251.                         IDOfWeapon[playerid] = 11;
  252.                         GivePlayerWeapon(playerid, 11, 1);
  253.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $150!");
  254.                         GivePlayerMoney(playerid, -150); }
  255.  
  256.                 case 4: {
  257.                         IDOfWeapon[playerid] = 10;
  258.                         GivePlayerWeapon(playerid, 4, 1);
  259.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador por: $200!");
  260.                         GivePlayerMoney(playerid, -200); }
  261.  
  262.                 case 5: {
  263.                         GivePlayerWeapon(playerid, 13, 1);
  264.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um Vibrador Prata por: $250!");
  265.                         GivePlayerMoney(playerid, -250); }
  266.             }
  267.         }
  268.     }
  269.  
  270.     // ~~~~~~~~~~~~~ Dialog de Outras Armas/Utilitarios ~~~~~~~~~~~~~
  271.     if(dialogid == Outros) {
  272.         if(response) {
  273.             switch(listitem) {
  274.                 case 0: {
  275.                         IDOfWeapon[playerid] = 43;
  276.                         AmountsOfAmmunition(playerid); }
  277.  
  278.                 case 1: {
  279.                         IDOfWeapon[playerid] = 42;
  280.                         AmountsOfAmmunition(playerid); }
  281.  
  282.                 case 2: {
  283.                         IDOfWeapon[playerid] = 41;
  284.                         AmountsOfAmmunition(playerid); }
  285.  
  286.                 case 3: {
  287.                         GivePlayerWeapon(playerid, 46, 1);
  288.                         SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você comprou um paraquedas por: $500!");
  289.                         GivePlayerMoney(playerid, -500); }
  290.             }
  291.         }
  292.     }
  293.  
  294.     // ~~~~~~~~~~~~~ Dialog da quantia de munição ~~~~~~~~~~~~~
  295.     if(dialogid == AmountOfAmmunition) {
  296.         if(response) {
  297.             new
  298.                 FinalPrice = strval(inputtext)*PriceOfAmmo,
  299.                 string[129];
  300.  
  301.             if(GetPlayerMoney(playerid) < FinalPrice) return SendClientMessage(playerid, -1, "{FF0000}[kWeapons]:{FFFFFF} Você não tem dinheiro para comprar essa quantia de munição!");
  302.             if(!IsNumeric(inputtext)) return AmountsOfAmmunition(playerid);
  303.             GivePlayerWeapon(playerid, IDOfWeapon[playerid], strval(inputtext));
  304.             GivePlayerMoney(playerid, -FinalPrice);
  305.             format(string, sizeof(string), "{FF0000}[kWeapons]:{FFFFFF} Você comprou uma arma com %i munições por $%i!", strval(inputtext), FinalPrice);
  306.             SendClientMessage(playerid, -1, string);
  307.             return 1;
  308.         }
  309.     }
  310.     return 0;
  311. }
  312.  
  313. // ~~~~~~~~~~~~~ Dialog da quantia de munição ~~~~~~~~~~~~~
  314. stock AmountsOfAmmunition(playerid)
  315. {
  316.     new string[120];
  317.     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);
  318.     ShowPlayerDialog(playerid, AmountOfAmmunition, DIALOG_STYLE_INPUT, "{FF0000}[kWeapons]:{FFFFFF} Quantidade de munições:", string, "Comprar", "Cancelar");
  319.     return 1;
  320. }
  321.  
  322. // ~~~~~~~~~~~~~ Verificamos se é número ~~~~~~~~~~~~~
  323. stock IsNumeric(const string[])
  324. {
  325.     for (new i = 0, j = strlen(string); i < j; i++)
  326.     {
  327.         if (string[i] > '9' || string[i] < '0') return 0;
  328.     }
  329.     return 1;
  330. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement