Code:
/*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* C4 target coordinates miner.
*
*/
#include amxmodx
#include amxmisc
#include cstrike
#include engine
#include fakemeta
#if !defined MAX_NAME_LENGTH
#define MAX_NAME_LENGTH 32
#endif
#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif
#define charsmin -1
#define SCOREATTRIB_BOMB (1<<1)
#define PLUGIN "C4 target coordinates"
new szMapname[MAX_NAME_LENGTH], szName[MAX_NAME_LENGTH];
new g_miner, origin[3];
public plugin_init()
{
register_plugin(PLUGIN, "1.0", "SPiNX");
get_mapname(szMapname, charsmax(szMapname) );
if (containi(szMapname,"de_") == charsmin)
pause ("a");
else
register_forward(FM_PlayerPreThink, "zone_think", 0);
g_miner = register_cvar("mine_c4", "0");
register_message(get_user_msgid("ScoreAttrib"), "Message_ScoreAttrib")
}
//affects showscores so we remove it.
public Message_ScoreAttrib()
{
new iFlags = get_msg_arg_int(2)
if( iFlags & SCOREATTRIB_BOMB && get_pcvar_num(g_miner) != 0 )
{
iFlags &= ~SCOREATTRIB_BOMB
set_msg_arg_int(2, 0, iFlags)
}
}
//silently shows all players have C4.
public zone_think(id)
{
if (get_pcvar_num(g_miner) != 0 )
{
if ( is_user_alive(id) )
cs_set_user_plant(id, 1, 0)
if ( cs_get_user_mapzones(id) == CS_MAPZONE_BOMBTARGET )
show_coords(id);
}
}
public show_coords(id)
{
#define IS_THERE (~(1<<IN_SCORE))
new Float:vec[3];
if( pev(id, pev_button) & IS_THERE && pev(id, pev_oldbuttons) & IS_THERE && get_user_velocity(id, vec) != 0.0 ){
get_mapname(szMapname, charsmax(szMapname) );
get_user_origin( id, origin, 0 );
get_user_name( id, szName, charsmax(szName) );
new players[MAX_PLAYERS], playercount, total;
get_players(players,playercount,"ch");
for (total=0; total<playercount; ++total)
if(is_user_admin(players[total]))
client_print( 0, print_console,"%s, %s bombsite coordinates [x:%i | y:%i | z:%i]", szMapname, szName, origin[0],origin[1],origin[2] );
log_to_file(szMapname, "%s, %s bombsite coordinates [x:%i | y:%i | z:%i]", PLUGIN, szName, origin[0],origin[1],origin[2] );
c4_validater(id)
}
return PLUGIN_HANDLED
}
public c4_validater(id)
{
new szteam[MAX_NAME_LENGTH];
get_user_team(id, szteam, charsmax(szteam))
if(get_user_weapon(id) == CSW_C4 || is_user_alive(id) && is_user_bot(id) && equal(szteam,"TERRORIST"))
cs_set_user_plant(id, 1, 1);
}