2009-05-14 02:28:26 +02:00
/*
* ============================================================================
*
2008-10-04 22:59:11 +02:00
* Zombie : Reloaded
2009-05-14 02:28:26 +02:00
*
2009-06-12 05:51:26 +02:00
* File : commands . inc
* Type : Core
* Description : Console command creation and hooking .
*
* Copyright ( C ) 2009 Greyscale , Richard Helgeby
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2009-05-14 02:28:26 +02:00
*
* ============================================================================
*/
/**
* Commands are created / hooked .
2008-10-04 22:59:11 +02:00
*/
2009-05-14 02:28:26 +02:00
CommandsInit ()
{
// Forward event to modules. (create commands)
2009-05-18 06:26:13 +02:00
ConfigOnCommandsCreate ();
2009-06-07 17:51:37 +02:00
LogOnCommandsCreate ();
2009-05-21 07:13:51 +02:00
ClassOnCommandsCreate ();
2009-05-14 02:28:26 +02:00
WeaponsOnCommandsCreate ();
2009-06-15 21:43:06 +02:00
InfectOnCommandsCreate ();
2009-06-17 23:32:46 +02:00
MenuOnCommandsCreate ();
ZAdminOnCommandsCreate ();
2009-06-22 06:08:26 +02:00
ZCookiesOnCommandsCreate ();
2009-06-17 23:32:46 +02:00
ZSpawnOnCommandsCreate ();
ZTeleOnCommandsCreate ();
ZHPOnCommandsCreate ();
2009-05-30 04:17:01 +02:00
VolOnCommandsCreate ();
2009-05-14 02:28:26 +02:00
// Forward event to modules. (hook commands)
ClassOnCommandsHook ();
DamageOnCommandsHook ();
}
/* CreateCommands ()
2008-10-04 22:59:11 +02:00
{
RegAdminCmd ( " zr_infect " , Command_Infect , ADMFLAG_GENERIC , " Infects the specified player " );
RegAdminCmd ( " zr_spawn " , Command_Respawn , ADMFLAG_GENERIC , " Respawns the specified player following auto-respawning rules " );
2009-04-09 06:49:15 +02:00
2009-04-14 23:16:31 +02:00
//RegAdminCmd("zr_set_class_knockback", Command_SetClassKnockback, ADMFLAG_GENERIC, "Sets the knockback to the specified class. Usage: zr_set_class_knockback <class name> <value>");
//RegAdminCmd("zr_get_class_knockback", Command_GetClassKnockback, ADMFLAG_GENERIC, "Gets the knockback to the specified class. Usage: zr_get_class_knockback <class name>");
2009-04-09 06:49:15 +02:00
2008-10-11 17:17:51 +02:00
RegAdminCmd ( " zr_admin " , Command_AdminMenu , ADMFLAG_GENERIC , " Displays the admin menu for Zombie: Reloaded. " );
2009-04-14 23:16:31 +02:00
//RegAdminCmd("zr_knockback_m", Command_KnockbackMMenu, ADMFLAG_GENERIC, "Displays the knockback multiplier menu.");
2009-01-19 22:45:58 +01:00
RegAdminCmd ( " zr_anticamp_create_volume " , Command_AnticampCreateVolume , ADMFLAG_GENERIC , " Creates a rectangular hurt volume between two points. Usage: ht_create_volume <damage> <interval> <x1> <y1> <z1> <x2> <y2> <z2> " );
RegAdminCmd ( " zr_anticamp_remove_volume " , Command_AnticampRemoveVolume , ADMFLAG_GENERIC , " Removes a volume. Use zr_anticamp_list to list volumes. Usage: zr_anticamp_remove_volume <volume index> " );
RegAdminCmd ( " zr_anticamp_list " , Command_AnticampList , ADMFLAG_GENERIC , " List current volumes. " );
2009-01-31 20:48:56 +01:00
RegConsoleCmd ( " zr_log_flags " , Command_LogFlags , " List available logging flags. " );
2009-05-14 02:28:26 +02:00
} */
2008-10-04 22:59:11 +02:00
2009-05-14 02:28:26 +02:00
/* public Action : Command_Infect ( client , argc )
2008-10-04 22:59:11 +02:00
{
2009-04-20 02:56:26 +02:00
new bool : enabled = GetConVarBool ( g_hCvarsList [ CVAR_ENABLE ]);
2008-10-04 22:59:11 +02:00
if ( argc < 1 || ! enabled )
{
return Plugin_Handled ;
}
decl String : arg1 [ 32 ];
GetCmdArg ( 1 , arg1 , sizeof ( arg1 ));
2009-02-02 01:56:53 +01:00
decl String : target_name_list [ MAX_TARGET_LENGTH ];
2008-10-04 22:59:11 +02:00
new targets [ MAXPLAYERS ];
new bool : tn_is_ml ;
2009-04-09 06:49:15 +02:00
new tcount = ProcessTargetString ( arg1 , client , targets , MAXPLAYERS , COMMAND_FILTER_ALIVE , target_name_list , sizeof ( target_name_list ), tn_is_ml );
2008-10-04 22:59:11 +02:00
if ( tcount <= 0 )
{
ReplyToTargetError ( client , tcount );
return Plugin_Handled ;
}
2009-04-09 06:49:15 +02:00
decl String : target_name [ 64 ];
decl String : client_name [ 64 ];
2009-02-02 01:56:53 +01:00
if ( client > 0 )
{
GetClientName ( client , client_name , sizeof ( client_name ));
}
else
{
client_name = " Console \0 " ;
}
2008-10-04 22:59:11 +02:00
for ( new x = 0 ; x < tcount ; x ++ )
{
2009-06-15 21:43:06 +02:00
InfectHumanToZombie ( targets [ x ]);
2009-04-20 05:43:20 +02:00
if ( LogCheckFlag ( LOG_GAME_EVENTS , LOG_MODULE_COMMANDS ))
2009-02-02 01:56:53 +01:00
{
GetClientName ( targets [ x ], target_name , sizeof ( target_name ));
2009-04-20 05:43:20 +02:00
LogMessageFormatted ( client , " admin commands " , " infect " , " \" %s \" infected \" %s \" . " , true , client_name , target_name );
2009-02-02 01:56:53 +01:00
}
2008-10-04 22:59:11 +02:00
}
return Plugin_Handled ;
}
public Action : Command_Respawn ( client , argc )
{
2009-04-20 02:56:26 +02:00
new bool : enabled = GetConVarBool ( g_hCvarsList [ CVAR_ENABLE ]);
2008-10-04 22:59:11 +02:00
if ( argc < 1 || ! enabled )
{
return Plugin_Handled ;
}
decl String : arg1 [ 32 ];
GetCmdArg ( 1 , arg1 , sizeof ( arg1 ));
2009-02-02 01:56:53 +01:00
decl String : target_name_list [ MAX_TARGET_LENGTH ];
2008-10-04 22:59:11 +02:00
new targets [ MAXPLAYERS ];
new bool : tn_is_ml ;
2009-04-09 06:49:15 +02:00
new tcount = ProcessTargetString ( arg1 , client , targets , MAXPLAYERS , COMMAND_FILTER_DEAD , target_name_list , sizeof ( target_name_list ), tn_is_ml );
2008-10-04 22:59:11 +02:00
if ( tcount <= 0 )
{
ReplyToTargetError ( client , tcount );
return Plugin_Handled ;
}
2009-04-09 06:49:15 +02:00
decl String : client_name [ 64 ];
decl String : target_name [ 64 ];
2009-02-02 01:56:53 +01:00
if ( client > 0 )
{
GetClientName ( client , client_name , sizeof ( client_name ));
}
else
{
client_name = " Console \0 " ;
}
2008-10-29 22:02:46 +01:00
new team ;
2008-10-04 22:59:11 +02:00
for ( new x = 0 ; x < tcount ; x ++ )
{
2008-10-31 18:57:14 +01:00
team = GetClientTeam ( targets [ x ]);
2008-10-29 22:02:46 +01:00
if ( team == CS_TEAM_T || team == CS_TEAM_CT )
{
2009-04-20 05:43:20 +02:00
if ( LogCheckFlag ( LOG_GAME_EVENTS , LOG_MODULE_COMMANDS ))
2009-02-02 01:56:53 +01:00
{
GetClientName ( targets [ x ], target_name , sizeof ( target_name ));
2009-04-20 05:43:20 +02:00
LogMessageFormatted ( targets [ x ], " admin commands " , " spawn " , " \" %s \" spawned player \" %s \" . " , true , client_name , target_name );
2009-02-02 01:56:53 +01:00
}
2009-04-09 06:49:15 +02:00
2009-04-16 05:30:26 +02:00
RespawnSpawnClient ( targets [ x ]);
2008-10-29 22:02:46 +01:00
}
2008-10-04 22:59:11 +02:00
}
return Plugin_Handled ;
2009-05-14 02:28:26 +02:00
} */
2008-10-04 22:59:11 +02:00
2009-05-14 02:28:26 +02:00
/* public Action : Command_AdminMenu ( client , argc )
2008-10-11 17:17:51 +02:00
{
2009-04-24 05:02:19 +02:00
if ( ZRIsClientValid ( client ))
2008-10-11 17:17:51 +02:00
{
ZRAdminMenu ( client );
}
else
{
2009-04-14 23:16:31 +02:00
// BAD!
// ReplyToCommand(client, "This menu cannot be used from the console.");
2008-10-11 17:17:51 +02:00
}
return Plugin_Handled ;
}
public Action : Command_KnockbackMMenu ( client , argc )
{
2009-04-24 05:02:19 +02:00
if ( ZRIsClientValid ( client ))
2008-10-11 17:17:51 +02:00
{
2009-04-14 22:05:20 +02:00
// Disabled, under construction.
// ZRKnockbackMMenu(client);
2008-10-11 17:17:51 +02:00
}
else
{
2009-04-14 23:16:31 +02:00
// Tsk tsk no translation? :P
//ReplyToCommand(client, "This menu cannot be used from the console.");
2008-10-11 17:17:51 +02:00
}
2008-10-04 22:59:11 +02:00
return Plugin_Handled ;
2008-12-26 23:03:29 +01:00
}
public Action : Command_TeleMenu ( client , argc )
{
2009-04-24 05:02:19 +02:00
if ( ZRIsClientValid ( client ))
2008-12-26 23:03:29 +01:00
{
2009-03-29 22:04:47 +02:00
ZRZTeleMenu ( client );
2008-12-26 23:03:29 +01:00
}
else
{
2009-04-14 23:16:31 +02:00
// BAD!
2009-02-13 22:57:02 +01:00
ReplyToCommand ( client , " This menu cannot be used from the console. " );
2008-12-26 23:03:29 +01:00
}
return Plugin_Handled ;
}
2009-01-31 20:48:56 +01:00
public Action : Command_LogFlags ( client , argc )
{
decl String : message [ 2048 ];
2009-02-13 22:57:02 +01:00
message [ 0 ] = 0 ;
2009-01-31 20:48:56 +01:00
2009-02-13 22:57:02 +01:00
StrCat ( message , sizeof ( message ), " LOG_CORE_EVENTS (1) - Log core events like executing files, error messages, etc. \n " );
StrCat ( message , sizeof ( message ), " LOG_GAME_EVENTS (2) - Log game events like admin commands, suicide prevention and anticamp kills. \n " );
StrCat ( message , sizeof ( message ), " LOG_PLAYER_COMMANDS (4) - Log commands made by the player. \n " );
StrCat ( message , sizeof ( message ), " LOG_DEBUG (8) - Enable debug messages (if they exist). \n " );
StrCat ( message , sizeof ( message ), " LOG_DEBUG_DETAIL (16) - Detailed debug messages. May cause spam. \n " );
StrCat ( message , sizeof ( message ), " LOG_DEBUG_MAX_DETAIL (32) - Low level detailed debug messages. Causes spam! Only enable right before and after testing. \n " );
StrCat ( message , sizeof ( message ), " LOG_LOG_TO_ADMINS (64) - Display log messages to admin chat. \n " );
StrCat ( message , sizeof ( message ), " LOG_LOG_TO_CLIENT (128) - Display log messages to the client that executed the event/command. \n " );
StrCat ( message , sizeof ( message ), " LOG_IGNORE_CONSOLE (256) - Don't log messages from client 0 (console). \n " );
StrCat ( message , sizeof ( message ), " LOG_MODULES_ENABLED (512) - Enable detailed log control for developers. Module logs overrides previous flags. \n " );
StrCat ( message , sizeof ( message ), " LOG_MODULE_ZOMBIE (1024) - zombie.inc " );
ReplyToCommand ( client , message );
message [ 0 ] = 0 ;
2009-04-17 01:09:52 +02:00
StrCat ( message , sizeof ( message ), " LOG_MODULE_AMBIENTSOUNDS (2048) - ambientsounds.inc \n " );
2009-02-13 22:57:02 +01:00
StrCat ( message , sizeof ( message ), " LOG_MODULE_OVERLAYS (4096) - overlays.inc \n " );
StrCat ( message , sizeof ( message ), " LOG_MODULE_SAYTRIGGERS (8192) - sayhooks.inc \n " );
StrCat ( message , sizeof ( message ), " LOG_MODULE_TELEPORT (16384) - teleport.inc \n " );
StrCat ( message , sizeof ( message ), " LOG_MODULE_CLASSES (32768) - classes.inc \n " );
StrCat ( message , sizeof ( message ), " LOG_MODULE_WEAPONRESTICT (65536) - weaponrestrict.inc \n " );
StrCat ( message , sizeof ( message ), " LOG_MODULE_COMMANDS (131072) - commands.inc \n " );
StrCat ( message , sizeof ( message ), " LOG_MODULE_ANTICAMP (262144) - anticamp.inc \n " );
2009-04-19 19:54:21 +02:00
StrCat ( message , sizeof ( message ), " LOG_MODULE_DAMAGE (524288) - damage.inc \n " );
2009-02-13 22:57:02 +01:00
StrCat ( message , sizeof ( message ), " LOG_MODULE_OFFSETS (524288) - offsets.inc " );
2009-01-31 20:48:56 +01:00
ReplyToCommand ( client , message );
2009-02-13 22:57:02 +01:00
return Plugin_Handled ;
2009-05-14 02:28:26 +02:00
} */