Code:
/*
Knife Round
===========
Description
After every X rounds , an special knife round will be occur.
*/
#include <amxmodx>
#include <fun>
#include <engine>
// Red , Green , Blue
new const HUD_COLOR[3] = {0 , 255 , 0}
// Hud X position
const Float: HUD_POSITION_X = -1.0
// Hud Y position
const Float: HUD_POSITION_Y = 0.25
// Hud display time
const HOLD_TIME = 5
// buy menu commands
new const g_szBuyCmds[ ][ ] = {
"usp", "glock", "deagle", "p228", "elites", "fn57", "m3", "xm1014", "mp5", "tmp", "p90", "mac10", "ump45", "ak47",
"galil", "famas", "sg552", "m4a1", "aug", "scout", "awp", "g3sg1", "sg550", "m249", "vest", "vesthelm", "flash", "hegren",
"sgren", "defuser", "nvgs", "shield", "primammo", "secammo", "km45", "9x19mm", "nighthawk", "228compact", "12gauge",
"autoshotgun", "smg", "mp", "c90", "cv47", "defender", "clarion", "krieg552", "bullpup", "magnum", "d3au1", "krieg550",
"buyammo1", "buyammo2"
}
new const VERSION[] = "1.0"
// players class (needed when we want to block weapon pick up)
new const PLAYER_CLASS[] = "player"
// variable to increase value
new g_knife_round
// is knife round ?
new bool: g_is_knife_round
// cvar
new cvar_knife_round
public plugin_init()
{
register_plugin("Knife Round" , VERSION , "LearninG")
// looping through buy commands
for (new i; i<sizeof g_szBuyCmds; i++)
{
register_clcmd(g_szBuyCmds[i] , "block_buy")
}
// called when user touch weapons , shield ...
register_touch("armoury_entity", PLAYER_CLASS, "PlayerTouchArmoury")
register_touch("weaponbox", PLAYER_CLASS, "PlayerTouchWeaponBox")
register_touch("weapon_shield", PLAYER_CLASS, "PlayerTouchShield")
// event_new_round
register_logevent("event_new_round",2,"0=World triggered","1=Round_Start")
register_event( "30" , "event_intermission" , "a" )
register_cvar("knife_round_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY)
// store cvar in variable
cvar_knife_round = register_cvar("knife_round_delay" , "15")
}
// called when new round begins
public event_new_round()
{
g_is_knife_round = false
// increase variable value by 1
g_knife_round++
// variable value reached our cvar number ?
if (g_knife_round == get_pcvar_num(cvar_knife_round))
{
// Start round
g_is_knife_round = true
g_knife_round = 0
// looping through all connected players
new players[32], num
get_players(players, num, "a")
for( --num; num >= 0; num-- )
{
// take away players weapon
strip_user_weapons(players[num])
// give them a knife
give_item(players[num] , "weapon_knife")
// set our hud message and show it to them.
set_hudmessage(HUD_COLOR[0] , HUD_COLOR[1] , HUD_COLOR[2] , HUD_POSITION_X , HUD_POSITION_Y , 0, 8.0, 6.0, 0.3, 0.3, HOLD_TIME)
show_hudmessage(players[num] , "Knife Round!!!")
}
}
}
public block_buy()
{
// is knife round ?
if (g_is_knife_round)
{
// block buy commands
return PLUGIN_HANDLED
}
// allow buy commands
return PLUGIN_CONTINUE
}
public PlayerTouchArmoury(ent, id)
{
if (g_is_knife_round)
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public PlayerTouchWeaponBox(ent, id)
{
// player has touched a weapon , when round is knife_round
if (g_is_knife_round)
{
// block weapon pickup
return PLUGIN_HANDLED
}
// allow pick up
return PLUGIN_CONTINUE
}
// player has touched shield.
public PlayerTouchShield(ent, id)
{
if (g_is_knife_round)
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public event_intermission()
{
g_is_knife_round = false
g_knife_round = 0
}
are you using reHlds ? (if yes , i'm not sure if it will work )