Raised This Month: $ Target: $400
 0% 

[ZP] Extra Item: Buy Shield


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
|LeGeNdArY| SaMuRaI
BANNED
Join Date: Oct 2009
Location: Lithuania
Old 12-18-2009 , 10:03   Re: [ZP] Extra Item: Buy Shield
Reply With Quote #6

So This Plugin Works ?


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

new g_item_name[] = { "Shield" }
new g_itemid_shield
new bool:g_hasShield[33]
#define COST 5

public plugin_init() 
{
	register_plugin("[ZP] Extra Item: Buy Shield", "1.1", "Johnny")
	g_itemid_shield = zp_register_extra_item(g_item_name, COST, ZP_TEAM_HUMAN)
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}
public client_connect(id)
{
	g_hasShield[id] = false
}

public client_disconnect(id)
{
	g_hasShield[id] = false
}

public event_round_start()
{
	for (new i = 1; i <= 32; i++)
		g_hasShield[i] = false
}


public zp_extra_item_selected(player, itemid)
{
	if ( itemid == g_itemid_shield )
	{
		if ( g_hasShield[player] == true )
		{
			new ammo_packs = zp_get_user_ammo_packs(player)
			zp_set_user_ammo_packs(player, ammo_packs + COST)
			zp_colored_print(player, "^x04[ZP]^x01 You already have a Shield")
		}
		else 
		{
			g_hasShield[player] = true
			fm_give_item(player, "weapon_shield")
			zp_colored_print(player, "^x04[ZP]^x01 You now have a Shield")
		}
	}
}

// Colored Print (zp_colored_print)
stock zp_colored_print(target, const message[], any:...)
{
	static g_msgSayText, maxplayers;
	if ( !g_msgSayText )
		g_msgSayText = get_user_msgid("SayText")
		
	if ( !maxplayers )
		maxplayers = get_maxplayers();
	
	static buffer[512], i, argscount;
	argscount = numargs();
	
	// Send to everyone
	if (!target)
	{
		static player;
		for (player = 1; player <= maxplayers; player++)
		{
			// 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 (i = 2; i < argscount; i++)
			{
				if (getarg(i) == LANG_PLAYER)
				{
					setarg(i, 0, player);
					changed[changedcount] = i;
					changedcount++;
				}
			}
			
			// Format message for player
			vformat(buffer, sizeof buffer - 1, message, 3);
			
			// Send it
			message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player);
			write_byte(player);
			write_string(buffer);
			message_end();
			
			// Replace back player id's with LANG_PLAYER
			for (i = 0; i < changedcount; i++)
				setarg(changed[i], 0, LANG_PLAYER);
		}
	}
	
	// Send to specific target
	else
	{
		// Format message for player
		vformat(buffer, sizeof buffer - 1, message, 3);
		
		// Send it
		message_begin(MSG_ONE, g_msgSayText, _, target);
		write_byte(target);
		write_string(buffer);
		message_end();
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/
I Cant Test It Myself - Server Is Down For A Week...
|LeGeNdArY| SaMuRaI is offline
Send a message via Skype™ to |LeGeNdArY| SaMuRaI
 



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


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