GET NO CLIP FOR PRESS CALL BUTTON

Unpaid Requests, Public Plugins
Post Reply
User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 477
Joined: 5 years ago
Location: The Red City ❤
Contact:

Re: GET NO CLIP FOR PRESS CALL BUTTON

#1

Post by z0h1r-LK » 2 years ago

I will make it !

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#2

Post by sPe3doN » 2 years ago

jerb ida ymachi wla la psq ana manich mjrbo, w ida mamchach goli

Code: Select all

#include <zombie_escape>

// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"

// Variables
new bool:g_bButtonUsed = false

// 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_has_unlimited_clip[33]

// Default Values
new const szButtonEnt[][] = 
{
	"grescate_amazonas",
	"tren_escape",
	"escape_assault",
	"tetikleme",
	"gemoroy",
	"a1",
	"llamado_escape",
	"carrex",
	"manager",
	"rescate_jp",
	"mario_escape_final_001",
	"ascensor_escape",
	"multi",
	"escape_final",
	"heli",
	"msilo",
	"trem_ati",
	"heli_escape",
	"heli1",
	"final",
	"tren"
}

new Array:g_szButtonName

public plugin_init()
{
	register_plugin("Unlimited Clip For Press Call Button", "1.0", "DZ")

	// Hams
	RegisterHam(Ham_Use, "func_button", "Fw_ButtonUsed_Post", 1)

	register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
}

public Fw_ButtonUsed_Post(iEnt, iCallerID)
{
	new szTargetName[51], szCallerName[32]
	
	pev(iEnt, pev_target, szTargetName, charsmax(szTargetName))
	
	for (new iIndex = 0; iIndex < ArraySize(g_szButtonName); iIndex++)
	{
		new szButtonName[51]
		ArrayGetString(g_szButtonName, iIndex, szButtonName, charsmax(szButtonName))
		
		if (equal(szTargetName, szButtonName) && !g_bButtonUsed)
		{
			get_user_name(iCallerID, szCallerName, charsmax(szCallerName))
			ze_colored_print(0, "!tEscape button was used by!y:!g %s!y.", szCallerName)
			g_has_unlimited_clip[iCallerID] = true
			ze_colored_print(iCallerID, "!yYou got Free !gUnlimited Clip !yFor Pressing Escape Button!y!")
			g_bButtonUsed = true
			break;
		}
	}
}

// Reset flags for all players on newround
public ze_user_humanized(id)
{
	g_has_unlimited_clip[id] = false;
}

public plugin_precache()
{
	// Initialize arrays
	g_szButtonName = ArrayCreate(51, 1)
	
	// Load from external file
	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Escape Button Message", "Button Names", g_szButtonName)
	
	// If we couldn't load from file, use and save default ones
	new iIndex

	if (ArraySize(g_szButtonName) == 0)
	{
		for (iIndex = 0; iIndex < sizeof szButtonEnt; iIndex++)
			ArrayPushString(g_szButtonName, szButtonEnt[iIndex])
		
		// If not found .ini File Create it and save default values in it
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Escape Button Message", "Button Names", g_szButtonName)
	}
}

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

public ze_game_started()
{
	g_bButtonUsed = false
}

// 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);
}
Image

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 477
Joined: 5 years ago
Location: The Red City ❤
Contact:

#3

Post by z0h1r-LK » 2 years ago

Check this: viewtopic.php?f=15&t=4058&p=12337#p12337
It's working on all maps !

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 11 guests