Raised This Month: $32 Target: $400
 8% 

Grenades after kill


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IoNut1290
Junior Member
Join Date: Oct 2019
Location: Newcastle
Old 01-17-2021 , 06:43   Grenades after kill
Reply With Quote #1

Hello

I tried to search but only found Award Nades topic. That one gives you HE grenades after Headshot/weapon or knife kill . I was looking for a plugin that gives you HE grenade after a number of kills (for ex you kill 4 in a row and you get an extra HE )

Searched a lot on the forum but didn't find this one.

Can someone help me with a link or a source ?

Thanks in advance.
IoNut1290 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-18-2021 , 10:42   Re: Grenades after kill
Reply With Quote #2

Untested
I've added a cvar he_min_kills

Code:
#include <amxmodx>
#include <cstrike>
#include <fun>

#if !defined MAX_PLAYERS
	#define MAX_PLAYERS 32
#endif

new g_CvarHeMinKills
new g_MsgAmmoPickup
new g_PlayerKills[MAX_PLAYERS+1]


public plugin_init()
{
	register_plugin("Plugin", "Version", "Author")

	register_event("DeathMsg", "EventDeathMsg", "a")
	register_event("HLTV", "EventNewRound", "a", "1=0", "2=0")

	g_CvarHeMinKills = register_cvar("he_min_kills", "4")

	g_MsgAmmoPickup = get_user_msgid("AmmoPickup")
}

public plugin_precache()
{
	precache_sound("items/gunpickup2.wav")
}

public EventDeathMsg()
{
	new attacker = read_data(1)
	new victim = read_data(2)

	if (!is_user_alive(attacker))
		return

	if (++g_PlayerKills[attacker] >= get_pcvar_num(g_CvarHeMinKills))
	{
		if (user_has_weapon(attacker, CSW_HEGRENADE))
		{
			cs_set_user_bpammo(attacker, CSW_HEGRENADE, cs_get_user_bpammo(attacker, CSW_HEGRENADE) + 1)

			message_begin(MSG_ONE, g_MsgAmmoPickup, _, attacker)
			write_byte(12) // Ammo ID
			write_byte(1) // Amount
			message_end()

			emit_sound(attacker, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		}
		else
			give_item(attacker, "weapon_hegrenade")

		g_PlayerKills[attacker] = 0
	}
}

public EventNewRound()
{
	arrayset(g_PlayerKills, 0, sizeof g_PlayerKills)
}
__________________








CrazY. is offline
IoNut1290
Junior Member
Join Date: Oct 2019
Location: Newcastle
Old 01-20-2021 , 05:38   Re: Grenades after kill
Reply With Quote #3

Hello CraZy

Thanks for your help. I've tested your plugin and set the cvar on 1,2 and 3 . Sometimes it gives and sometimes won't. Sometimes gives after 1 kill and sometimes after 3 ( when set to 3 )
IoNut1290 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-21-2021 , 14:46   Re: Grenades after kill
Reply With Quote #4

That's weird, did some tests on home server with bots and seems to be working.
I have added two messages to debug the plugin. One will print the number of kills and how much is needed to get a HE and the second one will just warn you when you get the grenade.

Code:
#include <amxmodx>
#include <cstrike>
#include <fun>

#if !defined MAX_PLAYERS
	#define MAX_PLAYERS 32
#endif

new g_CvarHeMinKills
new g_MsgAmmoPickup
new g_PlayerKills[MAX_PLAYERS+1]


public plugin_init()
{
	register_plugin("Plugin", "Version", "Author")

	register_event("DeathMsg", "EventDeathMsg", "a")
	register_event("HLTV", "EventNewRound", "a", "1=0", "2=0")

	g_CvarHeMinKills = register_cvar("he_min_kills", "3")

	g_MsgAmmoPickup = get_user_msgid("AmmoPickup")
}

public plugin_precache()
{
	precache_sound("items/gunpickup2.wav")
}

public EventDeathMsg()
{
	new attacker = read_data(1)
	//new victim = read_data(2)

	if (!is_user_alive(attacker))
		return

	g_PlayerKills[attacker] += 1
	client_print(attacker, print_chat, "DEBUG --- number of kills: %d, required: %d", g_PlayerKills[attacker], get_pcvar_num(g_CvarHeMinKills))

	if (g_PlayerKills[attacker] >= get_pcvar_num(g_CvarHeMinKills))
	{
		if (user_has_weapon(attacker, CSW_HEGRENADE))
		{
			cs_set_user_bpammo(attacker, CSW_HEGRENADE, cs_get_user_bpammo(attacker, CSW_HEGRENADE) + 1)

			message_begin(MSG_ONE, g_MsgAmmoPickup, _, attacker)
			write_byte(12) // Ammo ID
			write_byte(1) // Amount
			message_end()

			emit_sound(attacker, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		}
		else
		{
			give_item(attacker, "weapon_hegrenade")
		}

		client_print(attacker, print_chat, "DEBUG --- give grenade")

		g_PlayerKills[attacker] = 0
	}
}

public EventNewRound()
{
	arrayset(g_PlayerKills, 0, sizeof g_PlayerKills)
}
__________________








CrazY. is offline
IoNut1290
Junior Member
Join Date: Oct 2019
Location: Newcastle
Old 01-21-2021 , 15:52   Re: Grenades after kill
Reply With Quote #5

Yes

Now it works fine <3

Before,cvar was set to 3 and after 3 kills was giving 2 HE grenades, set to 5 and was giving even after 2 kills .

Now works fine

Thank you <3

Later Edit : on awp india for example it gives you 2 HE after the number of kills set :-?

Last edited by IoNut1290; 01-21-2021 at 16:25.
IoNut1290 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-22-2021 , 07:19   Re: Grenades after kill
Reply With Quote #6

It shouldn't do that. Did some tests on the same map and I didn't noticed the problem.
Make sure you've not enabled two of the same plugin by mistake
__________________








CrazY. 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 22:41.


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