Raised This Month: $ Target: $400
 0% 

[ZP] Extra Item Buy Limit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
serjaka
Senior Member
Join Date: Oct 2011
Old 11-24-2013 , 06:12   [ZP] Extra Item Buy Limit
Reply With Quote #1

Hello AlliedModders who can help me please to do Extra Item buy Limit! Exemple: I buy Unlimited Clip and after this i need when buy unlimited clip again in chat will appear: "You alredy Have UnlimitedClip" becouse now when i am buying unlimited clip 1000 times per round and people can loose ammo packs! Thx

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

/*================================================================================
 [Plugin Customization]
=================================================================================*/

new const g_item_name[] = { "Unlimited Clip" }
const 
g_item_cost 10

/*============================================================================*/

// CS Offsets
#if cellbits == 32
const OFFSET_CLIPAMMO 51
#else
const OFFSET_CLIPAMMO 65
#endif
const OFFSET_LINUX_WEAPONS 4

// Max Clip for weapons
new const MAXCLIP[] = { -113, -11017, -1303013020253035251220,
            
10301008303020273030, -150 }

new 
g_itemid_infammog_has_unlimited_clip[33]

public 
plugin_init()
{
    
register_plugin("[ZP] Extra: Unlimited Clip""1.0""zp4.3")
    
    
g_itemid_infammo zp_register_extra_item(g_item_nameg_item_costZP_TEAM_HUMAN)    
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
}

// Player buys our upgrade, set the unlimited ammo flag
public zp_extra_item_selected(playeritemid)
{
    if (
itemid == g_itemid_infammo)
    {
        
g_has_unlimited_clip[player] = true
        ColorChat
(playerGREEN"[ZP] ^x01You bought^x04 Unlimited Clip^x01!")
        }
}

// Reset flags for all players on newround
public event_round_start()
{
    for (new 
idid <= 32id++) g_has_unlimited_clip[id] = false;
}

// Unlimited clip code
public message_cur_weapon(msg_idmsg_destmsg_entity)
{
    
// Player doesn't have the unlimited clip upgrade
    
if (!g_has_unlimited_clip[msg_entity])
        return;
    
    
// Player not alive or not an active weapon
    
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
        return;
    
    static 
weaponclip
    weapon 
get_msg_arg_int(2// get weapon ID
    
clip get_msg_arg_int(3// get weapon clip
    
    // Unlimited Clip Ammo
    
if (MAXCLIP[weapon] > 2// skip grenades
    
{
        
set_msg_arg_int(3get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time
        
        
if (clip 2// refill when clip is nearly empty
        
{
            
// Get the weapon entity
            
static wname[32], weapon_ent
            get_weaponname
(weaponwnamesizeof wname 1)
            
weapon_ent fm_find_ent_by_owner(-1wnamemsg_entity)
            
            
// Set max clip on weapon
            
fm_set_weapon_ammo(weapon_entMAXCLIP[weapon])
        }
    }
}

// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) {}
    
    return 
entity;
}

// Set Weapon Clip Ammo
stock fm_set_weapon_ammo(entityamount)
{
    
set_pdata_int(entityOFFSET_CLIPAMMOamountOFFSET_LINUX_WEAPONS);

serjaka is offline
bat
Veteran Member
Join Date: Jul 2012
Old 11-24-2013 , 06:33   Re: [ZP] Extra Item Buy Limit
Reply With Quote #2

Code:
public zp_extra_item_selected(player, itemid) 
{ 
    if (itemid == g_itemid_infammo) 
    { 
        g_has_unlimited_clip[player] = true 
        ColorChat(player, GREEN, "[ZP] ^x01You bought^x04 Unlimited Clip^x01!") 
    } 
	
	if (g_itemid_infammo[id])
	{
	    ColorChat(player, GREEN, "[ZP] ^x01You already have this item") 
	}	
}

Last edited by bat; 11-24-2013 at 06:35. Reason: forget )
bat is offline
Send a message via Skype™ to bat
serjaka
Senior Member
Join Date: Oct 2011
Old 11-24-2013 , 06:38   Re: [ZP] Extra Item Buy Limit
Reply With Quote #3

error when i try to copile
serjaka is offline
bat
Veteran Member
Join Date: Jul 2012
Old 11-24-2013 , 06:42   Re: [ZP] Extra Item Buy Limit
Reply With Quote #4

Sorry, try it

Code:
#include <amxmodx> 
#include <fakemeta> 
#include <zombieplague> 
#include <ColorChat> 

/*================================================================================ 
 [Plugin Customization] 
=================================================================================*/ 

new const g_item_name[] = { "Unlimited Clip" } 
const g_item_cost = 10 

/*============================================================================*/ 

// CS Offsets 
#if cellbits == 32 
const OFFSET_CLIPAMMO = 51 
#else 
const OFFSET_CLIPAMMO = 65 
#endif 
const OFFSET_LINUX_WEAPONS = 4 

// Max Clip for weapons 
new const MAXCLIP[] = { -1, 13, -1, 10, 1, 7, -1, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20, 
            10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, -1, 50 } 

new g_itemid_infammo, g_has_unlimited_clip[33] 

public plugin_init() 
{ 
    register_plugin("[ZP] Extra: Unlimited Clip", "1.0", "zp4.3") 
     
    g_itemid_infammo = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)     
     
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0") 
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon") 
} 

// Player buys our upgrade, set the unlimited ammo flag 
public zp_extra_item_selected(player, itemid) 
{ 
    if (itemid == g_itemid_infammo) 
    { 
        g_has_unlimited_clip[player] = true 
        ColorChat(player, GREEN, "[ZP] ^x01You bought^x04 Unlimited Clip^x01!") 
    } 
	
    if(g_has_unlimited_clip[player])
    {
       ColorChat(player, GREEN, "[ZP] ^x01You already have this item") 
       return ZP_PLUGIN_HANDLED
    }	

   return PLUGIN_CONTINUE
}

// Reset flags for all players on newround 
public event_round_start() 
{ 
    for (new id; id <= 32; id++) g_has_unlimited_clip[id] = false; 
} 

// Unlimited clip code 
public message_cur_weapon(msg_id, msg_dest, msg_entity) 
{ 
    // Player doesn't have the unlimited clip upgrade 
    if (!g_has_unlimited_clip[msg_entity]) 
        return; 
     
    // Player not alive or not an active weapon 
    if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1) 
        return; 
     
    static weapon, clip 
    weapon = get_msg_arg_int(2) // get weapon ID 
    clip = get_msg_arg_int(3) // get weapon clip 
     
    // Unlimited Clip Ammo 
    if (MAXCLIP[weapon] > 2) // skip grenades 
    { 
        set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time 
         
        if (clip < 2) // refill when clip is nearly empty 
        { 
            // Get the weapon entity 
            static wname[32], weapon_ent 
            get_weaponname(weapon, wname, sizeof wname - 1) 
            weapon_ent = fm_find_ent_by_owner(-1, wname, msg_entity) 
             
            // Set max clip on weapon 
            fm_set_weapon_ammo(weapon_ent, MAXCLIP[weapon]) 
        } 
    } 
} 

// Find entity by its owner (from fakemeta_util) 
stock fm_find_ent_by_owner(entity, const classname[], owner) 
{ 
    while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {} 
     
    return entity; 
} 

// Set Weapon Clip Ammo 
stock fm_set_weapon_ammo(entity, amount) 
{ 
    set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS); 
}
bat is offline
Send a message via Skype™ to bat
serjaka
Senior Member
Join Date: Oct 2011
Old 11-24-2013 , 07:08   Re: [ZP] Extra Item Buy Limit
Reply With Quote #5

This problem -
serjaka is offline
Gasa
Senior Member
Join Date: Sep 2013
Old 11-24-2013 , 07:53   Re: [ZP] Extra Item Buy Limit
Reply With Quote #6

PHP Code:
#include <amxmodx> 
#include <fakemeta> 
#include <zombieplague> 
#include <ColorChat> 
#include <zp50_items> 

/*================================================================================ 
 [Plugin Customization] 
=================================================================================*/ 

new const g_item_name[] = { "Unlimited Clip" 
const 
g_item_cost 10 

/*============================================================================*/ 

// CS Offsets 
#if cellbits == 32 
const OFFSET_CLIPAMMO 51 
#else 
const OFFSET_CLIPAMMO 65 
#endif 
const OFFSET_LINUX_WEAPONS 

// Max Clip for weapons 
new const MAXCLIP[] = { -113, -11017, -1303013020253035251220
            
10301008303020273030, -150 

new 
g_itemid_infammog_has_unlimited_clip[33


public 
plugin_init() 

    
register_plugin("[ZP] Extra: Unlimited Clip""1.0""zp4.3"
     
    
g_itemid_infammo zp_register_extra_item(g_item_nameg_item_costZP_TEAM_HUMAN)     
     
    
register_event("HLTV""event_round_start""a""1=0""2=0"
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon"


public 
zp_fw_items_select_pre(iditemid)
{
    if(
itemid != g_has_unlimited_clip[id])
        return 
ZP_ITEM_AVAILABLE
        
    
if (g_has_unlimited_clip[id])
        return 
ZP_ITEM_NOT_AVAILABLE

    
if(zp_get_user_zombie(id))
        return 
ZP_ITEM_DONT_SHOW

    
return ZP_ITEM_AVAILABLE
}

// Player buys our upgrade, set the unlimited ammo flag 
public zp_extra_item_selected(playeritemid

    if (
itemid == g_itemid_infammo
    { 
        
g_has_unlimited_clip[player] = true 
        ColorChat
(playerGREEN"[ZP] ^x01You bought^x04 Unlimited Clip^x01!"
        } 


// Reset flags for all players on newround 
public event_round_start() 

    for (new 
idid <= 32id++) g_has_unlimited_clip[id] = false


// Unlimited clip code 
public message_cur_weapon(msg_idmsg_destmsg_entity

    
// Player doesn't have the unlimited clip upgrade 
    
if (!g_has_unlimited_clip[msg_entity]) 
        return; 
     
    
// Player not alive or not an active weapon 
    
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1
        return; 
     
    static 
weaponclip 
    weapon 
get_msg_arg_int(2// get weapon ID 
    
clip get_msg_arg_int(3// get weapon clip 
     
    // Unlimited Clip Ammo 
    
if (MAXCLIP[weapon] > 2// skip grenades 
    

        
set_msg_arg_int(3get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time 
         
        
if (clip 2// refill when clip is nearly empty 
        

            
// Get the weapon entity 
            
static wname[32], weapon_ent 
            get_weaponname
(weaponwnamesizeof wname 1
            
weapon_ent fm_find_ent_by_owner(-1wnamemsg_entity
             
            
// Set max clip on weapon 
            
fm_set_weapon_ammo(weapon_entMAXCLIP[weapon]) 
        } 
    } 


// Find entity by its owner (from fakemeta_util) 
stock fm_find_ent_by_owner(entity, const classname[], owner

    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) {} 
     
    return 
entity


// Set Weapon Clip Ammo 
stock fm_set_weapon_ammo(entityamount

    
set_pdata_int(entityOFFSET_CLIPAMMOamountOFFSET_LINUX_WEAPONS); 

Gasa is offline
serjaka
Senior Member
Join Date: Oct 2011
Old 11-24-2013 , 07:57   Re: [ZP] Extra Item Buy Limit
Reply With Quote #7

i need for ZP 4.3
serjaka is offline
Gasa
Senior Member
Join Date: Sep 2013
Old 11-24-2013 , 08:18   Re: [ZP] Extra Item Buy Limit
Reply With Quote #8

4.3
PHP Code:
#include <amxmodx> 
#include <fakemeta> 
#include <zombieplague> 
#include <ColorChat> 

/*================================================================================ 
 [Plugin Customization] 
=================================================================================*/ 

new const g_item_name[] = { "Unlimited Clip" 
const 
g_item_cost 10 

/*============================================================================*/ 

// CS Offsets 
#if cellbits == 32 
const OFFSET_CLIPAMMO 51 
#else 
const OFFSET_CLIPAMMO 65 
#endif 
const OFFSET_LINUX_WEAPONS 

// Max Clip for weapons 
new const MAXCLIP[] = { -113, -11017, -1303013020253035251220
            
10301008303020273030, -150 

new 
g_itemid_infammo
new bool:g_has_unlimited_clip[33

public 
plugin_init() 

    
register_plugin("[ZP] Extra: Unlimited Clip""1.0""zp4.3"
     
    
g_itemid_infammo zp_register_extra_item(g_item_nameg_item_costZP_TEAM_HUMAN)     
     
    
register_event("HLTV""event_round_start""a""1=0""2=0"
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon"


// Player buys our upgrade, set the unlimited ammo flag 
public zp_extra_item_selected(playeritemid

    if (
g_has_unlimited_clip[player]) 
    { 
        
ColorChat(playerGREEN"[ZP] ^x01You already bought^x04 this item^x01!")
    }
    else
    if (
itemid == g_itemid_infammo
    { 
        
g_has_unlimited_clip[player] = true 
        ColorChat
(playerGREEN"[ZP] ^x01You bought^x04 Unlimited Clip^x01!"
    } 


// Reset flags for all players on newround 
public event_round_start() 

    for (new 
idid <= 32id++) g_has_unlimited_clip[id] = false


// Unlimited clip code 
public message_cur_weapon(msg_idmsg_destmsg_entity

    
// Player doesn't have the unlimited clip upgrade 
    
if (!g_has_unlimited_clip[msg_entity]) 
        return; 
     
    
// Player not alive or not an active weapon 
    
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1
        return; 
     
    static 
weaponclip 
    weapon 
get_msg_arg_int(2// get weapon ID 
    
clip get_msg_arg_int(3// get weapon clip 
     
    // Unlimited Clip Ammo 
    
if (MAXCLIP[weapon] > 2// skip grenades 
    

        
set_msg_arg_int(3get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time 
         
        
if (clip 2// refill when clip is nearly empty 
        

            
// Get the weapon entity 
            
static wname[32], weapon_ent 
            get_weaponname
(weaponwnamesizeof wname 1
            
weapon_ent fm_find_ent_by_owner(-1wnamemsg_entity
             
            
// Set max clip on weapon 
            
fm_set_weapon_ammo(weapon_entMAXCLIP[weapon]) 
        } 
    } 


// Find entity by its owner (from fakemeta_util) 
stock fm_find_ent_by_owner(entity, const classname[], owner

    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) {} 
     
    return 
entity


// Set Weapon Clip Ammo 
stock fm_set_weapon_ammo(entityamount

    
set_pdata_int(entityOFFSET_CLIPAMMOamountOFFSET_LINUX_WEAPONS); 


Last edited by Gasa; 11-24-2013 at 08:19.
Gasa is offline
serjaka
Senior Member
Join Date: Oct 2011
Old 11-24-2013 , 08:32   Re: [ZP] Extra Item Buy Limit
Reply With Quote #9

when i buy second time, in chat: You alredy have this item! but my ammo is go away i need no "-" ammo

Last edited by serjaka; 11-24-2013 at 08:33.
serjaka is offline
Gasa
Senior Member
Join Date: Sep 2013
Old 11-24-2013 , 09:15   Re: [ZP] Extra Item Buy Limit
Reply With Quote #10

ColorChat(player, GREEN, "[ZP] ^x01You already bought^x04 Unlimited Clips^x01!")
Gasa 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 23:20.


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