Code:
/****************************************//**************************************/
/* *//* */
/* Deathrun Manager *//* Other Plugins: */
/* by xPaw *//* Semiclip by danielkza */
/* *//* Spray Blocker */
/* Original code: *//* Radio Commands Blocker */
/* by Grim *//* No Roundtimer & Money */
/* *//* */
/****************************************//**************************************/
/** CVars
*
* Turn on/off the plugin
* deathrun_toggle 0/1 <default: 1>
*
* Turn on/off the spray blocker
* deathrun_spray 0/1 <default: 1>
*
* Turn on/off the radio commands blocker
* deathrun_radio 0/1 <default: 1>
*/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#pragma semicolon 1
// Plugin Version
#define VERSION "1.2a"
// Bools
new bool:g_Restart;
new bool:g_Randromized;
new bool:g_FirstRound;
new g_Toggle, g_SprayB, g_RadioB;
new g_Maxplayers, g_msgHideWeapon, g_msgCrosshair, g_msgTeamInfo, g_msgMoney;
#define OFFSET_TEAM 114
enum {
FM_TEAM_UNASSIGNED,
FM_TEAM_T,
FM_TEAM_CT,
FM_TEAM_SPECTATOR,
FM_TEAM_MAX
};
// =======================================================================================
public plugin_init() {
register_plugin("Deathrun Manager", VERSION, "xPaw");
g_Toggle = register_cvar("deathrun_toggle", "1");
g_SprayB = register_cvar("deathrun_spray", "1");
g_RadioB = register_cvar("deathrun_radio", "1");
register_cvar("deathrun_version", VERSION, FCVAR_SERVER);
set_cvar_string("deathrun_version", VERSION);
// Registering Language file
register_dictionary("deathrun.txt");
// Logging Events
register_logevent("eStartRound", 2, "1=Round_Start");
register_logevent("eRandromize", 2, "1=Round_End");
register_event("TextMsg", "eRandromize", "a", "2&#Game_w");
register_event("Money", "eMoney", "b");
register_event("ResetHUD", "eResetHUD", "be");
// Forwards
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
register_forward(FM_StartFrame, "fwStartFrame", 0);
register_forward(FM_AddToFullPack, "fwFullPack", 1);
register_forward(FM_ClientKill, "fwClientKill");
register_forward(FM_CmdStart, "cmdBlockSpray");
// First round // Maxplayers
g_FirstRound = true;
g_Maxplayers = get_maxplayers();
g_msgHideWeapon = get_user_msgid( "HideWeapon" );
g_msgCrosshair = get_user_msgid( "Crosshair" );
g_msgTeamInfo = get_user_msgid( "TeamInfo" );
g_msgMoney = get_user_msgid( "Money" );
// Block all radio commands
register_clcmd("radio1", "cmdBlockRadio");
register_clcmd("radio2", "cmdBlockRadio");
register_clcmd("radio3", "cmdBlockRadio");
register_clcmd("coverme", "cmdBlockRadio");
register_clcmd("takepoint", "cmdBlockRadio");
register_clcmd("holdpos", "cmdBlockRadio");
register_clcmd("regroup", "cmdBlockRadio");
register_clcmd("followme", "cmdBlockRadio");
register_clcmd("takingfire", "cmdBlockRadio");
register_clcmd("go", "cmdBlockRadio");
register_clcmd("fallback", "cmdBlockRadio");
register_clcmd("sticktog", "cmdBlockRadio");
register_clcmd("getinpos", "cmdBlockRadio");
register_clcmd("stormfront", "cmdBlockRadio");
register_clcmd("report", "cmdBlockRadio");
register_clcmd("roger", "cmdBlockRadio");
register_clcmd("enemyspot", "cmdBlockRadio");
register_clcmd("needbackup", "cmdBlockRadio");
register_clcmd("sectorclear", "cmdBlockRadio");
register_clcmd("inposition", "cmdBlockRadio");
register_clcmd("reportingin", "cmdBlockRadio");
register_clcmd("getout", "cmdBlockRadio");
register_clcmd("negative", "cmdBlockRadio");
register_clcmd("enemydown", "cmdBlockRadio");
if( get_pcvar_num(g_Toggle) ) { // only called at new map
// Terrorist Check
set_task(30.0, "eTerrorCheck",_,_,_, "b");
log_amx("[DeathRun] ON.");
} else
log_amx("[DeathRun] OFF.");
}
// =======================================================================================
// Making new Terr
public eRandromize() {
if(get_pcvar_num(g_Toggle) == 0)
return PLUGIN_HANDLED;
if(g_FirstRound || g_Randromized)
return PLUGIN_HANDLED;
g_Randromized = true;
new g_Players;
new indexArray[32];
for(new i=1; i<=g_Maxplayers; i++) {
if(is_user_connected(i)) {
indexArray[g_Players] = i;
g_Players++;
}
if(get_user_team(i) == 1)
fm_set_user_team(i, FM_TEAM_CT);
}
if(g_Players <= 1)
return PLUGIN_HANDLED;
if(g_FirstRound)
return PLUGIN_HANDLED;
new g_ID = indexArray[random_num(0, g_Players - 1)];
if(get_user_team(g_ID) == 2 && is_user_connected(g_ID)) {
new name[32];
get_user_name(g_ID, name, 31);
client_print(0, print_chat, "[Deathrun] %L", LANG_PLAYER, "MSG_NOW_TERR", name);
fm_set_user_team(g_ID, FM_TEAM_T);
} else {
if(g_Restart)
return PLUGIN_HANDLED;
g_Restart = true;
client_print(0, print_chat, "[Deathrun] %L", LANG_PLAYER, "MSG_TOO_LAZY");
eRandromize();
for(new i=0; i<g_Maxplayers; i++)
if(is_user_alive(i) && get_user_team(i) == 2)
fm_user_kill(i);
}
return PLUGIN_HANDLED;
}
// New Round
public eStartRound() {
if(get_pcvar_num(g_Toggle) == 0)
return PLUGIN_HANDLED;
g_Randromized = false;
g_Restart = false;
new g_Players;
for(new i=0; i<g_Maxplayers; i++)
if(is_user_connected(i))
g_Players++;
if(g_Players <= 1)
return PLUGIN_HANDLED;
set_cvar_num("sv_autoteambalance", 0);
set_cvar_num("mp_limitteams", g_Maxplayers);
set_hudmessage(255, 127, 0, -1.0, 0.1, 2, 7.0, 7.0, 0.2, 0.5, -1);
show_hudmessage(0, "%L", LANG_PLAYER, "MSG_PREPARE");
if(g_FirstRound) {
log_amx("[DeathRun] %L", LANG_SERVER, "MSG_STARTING");
client_print(0, print_chat, "[Deathrun] %L", LANG_PLAYER, "MSG_STARTING");
set_cvar_num("sv_restartround", 10);
g_FirstRound = false;
}
return PLUGIN_CONTINUE;
}
// Terrorist check
public eTerrorCheck() {
if(g_FirstRound)
return PLUGIN_HANDLED;
new g_Terrors;
new g_Players;
for(new i=0; i<g_Maxplayers; i++) {
if(get_user_team(i) == 1)
g_Terrors++;
if(is_user_connected(i))
g_Players++;
}
if(g_Players <= 1)
return PLUGIN_HANDLED;
if(g_Terrors == 0) {
if(g_Restart)
return PLUGIN_HANDLED;
g_Restart = true;
client_print(0, print_chat, "[Deathrun] %L", LANG_PLAYER, "MSG_NO_DETECT");
log_amx("[DeathRun] %L", LANG_SERVER, "MSG_NO_DETECT");
eRandromize();
for(new i=0; i<g_Maxplayers; i++)
if(is_user_alive(i) && get_user_team(i) == 2)
fm_user_kill(i);
}
return PLUGIN_CONTINUE;
}
// Remove Timer & Money
public eResetHUD( id ) {
if(!is_user_bot( id )) {
message_begin( MSG_ALL, g_msgHideWeapon, _, id );
write_byte( (1<<4 | 1<<5) );
message_end();
message_begin( MSG_ALL, g_msgCrosshair, _, id );
write_byte( 0 );
message_end();
}
}
public client_disconnect()
eTerrorCheck();
public eMoney( id )
fm_set_user_money(id, 0);
// Lets strip player weapons...
public fwHamPlayerSpawnPost( id ) {
if(!is_user_alive( id ))
return PLUGIN_HANDLED;
fm_strip_user_weapons( id );
fm_give_item(id, "weapon_knife");
fm_give_item(id, "weapon_usp");
fm_give_item(id, "ammo_45acp");
fm_give_item(id, "ammo_45acp");
fm_give_item(id, "ammo_45acp");
fm_give_item(id, "ammo_45acp");
return PLUGIN_CONTINUE;
}
// =======================================================================================
// Block commands
// =======================================================================================
public cmdBlockRadio( id ) {
if(get_pcvar_num(g_RadioB) == 1) {
if(is_user_alive(id))
client_print(id, print_center, "%L", id, "BLOCK_RADIO");
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public fwClientKill( id ) {
if(!is_user_alive(id))
return FMRES_IGNORED;
client_print(id, print_chat, "[Deathrun] You can't kill yourself!");
client_print(id, print_console, "[Deathrun] You can't kill yourself!");
return FMRES_SUPERCEDE;
}
public cmdBlockSpray( id, uc_handle, seed ) {
if(get_pcvar_num(g_SprayB) == 0)
return PLUGIN_HANDLED;
if(get_uc(uc_handle, UC_Impulse) == 201) {
set_uc(uc_handle, UC_Impulse, 0);
client_print(id, print_center, "%L", id, "BLOCK_SPRAY");
return FMRES_HANDLED;
}
return FMRES_IGNORED;
}
// =======================================================================================
// Stocks
// =======================================================================================
stock fm_create_entity(const classname[])
return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname));
stock fm_set_user_team(client, team) {
set_pdata_int(client, OFFSET_TEAM, team);
static const TeamInfo[FM_TEAM_MAX][] = {
"UNASSIGNED",
"TERRORIST",
"CT",
"SPECTATOR"
};
message_begin(MSG_ALL, g_msgTeamInfo);
write_byte(client);
write_string(TeamInfo[team]);
message_end();
}
stock fm_set_user_money ( id, i_Money ) {
set_pdata_int ( id, 115, i_Money );
message_begin ( MSG_ONE, g_msgMoney, _, id );
write_long ( i_Money );
write_byte ( 1 );
message_end ();
}
stock fm_user_kill(index) {
dllfunc(DLLFunc_ClientKill, index);
return 1;
}
stock fm_strip_user_weapons(index) {
new ent = fm_create_entity("player_weaponstrip");
if (!pev_valid(ent))
return 0;
dllfunc(DLLFunc_Spawn, ent);
dllfunc(DLLFunc_Use, ent, index);
engfunc(EngFunc_RemoveEntity, ent);
return 1;
}
stock fm_give_item(index, const item[]) {
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5))
return 0;
new ent = fm_create_entity(item);
if (!pev_valid(ent))
return 0;
new Float:origin[3];
pev(index, pev_origin, origin);
set_pev(ent, pev_origin, origin);
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
dllfunc(DLLFunc_Spawn, ent);
new save = pev(ent, pev_solid);
dllfunc(DLLFunc_Touch, ent, index);
if (pev(ent, pev_solid) != save)
return ent;
engfunc(EngFunc_RemoveEntity, ent);
return -1;
}