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

API Scripting Help [REQ]Drop unlimited clip


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 03-05-2015 , 01:49   [REQ]Drop unlimited clip
Reply With Quote #1

I know i have exotic requests... but...
Can someone do it, or help me out in creating the following
If player has unlimited clip and is infected/killed the unlimited clip to drop just like the jetpack

i posted the code that spawns a jetpack, if anyone could delete the useless stuff from it and merge it into the unlimited clip code, it would be great, thx

Short Explanation:
How to make an entity spawn when a player with unlimited clip dies or is infected ( like jetpack or bat ) ?
Also when a player touches the entity, the entity to dissapear and the player to recieve unlimited clip

Code:
#include <amxmodx>
#include <fakemeta>
#include <zp50_core>
#include <zp50_items>
#include <zp50_colorchat>

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


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

// 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", "MeRcyLeZZ")
	
	g_itemid_infammo = zp_items_register("Unlimited Clip", 30)	
	
	register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
	register_event("DeathMsg","DeathMsg","a")
}

public DeathMsg(id) 
{
	new id = read_data(2)
	
	g_has_unlimited_clip[id] = false
}

public zp_fw_core_infect_post(id)
{
       g_has_unlimited_clip[id] = false
}

// Player buys our upgrade, set the unlimited ammo flag
public zp_fw_items_select_pre(id, itemid, igc)
{
   if( itemid == g_itemid_infammo)
   {
      if( zp_core_is_zombie(id))
      return ZP_ITEM_DONT_SHOW         
   }
   return ZP_ITEM_AVAILABLE
     
}

public zp_fw_items_select_post(id, item, igc)
{
	if(item == g_itemid_infammo)
	{
           if(g_has_unlimited_clip[id])
           {
           zp_colored_print(id, "^x04[ZP]^x01 You Already have Unlimited Clip!")
           return PLUGIN_HANDLED 
           }
 
           else
           { 
           zp_colored_print(id, "^x04[ZP]^x01 You bought Unlimited Clip")
           g_has_unlimited_clip[id] = true
           }
        }
        return PLUGIN_CONTINUE  
}

// 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);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/
Helpful jetpack code
Code:
public OnTouchJetPack(ent, id)
{
	if(is_valid_ent(ent) && is_user_connected(id))
	{
		if(!is_user_alive(id)) return PLUGIN_HANDLED;
		if(bHasJetpack[id] || zp_get_user_zombie(id) || zp_get_user_survivor(id)) return PLUGIN_HANDLED;
		
		entity_set_int(ent, EV_INT_solid, SOLID_NOT)
		remove_entity(ent)
		CreateJetPack(id, 0)
		client_print(id, print_chat, "[ZP] You got a Jetpack, fly like a BOSS. Hold 'JUMP+DUCK' to fly.")
		client_print(id, print_chat, "[ZP] Press mouse 'right-click' to shoot rocket.")
		emit_sound(id, CHAN_STATIC, SoundPickup, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
	
	return PLUGIN_CONTINUE;
}


CreateWorldJetPack(id)
{
	new ent = create_entity("info_target")
	if(!is_valid_ent(ent)) return;
	
	new Float:Aim[3], Float:Origin[3], iColor[3]
	velocity_by_aim(id, 32, Aim)
	entity_get_vector(id, EV_VEC_origin, Origin)
	Origin[0] += 2*Aim[0]
	Origin[1] += 2*Aim[1]
	entity_set_string(ent, EV_SZ_classname, ClassJetpack)
	entity_set_model(ent, ModelJetpack_W)
	#if defined MAKE_JETPACK_BOUNCING
	entity_set_int(ent, EV_INT_movetype, MOVETYPE_BOUNCE)
	#else
	entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
	#endif
	entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
	entity_set_size(ent, Float:{-8.0, -8.0, -8.0}, Float:{8.0, 8.0, 8.0})
	entity_set_float(ent, EV_FL_gravity, 1.25)
	entity_set_vector(ent, EV_VEC_origin, Origin)
	velocity_by_aim(id, 400, Aim)
	entity_set_vector(ent, EV_VEC_velocity, Aim)
}

Last edited by Depresie; 03-05-2015 at 03:11.
Depresie is offline
gfxchris
Member
Join Date: Feb 2016
Old 02-25-2016 , 16:46   Re: [REQ]Drop unlimited clip
Reply With Quote #2

can someone make this plugin ? ;o
gfxchris is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 02-25-2016 , 20:56   Re: [REQ]Drop unlimited clip
Reply With Quote #3

https://forums.alliedmods.net/showthread.php?t=273814
check "addons/amxmodx/scripting/zpnm_extra_unlimited_clip.sma" from the "Plugins" link.
it's not professionally done, but it will do the job for your request.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
gfxchris
Member
Join Date: Feb 2016
Old 02-26-2016 , 09:38   Re: [REQ]Drop unlimited clip
Reply With Quote #4

it's for zpnm ... can u make it compatible with 4.3 ?
gfxchris is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 02-26-2016 , 12:59   Re: [REQ]Drop unlimited clip
Reply With Quote #5

Quote:
Originally Posted by gfxchris View Post
it's for zpnm ... can u make it compatible with 4.3 ?
i currently don't have the time but it should be easy enough to replace the zpnm native with the code from another plugin
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
gfxchris
Member
Join Date: Feb 2016
Old 02-26-2016 , 15:33   Re: [REQ]Drop unlimited clip
Reply With Quote #6

tell me what to change in the .sma , or i'll wait for you till you have freetime
gfxchris is offline
ShooTeR XKy
Member
Join Date: Jul 2014
Location: Palestine
Old 06-09-2016 , 17:36   Re: [REQ]Drop unlimited clip
Reply With Quote #7

Really important to me too
This plugin
ShooTeR XKy 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 00:52.


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