Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* i dont care if you're not getting cash or anything else you should add yours native and more */
- #include <amxmodx>
- #include <amxmisc>
- #include <fvault>
- #include <hamsandwich>
- #include <fun>
- #define PLUGIN "Frag JailBreak Wish System"
- #define VERSION "1.0"
- #define AUTHOR "CheezPuff"
- #define WISH_COOLDOWN 3600 // Cooldown in seconds (e.g. 1 hour)
- #define VAULT_NAME "wish_system"
- #define MAX_WISHES 2 // Maximum number of wishes allowed
- #define REWARD_LOOP_TIME 5.0 // Time in seconds for the reward loop
- #define REWARD_CHANGE_INTERVAL 0.2 // Time between reward changes in the loop
- new const g_szRewards[][] = {
- "1,000 Cash",
- "5,000 Cash",
- "10,000 Cash",
- "25,000 Cash",
- "45,000 Cash",
- "100 Armor",
- "Extra Wish",
- "Nothing"
- };
- new g_szAuthID[33][35];
- new g_szIP[33][16];
- new g_iPlayerCash[33]; // add your native of main cash
- new g_iCurrentReward[33];
- new g_iRewardLoopTask[33];
- public plugin_init() {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- register_clcmd("say /wish", "CmdWish");
- register_clcmd("wish_reset", "CmdResetWishes", ADMIN_RCON);
- }
- public client_authorized(id) {
- get_user_authid(id, g_szAuthID[id], charsmax(g_szAuthID[]));
- get_user_ip(id, g_szIP[id], charsmax(g_szIP[]), 1);
- }
- public client_disconnected(id) {
- if (task_exists(g_iRewardLoopTask[id])) {
- remove_task(g_iRewardLoopTask[id]);
- }
- }
- public CmdWish(id) {
- new wishes_used, last_wish_time;
- if (CanMakeWish(id, wishes_used, last_wish_time)) {
- StartWishProcess(id, wishes_used);
- } else {
- new remaining_time = WISH_COOLDOWN - (get_systime() - last_wish_time);
- client_print(id, print_chat, "You must wait %d:%02d before making another wish.", remaining_time / 60, remaining_time % 60);
- }
- return PLUGIN_HANDLED;
- }
- bool:CanMakeWish(id, &wishes_used, &last_wish_time) {
- new data[64];
- if (fvault_get_data(VAULT_NAME, g_szAuthID[id], data, charsmax(data)) || fvault_get_data(VAULT_NAME, g_szIP[id], data, charsmax(data))) {
- new cash;
- parse(data, wishes_used, last_wish_time, cash);
- if (wishes_used >= MAX_WISHES) {
- if (get_systime() - last_wish_time >= WISH_COOLDOWN) {
- wishes_used = 0;
- return true;
- }
- return false;
- }
- } else {
- wishes_used = 0;
- last_wish_time = 0;
- }
- return true;
- }
- StartWishProcess(id, wishes_used) {
- g_iCurrentReward[id] = 0;
- g_iRewardLoopTask[id] = set_task(REWARD_CHANGE_INTERVAL, "ChangeReward", id, .flags="b");
- set_task(REWARD_LOOP_TIME, "FinishWish", id);
- UpdateWishHUD(id, true, wishes_used);
- }
- public ChangeReward(id) {
- g_iCurrentReward[id] = random(sizeof(g_szRewards));
- UpdateWishHUD(id, true, 0);
- }
- public FinishWish(id) {
- remove_task(g_iRewardLoopTask[id]);
- new wishes_used, last_wish_time;
- CanMakeWish(id, wishes_used, last_wish_time);
- ApplyReward(id, g_iCurrentReward[id]);
- wishes_used++;
- SaveWishData(id, wishes_used);
- UpdateWishHUD(id, false, wishes_used);
- }
- ApplyReward(id, reward) {
- new reward_value[32];
- copy(reward_value, charsmax(reward_value), g_szRewards[reward]);
- if (equal(reward_value, "Nothing")) {
- client_print(id, print_chat, "Better luck next time! You won nothing.");
- } else if (equal(reward_value, "Extra Wish")) {
- new wishes_used, last_wish_time;
- CanMakeWish(id, wishes_used, last_wish_time);
- wishes_used = max(0, wishes_used - 1);
- SaveWishData(id, wishes_used);
- client_print(id, print_chat, "You won an Extra Wish!");
- } else {
- new amount[16], type[16];
- parse(reward_value, amount, charsmax(amount), type, charsmax(type));
- new iAmount = str_to_num(amount);
- if (equal(type, "Cash")) {
- g_iPlayerCash[id] += iAmount;
- client_print(id, print_chat, "You won %d Cash!", iAmount);
- } else if (equal(type, "Armor")) {
- set_user_armor(id, get_user_armor(id) + iAmount);
- client_print(id, print_chat, "You won %d Armor!", iAmount);
- }
- }
- }
- SaveWishData(id, wishes_used) {
- new data[64];
- formatex(data, charsmax(data), "%d %d %d", wishes_used, get_systime(), g_iPlayerCash[id]);
- fvault_set_data(VAULT_NAME, g_szAuthID[id], data);
- fvault_set_data(VAULT_NAME, g_szIP[id], data);
- }
- public CmdResetWishes(id) {
- if (!(get_user_flags(id) & ADMIN_RCON)) {
- return PLUGIN_HANDLED;
- }
- fvault_clear(VAULT_NAME);
- client_print(id, print_chat, "All wish timers have been reset.");
- return PLUGIN_HANDLED;
- }
- UpdateWishHUD(id, bool:in_loop, wishes_used) {
- static hudMsg[512];
- new remaining_wishes = MAX_WISHES - wishes_used;
- if (in_loop) {
- formatex(hudMsg, charsmax(hudMsg), "Frag JailBreak - Wish^nGood Luck!^n^n>> %s <<^n^n%d Cash", g_szRewards[g_iCurrentReward[id]], g_iPlayerCash[id]);
- } else {
- formatex(hudMsg, charsmax(hudMsg), "Frag JailBreak - Wish^nGood Luck!^n^n>%d Wishes<^n^n%d Cash", remaining_wishes, g_iPlayerCash[id]);
- }
- set_hudmessage(0, 255, 255, -1.0, 0.2, 0, 6.0, in_loop ? 0.2 : 5.0, 0.1, 0.2, -1);
- show_hudmessage(id, hudMsg);
- }
- /* i dont care if you're not getting cash or anything else you should add yours native and more */
- /* By CheezPuff (Ariel) | Discord: CheezPuff#7720*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement