Raised This Month: $ Target: $400
 0% 

[Help] Add limit each player 1 item per map


Post New Thread Reply   
 
Thread Tools Display Modes
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-29-2014 , 12:02   Re: [Help] Add limit each player 1 item per map
Reply With Quote #71

Then, just use this code:
PHP Code:
#include <amxmodx>
#include <zombieplague>

#define PLUGIN "[ZP] "
#define VERSION "2.1"
#define AUTHOR ""

#define ZP_TEAM_HUMAN (1<<1)

new const g_item_nem_name[] = "Buy Nemesis"
new const g_item_sur_name[] = "Buy Survivor"
new const g_costnemesis 140
new const g_costsurvivor 200

new g_maxplayersg_msgSayText
new g_nemesisg_survivor
new g_buyableg_endroundRoundCountcvar_delay

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_logevent("logevent_round_end"2"1=Round_End")
    
    
g_nemesis zp_register_extra_item(g_item_nem_nameg_costnemesisZP_TEAM_HUMAN)
    
g_survivor zp_register_extra_item(g_item_sur_nameg_costsurvivorZP_TEAM_HUMAN)
    
    
cvar_delay register_cvar("zp_buy_classes_delay""3"
    
    
g_maxplayers get_maxplayers()
    
g_msgSayText get_user_msgid("SayText")
}

public 
zp_extra_item_selected(playeritemid)
{
    if(
itemid == g_nemesis)
    {
        if (!
g_buyable)
        {
            if (
RoundCount == get_pcvar_num(cvar_delay))
            {
                
zp_colored_print(player"^x04[ZP]^x01 You have to wait^x04 one^x01 more round before you can buy this item")
            }
            else
            {
                
zp_colored_print(player"^x04[ZP]^x01 You have to wait^x04 %d^x01 rounds until you can buy this item"get_pcvar_num(cvar_delay) - RoundCount 1)
            }
            return 
ZP_PLUGIN_HANDLED;
        }
        
        if (
zp_has_round_started() == || g_endround)
        {
            
zp_colored_print(player"^x04[ZP]^x01 This item can only be bought before the round mode starts")
            return 
ZP_PLUGIN_HANDLED;
        }  
        
        
zp_make_user_nemesis(player)
        
        new 
name[32]
        
get_user_name(playernamecharsmax(name))
        
zp_colored_print(0"^x04[ReverseZM]^x03 %s^x01 has bought^x04 Nemesis"name
        
        
g_buyable false
    
}
    else if(
itemid == g_survivor)
    {
        if (!
g_buyable)
        {
            if (
RoundCount == get_pcvar_num(cvar_delay))
            {
                
zp_colored_print(player"^x04[ZP]^x01 You have to wait^x04 one^x01 more round before you can buy this item")
            }
            else
            {
                
zp_colored_print(player"^x04[ZP]^x01 You have to wait^x04 %d^x01 rounds until you can buy this item"get_pcvar_num(cvar_delay) - RoundCount 1)
            }
            return 
ZP_PLUGIN_HANDLED;
        }
        
        if (
zp_has_round_started() == || g_endround)
        {
            
zp_colored_print(player"^x04[ZP]^x01 This item can only be bought before the round mode starts")
            return 
ZP_PLUGIN_HANDLED;
        }
        
        
zp_make_user_survivor(player)
        
        new 
name[32]
        
get_user_name(playernamecharsmax(name))
        
zp_colored_print(0"^x04[ReverseZM]^x03 %s^x01 has bought^x04 Survivor"name)  
        
        
g_buyable false
        
    
}   
    return 
PLUGIN_CONTINUE
}

public 
event_round_start()
{
    
g_endround false
    
    
if (RoundCount >= get_pcvar_num(cvar_delay))
    {
        
g_buyable true
        RoundCount 
0
    
}
}

public 
logevent_round_end()
{
    
g_endround true
    
    RoundCount
++
}

zp_colored_print(target, const message[], any:...)
{
    static 
buffer[512], iargscount
    argscount 
numargs()

    
// Send to everyone
    
if (!target)
    {
        static 
player
        
for (player 1player <= g_maxplayersplayer++)
        {
            
// Not connected
            
if (!is_user_connected(player))
                continue;
            
            
// Remember changed arguments
            
static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
            
changedcount 0
            
            
// Replace LANG_PLAYER with player id
            
for (2argscounti++)
            {
                if (
getarg(i) == LANG_PLAYER)
                {
                    
setarg(i0player)
                    
changed[changedcount] = i
                    changedcount
++
                }
            }
            
            
// Format message for player
            
vformat(buffercharsmax(buffer), message3)
            
            
// Send it
            
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_player)
            
write_byte(player)
            
write_string(buffer)
            
message_end()
            
            
// Replace back player id's with LANG_PLAYER
            
for (0changedcounti++)
                
setarg(changed[i], 0LANG_PLAYER)
        }
    }
    
// Send to specific target
    
else
    {
        
// Format message for player
        
vformat(buffercharsmax(buffer), message3)
        
        
// Send it
        
message_begin(MSG_ONEg_msgSayText_target)
        
write_byte(target)
        
write_string(buffer)
        
message_end()
    }

No need to add code in public zp_round_started(mode, id). So, just remove it.

Last edited by zmd94; 12-30-2014 at 01:49.
zmd94 is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-29-2014 , 14:17   Re: [Help] Add limit each player 1 item per map
Reply With Quote #72

your code is no use for me... your code forbids buying mode if the round is nemesis .. next round you can still buy mode...

what i need is ... if current round is nemesis || survivor, round count 2 for item to be buyable
Depresie is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-30-2014 , 01:49   Re: [Help] Add limit each player 1 item per map
Reply With Quote #73

I have updated the code.
zmd94 is offline
alaska4911
Junior Member
Join Date: Apr 2015
Location: USA
Old 12-17-2016 , 22:43   Re: [Help] Add limit each player 1 item per map
Reply With Quote #74

guys i want to renew this post but now i want same code for admin menu (nemesis, assasin, survivor, sniper) so they can turn themselves on map just 1 times.
alaska4911 is offline
PS7
New Member
Join Date: Dec 2016
Old 12-18-2016 , 06:57   Re: [Help] Add limit each player 1 item per map
Reply With Quote #75

how i can Add limit to any itme i want??? ZP 5.0 Show me, thank you guys.
PS7 is offline
Reply


Thread Tools
Display Modes

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 14:15.


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