Advertisement
CheezPuff

[Free] Frag JB Wish v1.1 [By CheezPuff]

Jul 13th, 2024
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.43 KB | None | 0 0
  1. /* i dont care if you're not getting cash or anything else you should add yours native and more */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <fvault>
  6. #include <hamsandwich>
  7. #include <fun>
  8.  
  9. #define PLUGIN "Frag JailBreak Wish System"
  10. #define VERSION "1.0"
  11. #define AUTHOR "CheezPuff"
  12.  
  13. #define WISH_COOLDOWN 3600 // Cooldown in seconds (e.g. 1 hour)
  14. #define VAULT_NAME "wish_system"
  15. #define MAX_WISHES 2 // Maximum number of wishes allowed
  16. #define REWARD_LOOP_TIME 5.0 // Time in seconds for the reward loop
  17. #define REWARD_CHANGE_INTERVAL 0.2 // Time between reward changes in the loop
  18.  
  19. new const g_szRewards[][] = {
  20.     "1,000 Cash",
  21.     "5,000 Cash",
  22.     "10,000 Cash",
  23.     "25,000 Cash",
  24.     "45,000 Cash",
  25.     "100 Armor",
  26.     "Extra Wish",
  27.     "Nothing"
  28. };
  29.  
  30. new g_szAuthID[33][35];
  31. new g_szIP[33][16];
  32. new g_iPlayerCash[33]; // add your native of main cash
  33. new g_iCurrentReward[33];
  34. new g_iRewardLoopTask[33];
  35.  
  36. public plugin_init() {
  37.     register_plugin(PLUGIN, VERSION, AUTHOR);
  38.     register_clcmd("say /wish", "CmdWish");
  39.     register_clcmd("wish_reset", "CmdResetWishes", ADMIN_RCON);
  40. }
  41.  
  42. public client_authorized(id) {
  43.     get_user_authid(id, g_szAuthID[id], charsmax(g_szAuthID[]));
  44.     get_user_ip(id, g_szIP[id], charsmax(g_szIP[]), 1);
  45. }
  46.  
  47. public client_disconnected(id) {
  48.     if (task_exists(g_iRewardLoopTask[id])) {
  49.         remove_task(g_iRewardLoopTask[id]);
  50.     }
  51. }
  52.  
  53. public CmdWish(id) {
  54.     new wishes_used, last_wish_time;
  55.     if (CanMakeWish(id, wishes_used, last_wish_time)) {
  56.         StartWishProcess(id, wishes_used);
  57.     } else {
  58.         new remaining_time = WISH_COOLDOWN - (get_systime() - last_wish_time);
  59.         client_print(id, print_chat, "You must wait %d:%02d before making another wish.", remaining_time / 60, remaining_time % 60);
  60.     }
  61.     return PLUGIN_HANDLED;
  62. }
  63.  
  64. bool:CanMakeWish(id, &wishes_used, &last_wish_time) {
  65.     new data[64];
  66.     if (fvault_get_data(VAULT_NAME, g_szAuthID[id], data, charsmax(data)) || fvault_get_data(VAULT_NAME, g_szIP[id], data, charsmax(data))) {
  67.         new cash;
  68.         parse(data, wishes_used, last_wish_time, cash);
  69.        
  70.         if (wishes_used >= MAX_WISHES) {
  71.             if (get_systime() - last_wish_time >= WISH_COOLDOWN) {
  72.                 wishes_used = 0;
  73.                 return true;
  74.             }
  75.             return false;
  76.         }
  77.     } else {
  78.         wishes_used = 0;
  79.         last_wish_time = 0;
  80.     }
  81.     return true;
  82. }
  83.  
  84. StartWishProcess(id, wishes_used) {
  85.     g_iCurrentReward[id] = 0;
  86.     g_iRewardLoopTask[id] = set_task(REWARD_CHANGE_INTERVAL, "ChangeReward", id, .flags="b");
  87.     set_task(REWARD_LOOP_TIME, "FinishWish", id);
  88.     UpdateWishHUD(id, true, wishes_used);
  89. }
  90.  
  91. public ChangeReward(id) {
  92.     g_iCurrentReward[id] = random(sizeof(g_szRewards));
  93.     UpdateWishHUD(id, true, 0);
  94. }
  95.  
  96. public FinishWish(id) {
  97.     remove_task(g_iRewardLoopTask[id]);
  98.     new wishes_used, last_wish_time;
  99.     CanMakeWish(id, wishes_used, last_wish_time);
  100.     ApplyReward(id, g_iCurrentReward[id]);
  101.     wishes_used++;
  102.     SaveWishData(id, wishes_used);
  103.     UpdateWishHUD(id, false, wishes_used);
  104. }
  105.  
  106. ApplyReward(id, reward) {
  107.     new reward_value[32];
  108.     copy(reward_value, charsmax(reward_value), g_szRewards[reward]);
  109.    
  110.     if (equal(reward_value, "Nothing")) {
  111.         client_print(id, print_chat, "Better luck next time! You won nothing.");
  112.     } else if (equal(reward_value, "Extra Wish")) {
  113.         new wishes_used, last_wish_time;
  114.         CanMakeWish(id, wishes_used, last_wish_time);
  115.         wishes_used = max(0, wishes_used - 1);
  116.         SaveWishData(id, wishes_used);
  117.         client_print(id, print_chat, "You won an Extra Wish!");
  118.     } else {
  119.         new amount[16], type[16];
  120.         parse(reward_value, amount, charsmax(amount), type, charsmax(type));
  121.         new iAmount = str_to_num(amount);
  122.        
  123.         if (equal(type, "Cash")) {
  124.             g_iPlayerCash[id] += iAmount;
  125.             client_print(id, print_chat, "You won %d Cash!", iAmount);
  126.         } else if (equal(type, "Armor")) {
  127.             set_user_armor(id, get_user_armor(id) + iAmount);
  128.             client_print(id, print_chat, "You won %d Armor!", iAmount);
  129.         }
  130.     }
  131. }
  132.  
  133. SaveWishData(id, wishes_used) {
  134.     new data[64];
  135.     formatex(data, charsmax(data), "%d %d %d", wishes_used, get_systime(), g_iPlayerCash[id]);
  136.     fvault_set_data(VAULT_NAME, g_szAuthID[id], data);
  137.     fvault_set_data(VAULT_NAME, g_szIP[id], data);
  138. }
  139.  
  140. public CmdResetWishes(id) {
  141.     if (!(get_user_flags(id) & ADMIN_RCON)) {
  142.         return PLUGIN_HANDLED;
  143.     }
  144.    
  145.     fvault_clear(VAULT_NAME);
  146.     client_print(id, print_chat, "All wish timers have been reset.");
  147.     return PLUGIN_HANDLED;
  148. }
  149.  
  150. UpdateWishHUD(id, bool:in_loop, wishes_used) {
  151.     static hudMsg[512];
  152.     new remaining_wishes = MAX_WISHES - wishes_used;
  153.    
  154.     if (in_loop) {
  155.         formatex(hudMsg, charsmax(hudMsg), "Frag JailBreak - Wish^nGood Luck!^n^n>> %s <<^n^n%d Cash", g_szRewards[g_iCurrentReward[id]], g_iPlayerCash[id]);
  156.     } else {
  157.         formatex(hudMsg, charsmax(hudMsg), "Frag JailBreak - Wish^nGood Luck!^n^n>%d Wishes<^n^n%d Cash", remaining_wishes, g_iPlayerCash[id]);
  158.     }
  159.    
  160.     set_hudmessage(0, 255, 255, -1.0, 0.2, 0, 6.0, in_loop ? 0.2 : 5.0, 0.1, 0.2, -1);
  161.     show_hudmessage(id, hudMsg);
  162. }
  163.  
  164. /* i dont care if you're not getting cash or anything else you should add yours native and more */
  165. /* By CheezPuff (Ariel) | Discord: CheezPuff#7720*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement