Страница 1 от 2

Only 1 HE Bomb per Round

Публикувано на: 17 Май 2019, 22:08
от Infamous2018
Hello, can anyone create an Plugin that an Player is allowed only to use ONE HE Bomb per Round? need it for my Poolday Server. It would be great. THX

Maybe that they get an message like: "You are allowed to use only 1 Bomb per Round"

Only 1 HE Bomb per Round

Публикувано на: 18 Май 2019, 05:51
от blazz3rzbg
Have you searched ? :P You can simply try this https://forums.alliedmods.net/showthread.php?t=179443

Only 1 HE Bomb per Round

Публикувано на: 18 Май 2019, 12:12
от Infamous2018
This Link blocks only the Buying Bombs. But poolday have in Pool multiple Bombs. Thats the reason why i am searching an Plugin who allow only one bomb per round.

Добавено преди 46 минути 52 секунди:
i tested ur link and it dont work.

Only 1 HE Bomb per Round

Публикувано на: 20 Май 2019, 02:12
от OciXCrom

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define m_pPlayer 41
#define m_flNextPrimaryAttack 46
#define XO_WEAPON 4

new const GRENADE_LIMIT = 1
new g_iThrownGrenades[33]

public plugin_init()
{
	register_plugin("HE Grenade Limit", "1.0", "OciXCrom")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_hegrenade", "PreThrowHe", 0)
	register_logevent("OnRoundStart", 2, "0=World triggered", "1=Round_Start")
}

public client_putinserver(id)
	reset_limit(id)

public OnRoundStart()
{
    arrayset(g_iThrownGrenades, 0, sizeof(g_iThrownGrenades))
}

public PreThrowHe(iWeapon)
{
	new id = get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPON)

	if(g_iThrownGrenades[id]++ >= GRENADE_LIMIT)
	{
		client_print(id, print_center, "You can throw only %i HE grenade per spawn", GRENADE_LIMIT)
		set_pdata_float(iWeapon, m_flNextPrimaryAttack, 1.0, XO_WEAPON)
		return HAM_SUPERCEDE
	}

	return HAM_IGNORED
}

reset_limit(id)
	g_iThrownGrenades[id] = 0

Only 1 HE Bomb per Round

Публикувано на: 20 Май 2019, 02:35
от blazz3rzbg
OciXCrom написа: 20 Май 2019, 02:12

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define m_pPlayer 41
#define m_flNextPrimaryAttack 46
#define XO_WEAPON 4

new const GRENADE_LIMIT = 1
new g_iThrownGrenades[33]

public plugin_init()
{
	register_plugin("HE Grenade Limit", "1.0", "OciXCrom @ Skype")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_hegrenade", "PreThrowHe", 0)
	register_logevent("OnRoundStart", 2, "0=World triggered", "1=Round_Start")
}

public client_putinserver(id)
	reset_limit(id)

public OnRoundStart()
{
    arrayset(g_iThrownGrenades, 0, sizeof(g_iThrownGrenades))
}

public PreThrowHe(iWeapon)
{
	new id = get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPON)

	if(g_iThrownGrenades[id] == GRENADE_LIMIT)
	{
		client_print(id, print_center, "You can throw only %i HE grenade per spawn", GRENADE_LIMIT)
		set_pdata_float(iWeapon, m_flNextPrimaryAttack, 1.0, XO_WEAPON)
		return HAM_SUPERCEDE
	}

	return HAM_IGNORED
}

reset_limit(id)
	g_iThrownGrenades[id] = 0
sizeof(g_iThrownGrenades) ? ? ?

I think it should be

sizeof g_iThrownGrenades

Not a big deal but I think its more correct that way.

Only 1 HE Bomb per Round

Публикувано на: 20 Май 2019, 02:57
от OciXCrom
It's the same thing. You can even do:

register_plugin "HE Grenade Limit", "1.0", "OciXCrom"

... clearly we aren't using this "style" anywhere, so why should we do it with sizeof? Brackets in functions are optional.

Only 1 HE Bomb per Round

Публикувано на: 20 Май 2019, 04:46
от blazz3rzbg
OciXCrom написа: 20 Май 2019, 02:57 It's the same thing. You can even do:

register_plugin "HE Grenade Limit", "1.0", "OciXCrom"

... clearly we aren't using this "style" anywhere, so why should we do it with sizeof? Brackets in functions are optional.
As I know sizeof isnt a function so () will work fine but without brackets is more correct.
Depends on your style as you said.. Just wanted to mention it.

Only 1 HE Bomb per Round

Публикувано на: 20 Май 2019, 16:20
от OciXCrom
It is a function, but not from AMXX itself. It's the same as if, for and the other ones. But yeah, it doesn't really matter as it's just my prefered style.

Only 1 HE Bomb per Round

Публикувано на: 20 Май 2019, 20:27
от Infamous2018
THX - I will test the Plugin and let u know if works or not.

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define m_pPlayer 41
#define m_flNextPrimaryAttack 46
#define XO_WEAPON 4

new const GRENADE_LIMIT = 1
new g_iThrownGrenades[33]

public plugin_init()
{
	register_plugin("HE Grenade Limit", "1.0", "OciXCrom @ Skype")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_hegrenade", "PreThrowHe", 0)
	register_logevent("OnRoundStart", 2, "0=World triggered", "1=Round_Start")
}

public client_putinserver(id)
	reset_limit(id)

public OnRoundStart()
{
    arrayset(g_iThrownGrenades, 0, sizeof(g_iThrownGrenades))
}

public PreThrowHe(iWeapon)
{
	new id = get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPON)

	if(g_iThrownGrenades[id] == GRENADE_LIMIT)
	{
		client_print(id, print_center, "You can throw only %i HE grenade per spawn", GRENADE_LIMIT)
		set_pdata_float(iWeapon, m_flNextPrimaryAttack, 1.0, XO_WEAPON)
		return HAM_SUPERCEDE
	}

	return HAM_IGNORED
}

reset_limit(id)
	g_iThrownGrenades[id] = 0
	
This one dont work. When i jump in the pool i can use all bombs one by one :(

Only 1 HE Bomb per Round

Публикувано на: 20 Май 2019, 21:25
от OciXCrom
I edited the code, try now.