Raised This Month: $ Target: $400
 0% 

limited ammo/clips


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ExKiLL
Senior Member
Join Date: Nov 2005
Location: Germany
Old 12-01-2007 , 14:09   limited ammo/clips
Reply With Quote #1

hey you out there

i want to write a plugin which let you config ammo and clips for each weapon

my basement is "Awp One Shot" made by Avalanche -> http://forums.alliedmods.net/showthread.php?t=52776

i tried to rewrite it for m4

http://forums.alliedmods.net/showthread.php?t=63288

but it doesnt works

i tried my skills (allmost 0)

Code:
/home/groups/amxmodx/tmp3/phpJQQG4k.sma(78) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpJQQG4k.sma(111) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpJQQG4k.sma(169) : warning 204: symbol is assigned a value that is never used: "gmsgCurWeapon1"
/home/groups/amxmodx/tmp3/phpJQQG4k.sma(169) : warning 203: symbol is never used: "weapon1"
Header size:            720 bytes
Code size:             4340 bytes
Data size:             1536 bytes
Stack/heap size:      16384 bytes; estimated max. usage=42 cells (168 bytes)
Total requirements:   22980 bytes

4 Warnings.
Done.
Code:
 #include <amxmodx>
 #include <fakemeta>
 #include <cstrike>

 new cv_awp_clip, gmsgCurWeapon, weapon[33], awp_clip[33], awp_bpammo[33];
 new cv_m4a1_clip, gmsgCurWeapon1, weapon1[33], m4a1_clip[33], m4_bpammo[33];

 public plugin_init()
 {
	register_plugin("AWP One Shot","0.11","Avalanche");

	register_event("CurWeapon","event_curweapon","b");
	register_event("AmmoX","event_ammox","b");

	gmsgCurWeapon = get_user_msgid("CurWeapon");
	gmsgCurWeapon1 = get_user_msgid("CurWeapon");
	cv_awp_clip = register_cvar("awp_clip","1");
	cv_m4a1_clip = register_cvar("m4a1_clip","10");

	register_forward(FM_CmdStart,"fw_cmdstart",1);
 }

 // reset values
 public client_putinserver(id)
 {
	weapon[id] = 0;
	awp_clip[id] = 0;
	awp_bpammo[id] = 0;
	m4a1_clip[id] = 0;
 }

 // restrict clip ammo
 public event_curweapon(id)
 {
	new status = read_data(1);

	if(status) weapon[id] = read_data(2);

	// using AWP
	if(read_data(2) == CSW_AWP)
	{
		// current weapon
		if(status)
		{
			// save clip information
			new old_awp_clip = awp_clip[id];
			awp_clip[id] = read_data(3);

			new max_clip = get_pcvar_num(cv_awp_clip);

			// plugin enabled and must restrict ammo
			if(max_clip && awp_clip[id] > max_clip)
			{
				new wEnt = get_weapon_ent(id,CSW_AWP);
				if(pev_valid(wEnt)) cs_set_weapon_ammo(wEnt,max_clip);

				// update HUD
				message_begin(MSG_ONE,gmsgCurWeapon,_,id);
				write_byte(1);
				write_byte(CSW_AWP);
				write_byte(max_clip);
				message_end();

				// don't steal ammo from the player
				if(awp_bpammo[id] && awp_clip[id] > old_awp_clip)
					cs_set_user_bpammo(id,CSW_AWP,awp_bpammo[id]-max_clip+old_awp_clip);

				awp_clip[id] = max_clip;
			}
		}
		else awp_clip[id] = 999;
	}
	
	if(status) weapon[id] = read_data(4);
	
		// using m4
		if(read_data(4) == CSW_M4A1)
		{
			// current weapon
			if(status)
			{
				// save clip information
				new old_m4a1_clip = m4a1_clip[id];
				m4a1_clip[id] = read_data(5);
	
				new max_clip = get_pcvar_num(cv_m4a1_clip);
	
				// plugin enabled and must restrict ammo
				if(max_clip && m4a1_clip[id] > max_clip)
				{
					new wEnt = get_weapon_ent(id,CSW_M4A1);
					if(pev_valid(wEnt)) cs_set_weapon_ammo(wEnt,max_clip);
	
					// update HUD
					message_begin(MSG_ONE,gmsgCurWeapon,_,id);
					write_byte(1);
					write_byte(CSW_M4A1);
					write_byte(max_clip);
					message_end();
	
					// don't steal ammo from the player
					if(m4_bpammo[id] && m4a1_clip[id] > old_m4a1_clip)
						cs_set_user_bpammo(id,CSW_M4A1,m4_bpammo[id]-max_clip+old_m4a1_clip);
	
					m4a1_clip[id] = max_clip;
				}
			}
			else m4a1_clip[id] = 999;
	}
	else if(status) m4a1_clip[id] = 999;
 }

 // delayed record bpammo information
 public event_ammox(id)
 {
	// awp ammo type is 1
	if(read_data(1) == 1)
	{
		static parms[2];
		parms[0] = id;
		parms[1] = read_data(2);

		set_task(0.1,"record_ammo",id,parms,2);
	}
 }

 // delay, because ammox is called right before curweapon
 public record_ammo(parms[])
 {
	awp_bpammo[parms[0]] = parms[1];
 }

 // block reload based on new clip size
 public fw_cmdstart(player,uc_handle,random_seed)
 {
	new max_clip = get_pcvar_num(cv_awp_clip);

	if(weapon[player] == CSW_AWP && max_clip && awp_clip[player] >= max_clip)
	{
		set_uc(uc_handle,UC_Buttons,get_uc(uc_handle,UC_Buttons) & ~IN_RELOAD);
		return FMRES_HANDLED;
	}

	return FMRES_IGNORED;
 }

 // find a player's weapon entity
 stock get_weapon_ent(id,wpnid=0,wpnName[]="")
 {
	// who knows what wpnName will be
	static newName[32];

	// need to find the name
	if(wpnid) get_weaponname(wpnid,newName,31);

	// go with what we were told
	else formatex(newName,31,"%s",wpnName);

	// prefix it if we need to
	if(!equal(newName,"weapon_",7))
		format(newName,31,"weapon_%s",newName);

	new ent;
	while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",newName)) && pev(ent,pev_owner) != id) {}

	return ent;
 }
but if i put this amxx on my server
still working for awp with 1 shot, but no result on m4

what is the name for the m4 or other weapons?

btw
i have no skills with the commands of the modules or something else

the plugin should support in final version to set the ammunition per amx_WEAPONNAME_ammo and amx_WEAPONNAME_clip

or only ammo, this is the important thing!
__________________
193.192.59.43:27015 ----- italy ( 20 )
85.25.150.62:27015 ------ sHclachthaus ( 14 )
85.25.150.62:27055 ------ DeathMatch ( 20 )
85.25.150.62:27035 ------ Kreedz Hangout ( 18 )
85.214.100.160:27015 ---- 24/7 full house | **GG + DM** ( 32 )
93.190.64.150:27015 ----- Superhero (12)

Last edited by ExKiLL; 12-01-2007 at 14:12.
ExKiLL 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 11:13.


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