Raised This Month: $ Target: $400
 0% 

[Help] Add limit each player 1 item per map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 10-07-2014 , 09:30   [Help] Add limit each player 1 item per map
Reply With Quote #1

how to add limit, 1 item per player in 1 map, ex: if 1 player Buy Nemesis, hee cant buy again nemesis on that map. (not for all players limit these items only on that player that bought 1 time) thank you !

code here

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <zombie_plague_advance>


#define PLUGIN "[ZP] Pack Assasin,Survivor,Nemesis,Sniper"
#define VERSION "2.1"
#define AUTHOR "Ghost95V"

#define ZP_TEAM_HUMAN (1<<1)
new const g_item_nem_name[] = "Buy Nemesis"
new const g_item_sur_name[] = "Buy Survivor"




new g_maxplayersg_msgSayText
new g_nemesisg_survivor
new g_buyableg_endroundRoundCountcvar_delay
new const g_costnemesis 140
new const g_costsurvivor 200


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)


    
g_maxplayers get_maxplayers()
    
g_msgSayText get_user_msgid("SayText")
    
    
g_buyable true
    RoundCount 
0
}


public 
plugin_precache()
{

    
cvar_delay register_cvar("zp_buy_classes_delay""3")    
}
public 
zp_extra_item_selected(playeritemid)
{
    if (
itemid != g_nemesis && itemid != g_survivor)
        return 
PLUGIN_CONTINUE;
    
    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;
    }
    new 
name[32]
    
get_user_name(playername31)

    if (
itemid == g_nemesis)
    {
        
zp_make_user_nemesis(player)
        
zp_colored_print(0"^x04[StreetZM]^x03 %s^x01 has bought ^x04 Nemesis"name)
    }
    else  if (
itemid == g_survivor)
    {
        
zp_make_user_survivor(player)
        
zp_colored_print(0"^x04[StreetZM]^x03 %s^x01 has bought ^x04 Survivor"name)    
    }
    
g_buyable false    
    
return PLUGIN_CONTINUE
}

public 
event_round_start()
    
g_endround false

public logevent_round_end()
{
    
g_endround true
    
    
if (g_buyable)
        return;
    
    if (
RoundCount get_pcvar_num(cvar_delay))
        
RoundCount++
    else if (
RoundCount >= get_pcvar_num(cvar_delay))
    {
        
g_buyable true
        RoundCount 
0
    
}
}
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()
    }

__________________

Last edited by ghost95v; 10-07-2014 at 16:45.
ghost95v is offline
Send a message via Skype™ to ghost95v
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-07-2014 , 20:10   Re: [Help] Add limit each player 1 item per map
Reply With Quote #2

Just try below:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <zombie_plague_advance>


#define PLUGIN "[ZP] Pack Assasin,Survivor,Nemesis,Sniper"
#define VERSION "2.1"
#define AUTHOR "Ghost95V"

#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_endround, , RoundCountcvar_delay
new has_nemesis[33], has_survivor[33]

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 (!
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;
    }
    new 
name[32]
    
get_user_name(playernamecharsmax(name))

    if(
itemid == g_nemesis)
    {
        if (
has_nemesis[player])
        {
            
zp_colored_print(player"^x04[ZP]^x01 You only can^x04 buy this item^x01 once for a map")
            
            return 
ZP_PLUGIN_HANDLED;
        }
        
        
zp_make_user_nemesis(player)
        
zp_colored_print(0"^x04[StreetZM]^x03 %s^x01 has bought ^x04 Nemesis"name)
        
        
has_nemesis[player] = true
    
}
    else if(
itemid == g_survivor)
    {
        if (
has_survivor[player])
        {
            
zp_colored_print(player"^x04[ZP]^x01 You only can^x04 buy this item^x01 once for a map")
            
            return 
ZP_PLUGIN_HANDLED;
        }
        
zp_make_user_survivor(player)
        
zp_colored_print(0"^x04[StreetZM]^x03 %s^x01 has bought ^x04 Survivor"name)  

        
has_survivor[player] = true
    
}   
    
g_buyable false
    
    
return PLUGIN_CONTINUE
}

public 
event_round_start()
{
    
g_endround false
    g_buyable 
true
    RoundCount 
0
}

public 
logevent_round_end()
{
    
g_endround true
    
    
if (g_buyable)
        return;
    
    if (
RoundCount get_pcvar_num(cvar_delay))
        
RoundCount++
        
    else if (
RoundCount >= get_pcvar_num(cvar_delay))
    {
        
g_buyable true
        RoundCount 
0
    
}
}
    
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()
    }


Last edited by zmd94; 10-08-2014 at 20:08.
zmd94 is offline
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 10-08-2014 , 07:38   Re: [Help] Add limit each player 1 item per map
Reply With Quote #3

Quote:
Originally Posted by zmd94 View Post
Just try below:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <zombie_plague_advance>


#define PLUGIN "[ZP] Pack Assasin,Survivor,Nemesis,Sniper"
#define VERSION "2.1"
#define AUTHOR "Ghost95V"

#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_endround
new has_nemesis[33], has_survivor[33]

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)

    
g_maxplayers get_maxplayers()
    
g_msgSayText get_user_msgid("SayText")
}

public 
zp_extra_item_selected(playeritemid)
{
    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;
    }
    new 
name[32]
    
get_user_name(playernamecharsmax(name))

    if(
itemid == g_nemesis)
    {
        if (
has_nemesis[id])
        {
            
zp_colored_print(player"^x04[ZP]^x01 You only can^x04 buy this item^x01 once for a map")
            
            return 
ZP_PLUGIN_HANDLED;
        }
        
        
zp_make_user_nemesis(player)
        
zp_colored_print(0"^x04[StreetZM]^x03 %s^x01 has bought ^x04 Nemesis"name)
        
        
has_nemesis[id] = true
    
}
    else if(
itemid == g_survivor)
    {
        if (
has_survivor[id])
        {
            
zp_colored_print(player"^x04[ZP]^x01 You only can^x04 buy this item^x01 once for a map")
            
            return 
ZP_PLUGIN_HANDLED;
        }
        
zp_make_user_survivor(player)
        
zp_colored_print(0"^x04[StreetZM]^x03 %s^x01 has bought ^x04 Survivor"name)  

        
has_survivor[id] = true
    
}   
    return 
PLUGIN_CONTINUE
}

public 
event_round_start()
    
g_endround false

public logevent_round_end()
    
g_endround true
    
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()
    }

thank you .... but , this is for each player ? or blocks buy for all player, if 1 player has already bought that item in that map. ( i wana to make, for that player, that has bought 1 time , that item in map , hee will cant buy again)
__________________

Last edited by ghost95v; 10-08-2014 at 07:41.
ghost95v is offline
Send a message via Skype™ to ghost95v
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-08-2014 , 09:20   Re: [Help] Add limit each player 1 item per map
Reply With Quote #4

It will only affect the player that bought the extra item. Not all players. ;)
zmd94 is offline
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 10-08-2014 , 14:28   Re: [Help] Add limit each player 1 item per map
Reply With Quote #5

Quote:
Originally Posted by zmd94 View Post
It will only affect the player that bought the extra item. Not all players. ;)
thank you so much , my friend ... in my firs post , code has round count, that players cant buy item before 3 rounds go,,, its possible to have and that ?
__________________
ghost95v is offline
Send a message via Skype™ to ghost95v
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-08-2014 , 17:10   Re: [Help] Add limit each player 1 item per map
Reply With Quote #6

Alright, I will try to update the code. ;)
zmd94 is offline
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 10-08-2014 , 17:16   Re: [Help] Add limit each player 1 item per map
Reply With Quote #7

Quote:
Originally Posted by zmd94 View Post
Alright, I will try to update the code. ;)
Ty ,,, and if i set " if (has_survivor[0]) " will afect on all players ?

and i think you coded bad? ..

this have "player" not "id"
PHP Code:
public zp_extra_item_selected(playeritemid
and you puted " [id] " in this check ??
PHP Code:
if (has_nemesis[id]) 
this will give, undefined symbol "id" i think.
__________________

Last edited by ghost95v; 10-08-2014 at 18:05.
ghost95v is offline
Send a message via Skype™ to ghost95v
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-08-2014 , 19:56   Re: [Help] Add limit each player 1 item per map
Reply With Quote #8

By the way, my fault. It is supposed to be if(has_nemesis[player]).

You are right.

I have updated the previous code. Feel free to use it. ;)

Last edited by zmd94; 10-08-2014 at 20:32.
zmd94 is offline
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 10-09-2014 , 10:13   Re: [Help] Add limit each player 1 item per map
Reply With Quote #9

Quote:
Originally Posted by zmd94 View Post
By the way, my fault. It is supposed to be if(has_nemesis[player]).

You are right.

I have updated the previous code. Feel free to use it. ;)
Yes, ty . sorry, again , if i set "if(has_nemesis[0]) will afect in all players?
__________________
ghost95v is offline
Send a message via Skype™ to ghost95v
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-09-2014 , 18:49   Re: [Help] Add limit each player 1 item per map
Reply With Quote #10

Nope. ;)
zmd94 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 13:59.


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