PDA

View Full Version : When someone kills with a headshot to give him a HE grenade.


.:cs.stambeto:.
07-18-2012, 10:54
Can someone write me the following plugin when someone kills someone with headshot to give him a HE grenade.

isotonic
07-21-2012, 10:19
Do you still need it?

.:cs.stambeto:.
07-21-2012, 11:53
Do you still need it?
YES

pokemonmaster
07-21-2012, 12:37
You can change the number if the grenades given by changing the cvar hs_grenbonus_num (by default it is set to 1 grenade)

#include <amxmodx>
#include <fun>

new const PLUGIN[] = "HeadShot Grenade bonus"
new const AUTHOR[] = "Khalid"
new const VERSION[] = "1.0"

new g_pGrenNum

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "eDeath", "a", "1!=2")
g_pGrenNum = register_cvar("hs_grenbonus_num", "1")
}

public eDeath()
{
new IsHeadShot, iKillerId

IsHeadShot = read_data(3)
if( IsHeadShot == 1 )
{
iKillerId = read_data(1)

new gren
gren = get_pcvar_num(g_pGrenNum)

switch(gren)
{
case 0:
return PLUGIN_HANDLED

case 1:
give_item(iKillerId, "weapon_hegren")

default:
{
for(new i; i <= gren; i++)
{
give_item(iKillerId, "weapon_gren")
}
}
}
}
return PLUGIN_HANDLED
}

.:cs.stambeto:.
07-21-2012, 13:24
L 07/21/2012 - 20:23:04: [FUN] Item "weapon_hegren" failed to create
L 07/21/2012 - 20:23:04: [AMXX] Displaying debug trace (plugin "granade.amxx")
L 07/21/2012 - 20:23:04: [AMXX] Run time error 10: native error (native "give_item")
L 07/21/2012 - 20:23:04: [AMXX] [0] granade.sma::eDeath (line 32)

ConnorMcLeod
07-21-2012, 14:07
#include <amxmodx>
#include <fun>

#define VERSION "0.0.1"
#define PLUGIN "He Bonus on HeadShots"

new g_iMaxPlayers

public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
register_event("DeathMsg", "Event_DeathMsg_HeadShot", "a", "1>0", "3=1")
g_iMaxPlayers = get_maxplayers()
}

public Event_DeathMsg_HeadShot()
{
new id = read_data(1)
if( id <= g_iMaxPlayers && user_has_weapon(id, CSW_HEGRENADE) ) // user_has_weapon should return 0 on dead players
{
give_item(id, "weapon_hegrenade")
}
}

.:cs.stambeto:.
07-21-2012, 14:17
#include <amxmodx>
#include <fun>

#define VERSION "0.0.1"
#define PLUGIN "He Bonus on HeadShots"

new g_iMaxPlayers

public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
register_event("DeathMsg", "Event_DeathMsg_HeadShot", "a", "1>0", "3=1")
g_iMaxPlayers = get_maxplayers()
}

public Event_DeathMsg_HeadShot()
{
new id = read_data(1)
if( id <= g_iMaxPlayers && user_has_weapon(id, CSW_HEGRENADE) ) // user_has_weapon should return 0 on dead players
{
give_item(id, "weapon_hegrenade")
}
}
I do not know but why not give me HE grenade to ask you with all weapons is done by killing someone with a head to give a grenade.

quilhos
07-21-2012, 15:15
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fun>

#define PLUGIN "HS give HE"
#define VERSION "1.0"
#define AUTHOR "Freestyle"

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "deadmsg", "a");
}

public deadmsg()
{
new kid = read_data(1);

if(read_data(3))
{
give_item(kid, "weapon_hegrenade");
}
}


I think this would work.

.:cs.stambeto:.
07-21-2012, 16:19
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fun>

#define PLUGIN "HS give HE"
#define VERSION "1.0"
#define AUTHOR "Freestyle"

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "deadmsg", "a");
}

public deadmsg()
{
new kid = read_data(1);

if(read_data(3))
{
give_item(kid, "weapon_hegrenade");
}
}
I think this would work.
L 07/21/2012 - 23:18:30: [AMXX] Displaying debug trace (plugin "granade.amxx")
L 07/21/2012 - 23:18:30: [AMXX] Run time error 3: stack error


Only this plugin works on my csdm can I get it lighten code

ConnorMcLeod
07-21-2012, 16:53
Remove :
&& user_has_weapon(id, CSW_HEGRENADE)

if you want to allow more than 1 grenade.