Advertisement
Guest User

Dynamic Dialogs: Weapons by Blunt

a guest
Oct 16th, 2014
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. #include <a_samp>
  2. #include <ZCMD>
  3. #define COLOR_WHITE 0xFFFFFFAA
  4. #define COLOR_GREY 0xAFAFAFAA
  5. #define COLOR_GREEN 0x33AA33AA
  6. #define COLOR_ORANGE 0xFFCC33AA
  7. #define DIALOG_WEAPON 7878
  8. #define DIALOG_EDITWEAPON 8787
  9. #define DIALOG_LISTITEM1 8000
  10. #define DIALOG_LISTITEM2 8001
  11. #define DIALOG_LISTITEM3 8002
  12. #define DIALOG_LISTITEM4 8003
  13. new
  14. ak47 = 500,
  15. deagle = 300,
  16. mp5 = 300,
  17. colt45 = 200
  18. ;
  19. stock IsNumeric(const string[])
  20. {
  21. for (new i = 0, j = strlen(string); i < j; i++)
  22. {
  23. if (string[i] > '9' || string[i] < '0') return 0;
  24. }
  25. return 1;
  26. }
  27. public OnFilterScriptInit()
  28. {
  29. print("Dynamic dialog: Weapon by Blunt");
  30. return 1;
  31. }
  32. public OnFilterScriptExit()
  33. {
  34. return 1;
  35. }
  36. main(){}
  37. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  38. {
  39. new list1[300],string[100],type = strval(inputtext);
  40. format(list1,300,"{FFFFFF}AK-47 {FFCC33}($%d) \n{FFFFFF}Desert Eagle {FFCC33}($%d) \n{FFFFFF}MP5 {FFCC33}($%d) \n{FFFFFF}Colt45 {FFCC33}($%d)",ak47,deagle,mp5,colt45);
  41. switch(dialogid)
  42. {
  43. case DIALOG_WEAPON:
  44. {
  45. if(!response) return 1;
  46. switch(listitem)
  47. {
  48. case 0:
  49. {
  50. if(GetPlayerMoney(playerid) <= ak47) return SendClientMessage(playerid,COLOR_GREY,"Insufficient funds for this item");
  51. GivePlayerWeapon(playerid,30,500);
  52. GivePlayerMoney(playerid,-ak47);
  53. }
  54. case 1:
  55. {
  56. if(GetPlayerMoney(playerid) <= deagle) return SendClientMessage(playerid,COLOR_GREY,"Insufficient funds for this item");
  57. GivePlayerWeapon(playerid,24,500);
  58. GivePlayerMoney(playerid,-deagle);
  59. }
  60. case 2:
  61. {
  62. if(GetPlayerMoney(playerid) <= mp5) return SendClientMessage(playerid,COLOR_GREY,"Insufficient funds for this item");
  63. GivePlayerWeapon(playerid,29,500);
  64. GivePlayerMoney(playerid,-mp5);
  65. }
  66. case 3:
  67. {
  68. if(GetPlayerMoney(playerid) <= colt45) return SendClientMessage(playerid,COLOR_GREY,"Insufficient funds for this item");
  69. GivePlayerWeapon(playerid,22,500);
  70. GivePlayerMoney(playerid,-colt45);
  71. }
  72. }
  73. }
  74. case DIALOG_EDITWEAPON:
  75. {
  76. if(!response) return 1;
  77. switch(listitem)
  78. {
  79. case 0:{ShowPlayerDialog(playerid,DIALOG_LISTITEM1,DIALOG_STYLE_INPUT,"WEAPON PRICE EDITOR","Type in a price that you want to set for the {33AA33}AK-47","Submit","Back");}
  80. case 1:{ShowPlayerDialog(playerid,DIALOG_LISTITEM2,DIALOG_STYLE_INPUT,"WEAPON PRICE EDITOR","Type in a price that you want to set for the {33AA33}Desert Eagle","Submit","Back");}
  81. case 2:{ShowPlayerDialog(playerid,DIALOG_LISTITEM3,DIALOG_STYLE_INPUT,"WEAPON PRICE EDITOR","Type in a price that you want to set for the {33AA33}MP5","Submit","Back");}
  82. case 3:{ShowPlayerDialog(playerid,DIALOG_LISTITEM4,DIALOG_STYLE_INPUT,"WEAPON PRICE EDITOR","Type in a price that you want to set for the {33AA33}Colt45","Submit","Back");}
  83. }
  84. }
  85. case DIALOG_LISTITEM1:
  86. {
  87. if(!response) return ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
  88. ak47 = type;
  89. format(string,sizeof(string),"You have updated the price of the AK-47 to $%d",type);
  90. SendClientMessage(playerid,COLOR_GREEN,string);
  91. }
  92. case DIALOG_LISTITEM2:
  93. {
  94. if(!response) return ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
  95. deagle = type;
  96. format(string,sizeof(string),"You have updated the price of the Desert Eagle to $%d",type);
  97. SendClientMessage(playerid,COLOR_GREEN,string);
  98. }
  99. case DIALOG_LISTITEM3:
  100. {
  101. if(!response) return ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
  102. mp5 = type;
  103. format(string,sizeof(string),"You have updated the price of the MP5 to $%d",type);
  104. SendClientMessage(playerid,COLOR_GREEN,string);
  105. }
  106. case DIALOG_LISTITEM4:
  107. {
  108. if(!response) return ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
  109. colt45 = type;
  110. format(string,sizeof(string),"You have updated the price of the Colt45 to $%d",type);
  111. SendClientMessage(playerid,COLOR_GREEN,string);
  112. }
  113. }
  114. return 1;
  115. }
  116. COMMAND:weapons(playerid)
  117. {
  118. if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GREY, "You must be on foot to use this command.");
  119. new list1[300];
  120. format(list1,300,"{FFFFFF}AK-47 {FFCC33}($%d) \n{FFFFFF}Desert Eagle {FFCC33}($%d) \n{FFFFFF}MP5 {FFCC33}($%d) \n{FFFFFF}Colt45 {FFCC33}($%d)",ak47,deagle,mp5,colt45);
  121. ShowPlayerDialog(playerid,DIALOG_WEAPON,DIALOG_STYLE_LIST,"WEAPONS",list1,"Select","Cancel");
  122. return 1;
  123. }
  124. COMMAND:editweapons(playerid)
  125. {
  126. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Command for admin-use only.");
  127. SendClientMessage(playerid,COLOR_GREEN,"To edit a price, double click/select an item on the list.");
  128. new list1[300];
  129. format(list1,300,"{FFFFFF}AK-47 {FFCC33}($%d) \n{FFFFFF}Desert Eagle {FFCC33}($%d) \n{FFFFFF}MP5 {FFCC33}($%d) \n{FFFFFF}Colt45 {FFCC33}($%d)",ak47,deagle,mp5,colt45);
  130. ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
  131. return 1;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement