Advertisement
Guest User

JG-ZM voucher

a guest
Sep 2nd, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3. #include <zcmd>
  4. #include <dini>
  5.  
  6. #define COLOR_GREY 0x808080FF
  7.  
  8. #define SERVER_VOUCHER_FILE "vouchers/%d.ini"
  9.  
  10. new fstring[32], nstring[156];
  11.  
  12. public OnFilterScriptInit()
  13. {
  14. print("\n------------------------");
  15. print(" JG-ZM Fix Bug");
  16. print("------------------------\n");
  17. return 1;
  18. }
  19.  
  20. CMD:genvoucher(playerid, params[])
  21. {
  22. new code, pexp, score;
  23. code = random(9999999);
  24. if(sscanf(params, "dd", pexp, score))
  25. {
  26. return SendClientMessage(playerid, COLOR_GREY, "USAGE: /genvoucher <money> <score>");
  27. }
  28.  
  29. if(IsPlayerAdmin(playerid))
  30. {
  31. format(fstring, sizeof(fstring), SERVER_VOUCHER_FILE, code);
  32. if(dini_Exists(fstring)) return SendClientMessage(playerid, COLOR_GREY, "Voucher dibuat sudah ada");
  33. dini_Create(fstring);
  34. dini_IntSet(string, "pexp", pexp);
  35. dini_IntSet(string, "Score", score);
  36. format(nstring, sizeof(nstring), "SUCCES: Voucher '%d' berhasil membuat.ERROR: Voucher dibuat sudah ada.", code);
  37. SendClientMessage(playerid, COLOR_GREY, nstring);
  38. }
  39. return 1;
  40. }
  41.  
  42. CMD:addvoucher(playerid, params[])
  43. {
  44. new code, pexp, score;
  45. if(sscanf(params, "ddd", code, pexp, score))
  46. {
  47. return SendClientMessage(playerid, COLOR_GREY, "USAGE: /addvoucher <code> <money> <score>");
  48. }
  49.  
  50. if(IsPlayerAdmin(playerid))
  51. {
  52. format(fstring, sizeof(fstring), SERVER_VOUCHER_FILE, code);
  53. if(dini_Exists(fstring)) return SendClientMessage(playerid, COLOR_GREY, "ERROR: Voucher dibuat sudah ada.");
  54. dini_Create(fstring);
  55. dini_IntSet(string, "pexp", pexp);
  56. dini_IntSet(string, "Score", score);
  57. format(nstring, sizeof(nstring), "SUCCES: Voucher '%d' berhasil membuat.", code);
  58. SendClientMessage(playerid, COLOR_GREY, nstring);
  59. }
  60. return 1;
  61. }
  62.  
  63. CMD:savoucher(playerid, params[])
  64. {
  65. new pexp, score;
  66. if(sscanf(params, "dd", pexp, score))
  67. {
  68. return SendClientMessage(playerid, COLOR_GREY, "USAGE: /savoucher <money> <score>");
  69. }
  70.  
  71. if(IsPlayerAdmin(playerid))
  72. {
  73. for(new i; i <= 9999999; i++)
  74. {
  75. format(fstring, sizeof(fstring), SERVER_VOUCHER_FILE, i);
  76. if(!dini_Exists(fstring))
  77. {
  78. dini_Create(fstring);
  79. dini_IntSet(string, "pexp", pexp);
  80. dini_IntSet(string, "Score", score);
  81. format(nstring, sizeof(nstring), "SUCCES: Voucher '%d' Berhasil Di Buat.", i);
  82. SendClientMessage(playerid, COLOR_GREY, nstring);
  83. return 1;
  84. }
  85. }
  86. }
  87. return 1;
  88. }
  89.  
  90. CMD:voucher(playerid, params[])
  91. {
  92. new code;
  93. if(sscanf(params, "d", code))
  94. {
  95. SendClientMessage(playerid, COLOR_GREY, "USAGE: /voucher <code>");
  96. return 1;
  97. }
  98.  
  99. format(fstring, sizeof(fstring), SERVER_VOUCHER_FILE, code);
  100. if(dini_Exists(fstring))
  101. {
  102. GivePlayerXP(playerid, dini_Int(fstring, "pexp"));
  103. SetPlayerScore(playerid, GetPlayerScore(playerid)+dini_Int(fstring, "Score"));
  104.  
  105. format(nstring, sizeof(nstring), "SUCCES: Anda menerima $%d exp dan %d Score.", dini_Int(fstring, "vMoney"), dini_Int(fstring, "vScore"));
  106. SendClientMessage(playerid, COLOR_GREY, nstring);
  107. dini_Remove(fstring);
  108. } else {
  109. SendClientMessage(playerid, COLOR_GREY, "ERROR: Voucher ini tidak ada!");
  110. }
  111. return 1;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement