#include #include /** Global Variables **/ new g_maxplayers, g_loteria_num, SayTxT new cvar_number_max, cvar_reward_ammos_for_win, cvar_bet_ammopacks, cvar_multiplier_ammos_for_win new g_loteria_usernum[33], g_used[33], g_loteria_userammo[33] new PlayersNum /** Plugin Init **/ public plugin_init() { // Register Plugin register_plugin("[ZP] Addon: Lottery", "2.3", "Kiske =D") // Cvars cvar_number_max = register_cvar("zp_lot_number_max", "200") cvar_reward_ammos_for_win = register_cvar("csgo_add_money", "200") cvar_bet_ammopacks = register_cvar("zp_lot_ammopacks_bet_on", "0") cvar_multiplier_ammos_for_win = register_cvar("zp_lot_multiplier_ammos_for_win", "3.0") // Events register_event("HLTV", "event_round_start", "a", "1=0", "2=0") // Client Commands register_clcmd("say /lot", "cmdlot") register_clcmd("say /lottery", "cmdlot") register_clcmd("say_team /lot", "cmdlot") register_clcmd("say_team /lottery", "cmdlot") register_clcmd("Type_Your_Number", "cmdEnter") register_clcmd("Type_Your_Ammo_Pack", "cmdEnter") register_clcmd("Type_Your_Number_For_Ammo_Pack", "cmdEnterNumForAmmo") // Message IDs SayTxT = get_user_msgid("SayText") // Get MaxPlayers g_maxplayers = get_maxplayers() // Language files register_dictionary("test.txt") } /** Bet Number **/ public cmdlot(id) { PlayersNum = GetAlive() if(PlayersNum >= 2) // Bug Fix! { if(g_used[id]) { chat_color(id, "%L", id, "ALREADY_BET") return PLUGIN_HANDLED } else { if(get_pcvar_num(cvar_bet_ammopacks)) client_cmd(id, "messagemode Wybierz ilosc EURO:") else client_cmd(id, "messagemode Wybierz liczbe:") } } else { chat_color(id, "%L", id, "LOTTERY_DISABLED") } return PLUGIN_HANDLED } /** Enter Number **/ public cmdEnter(id) { if(get_pcvar_num(cvar_bet_ammopacks)) { new say[32] read_args(say, charsmax(say)) remove_quotes(say), trim(say) new oNum = str_to_num(say) if(!oNum || oNum > csgo_get_money(id)) { chat_color(id, "%L", id, "INVALID_AMMOPACK") return PLUGIN_HANDLED } g_loteria_userammo[id] = oNum chat_color(id, "%L", id, "AMMOPACK_BET", oNum) client_cmd(id, "messagemode Type_Your_Number_For_Ammo_Pack") return PLUGIN_CONTINUE } else { new say[32] read_args(say, charsmax(say)) remove_quotes(say), trim(say) new iNum = str_to_num(say) if(!iNum || iNum >= get_pcvar_num(cvar_number_max)) { chat_color(id, "%L", id, "INVALID_NUMBER", get_pcvar_num(cvar_number_max)) return PLUGIN_HANDLED } g_loteria_usernum[id] = iNum g_loteria_num = random_num(1, get_pcvar_num(cvar_number_max)) chat_color(id, "%L", id, "NUMBER_BET", iNum) g_used[id] = true return PLUGIN_CONTINUE } return PLUGIN_CONTINUE } /** Enter Number For AmmoPack **/ public cmdEnterNumForAmmo(id) { new say[32] read_args(say, charsmax(say)) remove_quotes(say), trim(say) new aNum = str_to_num(say) if(!aNum || aNum >= get_pcvar_num(cvar_number_max)) { chat_color(id, "%L", id, "INVALID_NUMBER", get_pcvar_num(cvar_number_max)) return PLUGIN_HANDLED } g_loteria_usernum[id] = aNum csgo_set_money(id, csgo_get_money(id) - g_loteria_userammo[id]) g_loteria_num = random_num(1, get_pcvar_num(cvar_number_max)) chat_color(id, "%L", id, "NUMBER_BET", aNum) g_used[id] = true return PLUGIN_CONTINUE } /** Event Round Start **/ public event_round_start() { for(new id = 1; id <= g_maxplayers; id++) { PlayersNum = GetAlive() if(PlayersNum >= 2) { g_loteria_usernum[id] = 0 g_loteria_userammo[id] = 0 g_used[id] = false chat_color(id, "%L", id, "LOTTERY_RESET") chat_color(id, "%L", id, "LOTTERY_RESET2") } } } /** Round End **/ public zp_round_ended(winteam) { PlayersNum = GetAlive() if(PlayersNum >= 2) { for(new id = 1; id <= g_maxplayers; id++) { if(g_loteria_usernum[id] == g_loteria_num) { new name[32]; get_user_name(id, name, charsmax(name)) if(get_pcvar_num(cvar_bet_ammopacks)) { set_hudmessage(0, 255, 255, -1.0, 0.40, 1, 0.0, 5.0, 5.0, 1.0, -1) show_hudmessage(id, "%L", id, "WIN_PLAYER", g_loteria_num, name, g_loteria_userammo[id]*get_pcvar_num(cvar_multiplier_ammos_for_win)) csgo_set_money(id, csgo_get_money(id) + g_loteria_userammo[id]*get_pcvar_num(cvar_multiplier_ammos_for_win)) } else { set_hudmessage(0, 255, 255, -1.0, 0.40, 1, 0.0, 5.0, 5.0, 1.0, -1) show_hudmessage(id, "%L", id, "WIN_PLAYER", g_loteria_num, name, get_pcvar_num(cvar_reward_ammos_for_win)) csgo_set_money(id, csgo_get_money(id) + get_pcvar_num(cvar_reward_ammos_for_win)) } } else { set_hudmessage(0, 255, 255, -1.0, 0.40, 1, 0.0, 5.0, 5.0, 1.0, -1) show_hudmessage(id, "%L", id, "ALL_LOSERS") } } } } /** Stocks and Functions **/ // Color Chat! stock chat_color(const id, const input[], any:...) { new count = 1, players[32] static msg[191] vformat(msg, 190, input, 3) replace_all(msg, 190, "!g", "^4") // Green Color replace_all(msg, 190, "!y", "^1") // Default Color replace_all(msg, 190, "!team", "^3") // Team Color replace_all(msg, 190, "!team2", "^0") // Team2 Color if (id) players[0] = id; else get_players(players, count, "ch") { for (new i = 0; i < count; i++) { if (is_user_connected(players[i])) { message_begin(MSG_ONE_UNRELIABLE, SayTxT, _, players[i]) write_byte(players[i]); write_string(msg); message_end(); } } } } // GetAlive! GetAlive() { new Alive for (new id = 1; id <= g_maxplayers; id++) if (is_user_alive(id)) Alive++ return Alive }