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

[HELP] limit buy HP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abood alnjjar
Member
Join Date: Oct 2015
Location: palestine
Old 11-25-2015 , 15:42   [HELP] limit buy HP
Reply With Quote #1

hi guys...
how to limit this Extra item to can be buy it just 1 time in round

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

new const item_name[] = "Buy 2500 HP!"
new g_itemid_buyhp
new hpamount

public plugin_init() 
{
	register_plugin("[ZoZ] Buy Health Points", "1.0", "T[h]E Dis[as]teR")
	hpamount = register_cvar("zp_buyhp_amount", "2500")
	g_itemid_buyhp = zp_register_extra_item(item_name, 5, ZP_TEAM_HUMAN & ZP_TEAM_ZOMBIE)
}
public zp_extra_item_selected(id,itemid)
{
	if(!is_user_alive(id))
	
	return PLUGIN_HANDLED;
	
	if(itemid==g_itemid_buyhp)
	{
		if(zp_get_user_ammo_packs(id) < 5)
		{
			client_print(id, print_chat,"[ZoZ] Not enough Ammopacks!");
			return PLUGIN_HANDLED;
		}
		else
		{
			set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount));
			zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - 5);
			client_print(id, print_chat,"[ZP] You Bought HP!");
		}
	}
	return PLUGIN_CONTINUE;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/
__________________
abood alnjjar is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 11-25-2015 , 18:21   Re: [HELP] limit buy HP
Reply With Quote #2

PHP Code:
new bool:g_iTem33 ]  // Create a bool for the item

public client_connectid )
{
    
g_iTemid ] = false  // set the bool to false when the player connect
}

public 
whatever_you_wantid )
{
    if( !
g_iTemid ] ) // check to see if it's true or false. if it's false give the player the item
    
{
        
give_itemid"your_weapon" )
        
g_iTemid ] = true // set it true when the player buy the item
    
}
}

public 
round_end()
{
    
arraysetg_iTem0sizeofg_iTem) ) // set it to false at the end of the round.

Here's a way
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 11-25-2015 , 21:07   Re: [HELP] limit buy HP
Reply With Quote #3

Quote:
public client_connect( id )
{
g_iTem[ id ] = false // set the bool to false when the player connect
}
I thought booleans are set to false by default?
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-25-2015 , 21:50   Re: [HELP] limit buy HP
Reply With Quote #4

Quote:
Originally Posted by Chihuahuax View Post
I thought booleans are set to false by default?
They are but it has to be done during gameplay.

Here's why:
1. bugsy connects on slot 3, boolean is set to true
2. bugsy disconnects from the server, value is still true
3. Chihuahuax connects on slot 3, value is still true. It is set to false to reset it for players joining on that same slot.
__________________

Last edited by Bugsy; 11-25-2015 at 21:52.
Bugsy is offline
Old 11-25-2015, 22:33
Chihuahuax
This message has been deleted by Chihuahuax. Reason: got it
abood alnjjar
Member
Join Date: Oct 2015
Location: palestine
Old 11-26-2015 , 12:39   Re: [HELP] limit buy HP
Reply With Quote #5

be like this not work...how be ???

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

new const item_name[] = "Buy 2500 HP!"
new g_itemid_buyhp
new hpamount

public plugin_init() 
{
    
register_plugin("[ZoZ] Buy Health Points""1.0""T[h]E Dis[as]teR")
    
hpamount register_cvar("zp_buyhp_amount""2500")
    
g_itemid_buyhp zp_register_extra_item(item_name5ZP_TEAM_HUMAN ZP_TEAM_ZOMBIE)
}
public 
zp_extra_item_selected(id,itemid)
{
    if(!
is_user_alive(id))
    
    return 
PLUGIN_HANDLED;
    
    if(
itemid==g_itemid_buyhp)
    {
        if(
zp_get_user_ammo_packs(id) < 5)
        {
            
client_print(idprint_chat,"[ZoZ] Not enough Ammopacks!");
            return 
PLUGIN_HANDLED;
        }
        else
        {
            
set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount));
            
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - 5);
            
client_print(idprint_chat,"[ZoZ] You Bought HP!");
        }
    }
    return 
PLUGIN_CONTINUE;
}
new 
bool:g_iTem33 ]  // Create a bool for the item

public client_connectid )
{
    
g_iTemid ] = false  // set the bool to false when the player connect
}

public 
whatever_you_wantid )
{
    if( !
g_iTemid ] ) // check to see if it's true or false. if it's false give the player the item
    
{
        
give_itemid"your_weapon" )
        
g_iTemid ] = true // set it true when the player buy the item
    
}
}

public 
round_end()
{
    
arraysetg_iTem0sizeofg_iTem) ) // set it to false at the end of the round.
}  
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/ 
__________________

Last edited by Bugsy; 11-26-2015 at 14:42.
abood alnjjar is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 11-26-2015 , 14:37   Re: [HELP] limit buy HP
Reply With Quote #6

Don't use [QUOTE] tags to post code, use [PHP] or [CODE] tags instead. I showed you what you need to do.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 11-26-2015 , 17:09   Re: [HELP] limit buy HP
Reply With Quote #7

Quote:
Originally Posted by abood alnjjar View Post
be like this not work...how be ???

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

new const item_name[] = "Buy 2500 HP!"
new g_itemid_buyhp
new hpamount

public plugin_init() 
{
    
register_plugin("[ZoZ] Buy Health Points""1.0""T[h]E Dis[as]teR")
    
hpamount register_cvar("zp_buyhp_amount""2500")
    
g_itemid_buyhp zp_register_extra_item(item_name5ZP_TEAM_HUMAN ZP_TEAM_ZOMBIE)
}
public 
zp_extra_item_selected(id,itemid)
{
    if(!
is_user_alive(id))
    
    return 
PLUGIN_HANDLED;
    
    if(
itemid==g_itemid_buyhp)
    {
        if(
zp_get_user_ammo_packs(id) < 5)
        {
            
client_print(idprint_chat,"[ZoZ] Not enough Ammopacks!");
            return 
PLUGIN_HANDLED;
        }
        else
        {
            
set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount));
            
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - 5);
            
client_print(idprint_chat,"[ZoZ] You Bought HP!");
        }
    }
    return 
PLUGIN_CONTINUE;
}
new 
bool:g_iTem33 ]  // Create a bool for the item

public client_connectid )
{
    
g_iTemid ] = false  // set the bool to false when the player connect
}

public 
whatever_you_wantid )
{
    if( !
g_iTemid ] ) // check to see if it's true or false. if it's false give the player the item
    
{
        
give_itemid"your_weapon" )
        
g_iTemid ] = true // set it true when the player buy the item
    
}
}

public 
round_end()
{
    
arraysetg_iTem0sizeofg_iTem) ) // set it to false at the end of the round.
}  
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/ 
Because you just copy pasted what wickedd posted without editing it. Plus when creating global variables you need to create them about plugin_init
__________________
Blizzard_87 is offline
abood alnjjar
Member
Join Date: Oct 2015
Location: palestine
Old 11-27-2015 , 02:22   Re: [HELP] limit buy HP
Reply With Quote #8

im noob man what is plugin_init :/
__________________
abood alnjjar is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 11-27-2015 , 03:43   Re: [HELP] limit buy HP
Reply With Quote #9

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

new const item_name[] = "Buy 2500 HP!"
new g_itemid_buyhpg_maxplayersbool:g_iTem[33]
new 
hpamount

public plugin_init() 
{
    
register_plugin("[ZoZ] Buy Health Points""1.0""T[h]E Dis[as]teR")
    
hpamount register_cvar("zp_buyhp_amount""2500")
    
g_itemid_buyhp zp_register_extra_item(item_name5ZP_TEAM_HUMAN ZP_TEAM_ZOMBIE)
    
register_event("HLTV""event_round_start""a""1=0""2=0")    
    
g_maxplayers get_maxplayers()
}

public 
zp_extra_item_selected(id,itemid)
{    
    if(
itemid==g_itemid_buyhp)
    {
        if(
g_iTem[id])
        {
            
client_print(idprint_chat,"[ZoZ] Not enough Ammopacks!");
            return 
ZP_PLUGIN_HANDLED
        
}
        
set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount));
        
client_print(idprint_chat,"[ZP] You Bought HP!");
        
g_iTem[id] = true
    
}
    return 
PLUGIN_CONTINUE;
}

public 
client_connect(id)
{
    
g_iTem[id] = false
}

public 
event_round_start()
{
    for (new 
playerplayer <= g_maxplayersplayer++)
    {
        
g_iTem[player] = false
    
}

Did it for u bcuz i dont expect you to understand these
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
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 16:17.


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