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 , 11:56   Re: [ZP] Extra Item Buy Limit
Reply With Quote #1

wicho , your code dont work corect , now when i am buying other item i get +10 ammo packs and this message : You already have this item!

Last edited by serjaka; 11-24-2013 at 12:34.
serjaka is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 11-24-2013 , 13:55   Re: [ZP] Extra Item Buy Limit
Reply With Quote #2

This should work fine on ZP4.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_infammog_has_unlimited_clip[33], iBuyCount
const iMaxBuyRound //Set max unliclip that can be bought each round

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")
}

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

    
iBuyCount //reset buylimit
    
new iPlayers[32], iNumj
    get_players
(iPlayersiNum"h")
    for(
j=0;j<iNum;j++)
    {
        
g_has_unlimited_clip[iPlayers[j]] = 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]) 
        } 
    } 
}

public 
client_putinserver(id)
{
    
g_has_unlimited_clip[id] = false //remove unliclip bugfix
}

public 
client_disconnect(id)
{
    
g_has_unlimited_clip[id] = false //remove unliclip bugfix
}

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

    if (
itemid == g_itemid_infammo
    {
        if(
iBuyCount >= iMaxBuyRound//usage overlimit
        
{
            
ColorChat(playerGREEN"[ZP]^x01 Sorry this item is not available."
            return 
ZP_PLUGIN_HANDLED;
        }
        
        if(
g_has_unlimited_clip[player]) //already has unliclip
        
{
            
ColorChat(playerGREEN"[ZP]^x01 You already have^x04 UnlimitedClip")
            return 
ZP_PLUGIN_HANDLED;
        }
        
        
iBuyCount++
        
g_has_unlimited_clip[player] = true 
        ColorChat
(playerGREEN"[ZP]^x01 You bought^x04 Unlimited Clip^x01!"
    } 
    
    return 
PLUGIN_CONTINUE;


public 
zp_user_infected_post(id)
{
    
g_has_unlimited_clip[id] = false //remove unliclip bugfix
}

public 
zp_user_humanized_post(id)
{
    
g_has_unlimited_clip[id] = false //remove unliclip bugfix
}

// Find entity by its owner (from fakemeta_util) 
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 
fm_set_weapon_ammo(entityamount

    
set_pdata_int(entityOFFSET_CLIPAMMOamountOFFSET_LINUX_WEAPONS); 

Just set how many times player can buy each round here:
Code:
const iMaxBuyRound = 6 //Set max unliclip that can be bought each round
Code update, forgot to add return PLUGIN_CONTINUE;
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 11-24-2013 at 14:04.
yokomo is offline
serjaka
Senior Member
Join Date: Oct 2011
Old 11-24-2013 , 14:41   Re: [ZP] Extra Item Buy Limit
Reply With Quote #3

thx yokomo works fine , can you please add to this item too? thx bro
PHP Code:
 #include <amxmodx>
#include <zombieplague>
#include <fakemeta>
#include <fun>
#include <ColorChat>

new g_itemid1

public plugin_init()
{
register_plugin("[ZP] Extra Item: Gravity Item""1.0""Serjaka"
register_cvar("amx_gravitycost""10")
g_itemid1 zp_register_extra_item("Low Gravity"10ZP_TEAM_ANY)
}

public 
zp_extra_item_selected(playeritemid)
{
if (
itemid == g_itemid1)
{
set_user_gravity(player0.5)
ColorChat(playerGREEN"[ZP]^x01 You have bought^x04 Low Gravity^x01!")
}

serjaka is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 11-24-2013 , 16:12   Re: [ZP] Extra Item Buy Limit
Reply With Quote #4

Quote:
Originally Posted by serjaka View Post
thx yokomo works fine , can you please add to this item too? thx bro
PHP Code:
 #include <amxmodx>
#include <zombieplague>
#include <fakemeta>
#include <fun>
#include <ColorChat>

new g_itemid1

public plugin_init()
{
register_plugin("[ZP] Extra Item: Gravity Item""1.0""Serjaka"
register_cvar("amx_gravitycost""10")
g_itemid1 zp_register_extra_item("Low Gravity"10ZP_TEAM_ANY)
}

public 
zp_extra_item_selected(playeritemid)
{
if (
itemid == g_itemid1)
{
set_user_gravity(player0.5)
ColorChat(playerGREEN"[ZP]^x01 You have bought^x04 Low Gravity^x01!")
}

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

new g_itemid1iBuyCount
const iMaxBuy 6

public plugin_init()
{
    
register_plugin("[ZP] Extra Item: Gravity Item""1.0""Serjaka")
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
//register_cvar("amx_gravitycost", "10")
    
g_itemid1 zp_register_extra_item("Low Gravity"10ZP_TEAM_ANY)
}

public 
event_round_start()
{
    
iBuyCount 0
}

public 
zp_extra_item_selected(playeritemid)
{
    if (
itemid == g_itemid1)
    {
        if(
iBuyCount >= iMaxBuy)
        {
            
ColorChat(playerGREEN"[ZP]^x01 Sorry this item is not available.")
            return 
ZP_PLUGIN_HANDLED;
        }
        
        if(
pev(playerpev_gravity) <= 0.5)
        {
            
ColorChat(playerGREEN"[ZP]^x01 Your gravity is low already.")
            return 
ZP_PLUGIN_HANDLED;
        }
        
        
iBuyCount++
        
set_pev(playerpev_gravity0.5)
        
ColorChat(playerGREEN"[ZP]^x01 You have bought^x04 Low Gravity^x01!")
    }
    
    return 
PLUGIN_CONTINUE;

__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
serjaka
Senior Member
Join Date: Oct 2011
Old 11-24-2013 , 16:49   Re: [ZP] Extra Item Buy Limit
Reply With Quote #5

thx bro works fine
serjaka 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 23:20.


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