/*
Copyright © 2009, anakin_cstrike
Admin Thunder 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.
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 Admin Thunder; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
amx_thunder <target> - blows up a player
*/
#include <amxmodx>
#include <amxmisc>
// - - - - - - - - -
new const PLUGIN[ ] = "Admin Thunder";
#define VERSION "1.0"
// - - - - - - - - -
/* Thunder sound */
new const thunder_sound[] = "ambience/thunder_clap.wav";
/* Global variables */
new
g_lightning, g_smoke,
g_msgsaytext, g_msgclcorpse, g_maxplayers, g_pointer;
public plugin_init()
{
register_plugin( PLUGIN, VERSION, "anakin_cstrike" );
register_concmd( "amx_thunder", "thunder_cmd", ADMIN_SLAY, "- <target>" );
g_msgsaytext = get_user_msgid( "SayText" );
g_msgclcorpse = get_user_msgid( "ClCorpse" );
g_pointer = get_cvar_pointer( "amx_show_activity" );
g_maxplayers = get_maxplayers();
}
public plugin_precache()
{
precache_sound( thunder_sound );
g_lightning = precache_model( "sprites/lgtning.spr" );
g_smoke = precache_model( "sprites/steam1.spr" );
}
public thunder_cmd( id, level, cid )
{
// check for access
if( !cmd_access( id, level, cid, 2 ) )
return PLUGIN_HANDLED;
// read argument from console
new arg[ 32 ];
read_argv( 1, arg, 31 );
new target = cmd_target( id, arg, 6 );
if( !target )
return PLUGIN_HANDLED;
// get target's origin
new vorigin[ 3 ], pos[ 3 ];
get_user_origin( target, vorigin );
// modify origins
vorigin[ 2 ] -= 26;
pos[ 0 ] = vorigin[ 0 ] + 150;
pos[ 1 ] = vorigin[ 1 ] + 150;
pos[ 2 ] = vorigin[ 2 ] + 800;
// block ClCorpse
set_msg_block( g_msgclcorpse, BLOCK_ONCE );
// kill player
user_kill( target );
// create lightning bolt
Thunder( pos, vorigin );
// create smoke
Smoke( vorigin, 10, 10 );
// create blood
Blood( vorigin );
// Info about command
ShowActivity( id, target );
return PLUGIN_HANDLED;
}
Thunder( start[ 3 ], end[ 3 ] )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_BEAMPOINTS );
write_coord( start[ 0 ] );
write_coord( start[ 1 ] );
write_coord( start[ 2 ] );
write_coord( end[ 0 ] );
write_coord( end[ 1 ] );
write_coord( end[ 2 ] );
write_short( g_lightning );
write_byte( 1 );
write_byte( 5 );
write_byte( 7 );
write_byte( 20 );
write_byte( 30 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
message_end();
message_begin( MSG_PVS, SVC_TEMPENTITY, end );
write_byte( TE_SPARKS );
write_coord( end[ 0 ] );
write_coord( end[ 1 ]);
write_coord( end[ 2 ] );
message_end();
emit_sound( 0 ,CHAN_ITEM, thunder_sound, 1.0, ATTN_NORM, 0, PITCH_NORM );
}
Smoke( iorigin[ 3 ], scale, framerate )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_SMOKE );
write_coord( iorigin[ 0 ] );
write_coord( iorigin[ 1 ] );
write_coord( iorigin[ 2 ] );
write_short( g_smoke );
write_byte( scale );
write_byte( framerate );
message_end();
}
Blood( iorigin[ 3 ] )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_LAVASPLASH );
write_coord( iorigin[ 0 ] );
write_coord( iorigin[ 1 ] );
write_coord( iorigin[ 2 ] );
message_end();
}
ShowActivity( admin, player )
{
new value = get_pcvar_num( g_pointer );
// if amx_show_activity is set to 0 do nothing
if( !value )
return 0;
new Buffer[ 128 ], adminname[ 32 ], playername[ 32 ], i;
// get admin's and target's name
get_user_name( admin, adminname, 31 );
get_user_name( player, playername, 31 );
// if amx_show_activity is set to 2 show admin's name, else just player's name
formatex( Buffer, sizeof Buffer - 1, "ADMIN %s: Trucked-down player %s.", (value==1) ? "" : adminname, playername );
// log command to the AMXx logfile
log_amx( Buffer );
// print chat message to all players
for( i = 1; i <= g_maxplayers; i++ )
{
if( !is_user_connected( i ) )
continue;
// skip bots
if( is_user_bot( i ) )
continue;
message_begin( MSG_ONE, g_msgsaytext, _, i );
write_byte( i );
write_string( Buffer );
message_end();
}
return 1;
}