/** Give the Bomb!
*
* By DrFreeze - Version: 1.0 - Release 17-05-2015
*
* Simple plugin that enables the carriers of the bomb to write /give and to pass it to another
* player. Also the admins with flag T can write /take and to take the bomb from the current
* carrier.
*
* Client commands:
* say /give
* say /givebomb
*
* Admin commands:
* say /take
*
* There are no CVARS yet!
*/
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#define PLUGIN "Give the Bomb"
#define VERSION "1.0"
#define AUTHOR "DrFreeze"
#define iPrefix "[Bomba átadás]"
enum Color {
NORMAL = 1,
GREEN,
TEAM_COLOR,
GREY,
RED,
BLUE,
}
new TeamName[][] = {
"",
"TERRORIST",
"CT",
"SPECTATOR"
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_dictionary("give_bomb.txt")
register_clcmd("say /atad", "GiveBombMenu");
}
public TakeBombMenu(id)
{
if (get_user_team(id) != 1 || !is_user_alive(id) || user_has_weapon(id, CSW_C4))
{
ColorChat( id, GREEN, "%s^1 Ezzel a menüvel^3 át tudjuk adni csapattársunknak a bombát!", iPrefix );
return PLUGIN_HANDLED;
}
new menu = menu_create( "\\yBomba Átvétel Menü:", "take_bomb_handler" );
new players[32], pnum, tempid;
new szName[32], szUserId[32];
get_players( players, pnum, "ae", "TERRORIST");
for ( new i; i<pnum; i++ )
{
tempid = players[i];
if (user_has_weapon(tempid, CSW_C4))
{
get_user_name( tempid, szName, charsmax( szName ) );
formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ));
menu_additem( menu, szName, szUserId, 0 );
}
}
menu_display (id, menu, 0);
return PLUGIN_CONTINUE;
}
public take_bomb_handler(id, menu, item)
{
if ( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new szData[6], szName[64];
new _access, item_callback;
menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
new userid = str_to_num( szData );
new player = find_player( "k", userid ); // flag "k" : find player from userid
new current_carrier[32]
get_user_name(id, current_carrier, charsmax ( current_carrier ) );
if ( has_flag( id, "t" ) && player && is_user_alive(player) && user_has_weapon(player, CSW_C4) )
{
fm_transfer_user_gun(player, id, CSW_C4)
ColorChat( id, GREEN, "%s^1 A bombát^3 átadták^4 %s-nak!", iPrefix, szName, current_carrier );
}
else
{
ColorChat( id, GREEN, "%s^1 A bombát^3 nem vették át!", iPrefix);
}
menu_destroy( menu );
return PLUGIN_CONTINUE;
}
public GiveBombMenu(id) {
if (get_user_team(id) != 1 || !is_user_alive(id) || !user_has_weapon(id, CSW_C4)){
ColorChat( id, GREEN, "%s^1 Ezzel a menüvel^3 át tudjuk adni csapattársunknak a bombát!", iPrefix );
return PLUGIN_HANDLED;
}
new menu = menu_create( "\\rBomba Átadás Menü:", "give_bomb_handler" );
new players[32], pnum, tempid;
new szName[32], szUserId[32];
get_players( players, pnum, "ae", "TERRORIST");
for(new i; i<pnum; i++)
{
tempid = players[i];
if (!user_has_weapon(tempid, CSW_C4)){
get_user_name( tempid, szName, charsmax( szName ) );
formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ) );
menu_additem( menu, szName, szUserId, 0 );
}
}
menu_display(id, menu, 0);
return PLUGIN_CONTINUE;
}
public give_bomb_handler( id, menu, item )
{
if ( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new szData[6], szName[64];
new _access, item_callback;
menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
new userid = str_to_num( szData );
new player = find_player( "k", userid ); // flag "k" : find player from userid
new current_carrier[32]
get_user_name(id, current_carrier, charsmax ( current_carrier ) );
if ( player && is_user_alive(player) && !user_has_weapon(player, CSW_C4) )
{
fm_transfer_user_gun(id, player, CSW_C4)
ColorChat( id, GREEN, "%s^1 A bombát^3 átadták^4 %s-nak!", iPrefix, szName, current_carrier );
}
else
{
ColorChat( id, GREEN, "%s^1 A bombát^3 nem vették at!", iPrefix);
}
menu_destroy( menu );
return PLUGIN_CONTINUE;
}
ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
static message[256];
switch(type)
{
case NORMAL:
{
message[0] = 0x01;
}
case GREEN:
{
message[0] = 0x04;
}
default:
{
message[0] = 0x03;
}
}
vformat(message[1], 251, msg, 4);
message[192] = '^0';
static team, ColorChange, index, MSG_Type;
if(id)
{
MSG_Type = MSG_ONE;
index = id;
}
else
{
index = FindPlayer();
MSG_Type = MSG_ALL;
}
team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message);
if(ColorChange)
{
Team_Info(index, MSG_Type, TeamName[team]);
}
}
ShowColorMessage(id, type, message[])
{
message_begin(type, get_user_msgid("SayText"), _, id);
write_byte(id)
write_string(message);
message_end();
}
Team_Info(id, type, team[])
{
message_begin(type, get_user_msgid("TeamInfo"), _, id);
write_byte(id);
write_string(team);
message_end();
return 1;
}
ColorSelection(index, type, Color:Type)
{
switch(Type)
{
case RED:
{
return Team_Info(index, type, TeamName[1]);
}
case BLUE:
{
return Team_Info(index, type, TeamName[2]);
}
case GREY:
{
return Team_Info(index, type, TeamName[0]);
}
}
return 0;
}
FindPlayer()
{
static i;
i = -1;
while(i <= get_maxplayers())
{
if(is_user_connected(++i))
{
return i;
}
}
return -1;
}