Raised This Month: $51 Target: $400
 12% 

Give reward everyone when map starts


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 07-17-2020 , 21:27   Give reward everyone when map starts
Reply With Quote #1

Hi everyone, I use this zombie plague lottery plugin when a player writes /lottery can choose a number from 1 to 200 and when the round ends choose the winner and so on, the problem is that when a new map starts and they choose the teams and the round begins the winner hud says that the winning number is zero and all the names of the players come out and gives the ammo packs to everyone, I mean they are all winners, my question is how can I avoid that? ... Thanks in advance

PHP Code:
#include <amxmodx>
#include <zombieplague>

/** Global Variables **/
new g_maxplayersg_loteria_numSayTxT
new cvar_number_maxcvar_reward_ammos_for_wincvar_bet_ammopackscvar_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("zp_lot_ammopacks_for_win""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("zp_lott.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 Type_Your_Ammo_Pack")
            else
                
client_cmd(id"messagemode Type_Your_Number")
        }
    }
    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(saycharsmax(say))
        
remove_quotes(say), trim(say)
        
        new 
oNum str_to_num(say)
        if(!
oNum || oNum zp_get_user_ammo_packs(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(saycharsmax(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(1get_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(saycharsmax(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
    zp_set_user_ammo_packs
(idzp_get_user_ammo_packs(id) - g_loteria_userammo[id])
    
g_loteria_num random_num(1get_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 1id <= g_maxplayersid++)
    {
        
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 1id <= g_maxplayersid++)
        {
            if(
g_loteria_usernum[id] == g_loteria_num)
            {
                new 
name[32]; get_user_name(idnamecharsmax(name))
                
                if(
get_pcvar_num(cvar_bet_ammopacks))
                {
                    
set_hudmessage(0255255, -1.00.4010.05.05.01.0, -1)
                    
show_hudmessage(id"%L"id"WIN_PLAYER"g_loteria_numnameg_loteria_userammo[id]*get_pcvar_num(cvar_multiplier_ammos_for_win))
                    
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) + g_loteria_userammo[id]*get_pcvar_num(cvar_multiplier_ammos_for_win))
                }
                else
                {
                    
set_hudmessage(0255255, -1.00.4010.05.05.01.0, -1)
                    
show_hudmessage(id"%L"id"WIN_PLAYER"g_loteria_numnameget_pcvar_num(cvar_reward_ammos_for_win))
                    
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) + get_pcvar_num(cvar_reward_ammos_for_win))
                }
            }
            else
            {
                
set_hudmessage(0255255, -1.00.4010.05.05.01.0, -1)
                
show_hudmessage(id"%L"id"ALL_LOSERS")
            }
        }
    }
}

/** Stocks and Functions **/
// Color Chat!
stock chat_color(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color
    
replace_all(msg190"!team2""^0"// Team2 Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch")
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLESayTxT_players[i])
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }
}

// GetAlive!
GetAlive()
{
    new 
Alive
    
    
for (new id 1id <= g_maxplayersid++)
        if (
is_user_alive(id)) Alive++
    
    return 
Alive


Last edited by wicho; 07-17-2020 at 21:28.
wicho is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode