Spoiler
/*
Nade giver 1.2 by Lulu the hero
This plugin automatically gives a every alive player grenades( amounts according to cvars )
Counter Strike required
Can be used with any plugin(the most fun is at deathmatch games)
Cvars:
nadegive_he,nadegive_flash,nadegive_smoke - amount of grenades to give
nadegive_delay - afterspawn delay of grenade giving
[1.2]Optimized code by: ConnorMcLeod - thanks!
[1.1]Changed event ResetHud(to detect spawn) to Ham_Spawn
[1.0]Main code created
*/
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#pragma semicolon 1
//defaults cvar values - DON'T EDIT THIS HERE, USE THE CONFIG FILE(amxx.cfg)!
#define d_delay "0.5"
#define d_givehe "2"
#define d_giveflash "0"
#define d_givesmoke "0"
//pcvars
new g_givedelay; //delay from spawn in seconds
enum _:Nades {
HeGrenade,
FlashBang,
SmokeGrenade
}
new g_pCvar[Nades];
public plugin_init()
{
register_plugin("NadeGiver","1.2","Lulu the hero");
//let's make cvars
g_givedelay = register_cvar("nadegive_delay",d_delay);
g_pCvar[HeGrenade] = register_cvar("nadegive_he",d_givehe);
g_pCvar[FlashBang] = register_cvar("nadegive_flash",d_giveflash);
g_pCvar[SmokeGrenade] = register_cvar("nadegive_smoke",d_givesmoke);
//hooking the spawning event
RegisterHam(Ham_Spawn,"player","hamPlayerSpawned",1);
}
//someone spawned
public hamPlayerSpawned(id)
{
if(!is_user_alive(id))
return;
//set the grenade giving a delay
new Float:flDelay = get_pcvar_float(g_givedelay);
remove_task(id);
if( flDelay )
{
set_task(flDelay,"GiveNades",id);
}
else
{
GiveNades(id);
}
}
//let's give some stuffs
public GiveNades( id )
{
if(cs_get_user_team(id) == CS_TEAM_CT)
{
return;
}
static const szNadesNames[Nades][] = {
"weapon_hegrenade",
"weapon_flashbang",
"weapon_smokegrenade"
};
static const iNadesId[Nades] = {
CSW_HEGRENADE,
CSW_FLASHBANG,
CSW_SMOKEGRENADE
};
new iBpAmmo, iNadeAmount, iId;
for(new i; i<Nades; i++)
{
iNadeAmount = get_pcvar_num(g_pCvar[i]);
if( iNadeAmount > 0 )
{
iId = iNadesId[i]; // value used twice, so cache it's value in a var
iBpAmmo = cs_get_user_bpammo(id, iId);
if( !iBpAmmo )
{
give_item(id, szNadesNames[i]);
}
cs_set_user_bpammo(id, iId, iNadeAmount);
}
}
}lub to :
Spoiler
/*
Nade giver 1.2 by Lulu the hero
This plugin automatically gives a every alive player grenades( amounts according to cvars )
Counter Strike required
Can be used with any plugin(the most fun is at deathmatch games)
Cvars:
nadegive_he,nadegive_flash,nadegive_smoke - amount of grenades to give
nadegive_delay - afterspawn delay of grenade giving
[1.2]Optimized code by: ConnorMcLeod - thanks!
[1.1]Changed event ResetHud(to detect spawn) to Ham_Spawn
[1.0]Main code created
*/
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#pragma semicolon 1
//defaults cvar values - DON'T EDIT THIS HERE, USE THE CONFIG FILE(amxx.cfg)!
#define d_delay "0.5"
#define d_givehe "2"
#define d_giveflash "0"
#define d_givesmoke "0"
//pcvars
new g_givedelay; //delay from spawn in seconds
enum _:Nades {
HeGrenade,
FlashBang,
SmokeGrenade
}
new g_pCvar[Nades];
public plugin_init()
{
register_plugin("NadeGiver","1.2","Lulu the hero");
//let's make cvars
g_givedelay = register_cvar("nadegive_delay",d_delay);
g_pCvar[HeGrenade] = register_cvar("nadegive_he",d_givehe);
g_pCvar[FlashBang] = register_cvar("nadegive_flash",d_giveflash);
g_pCvar[SmokeGrenade] = register_cvar("nadegive_smoke",d_givesmoke);
//hooking the spawning event
RegisterHam(Ham_Spawn,"player","hamPlayerSpawned",1);
}
//someone spawned
public hamPlayerSpawned(id)
{
if(!is_user_alive(id))
return;
//set the grenade giving a delay
new Float:flDelay = get_pcvar_float(g_givedelay);
remove_task(id);
if( flDelay )
{
set_task(flDelay,"GiveNades",id);
}
else
{
GiveNades(id);
}
}
//let's give some stuffs
public GiveNades( id )
{
if(get_user_team(id) == 2)
{
return;
}
static const szNadesNames[Nades][] = {
"weapon_hegrenade",
"weapon_flashbang",
"weapon_smokegrenade"
};
static const iNadesId[Nades] = {
CSW_HEGRENADE,
CSW_FLASHBANG,
CSW_SMOKEGRENADE
};
new iBpAmmo, iNadeAmount, iId;
for(new i; i<Nades; i++)
{
iNadeAmount = get_pcvar_num(g_pCvar[i]);
if( iNadeAmount > 0 )
{
iId = iNadesId[i]; // value used twice, so cache it's value in a var
iBpAmmo = cs_get_user_bpammo(id, iId);
if( !iBpAmmo )
{
give_item(id, szNadesNames[i]);
}
cs_set_user_bpammo(id, iId, iNadeAmount);
}
}
}

Dodatki SourceMod




Moja zawartość
Mężczyzna