Команда е: /team
Код за потвърждение: Избери целия код
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <colorchat>
#include <basebuilder>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Administrator"
#define MAX 32
#define LICZBA_KOLOROW 8
#define GetLastMover(%1) ( entity_get_int( %1, EV_INT_iuser4 ) )
#define SetLastMover(%1,%2) ( set_pev( %1, pev_iuser4, %2 ) )
#define FLAG ADMIN_BAN
#define MAXENTS 1024
new pInfo,pInfoText;
new g_iMaxPlayers, mozna;
new wlasciciel[33];
new klocek[128];
new klocekk[33];
new const nazwa_koloru[LICZBA_KOLOROW][16] =
{
"Red",
"Green",
"Blue",
"Purple",
"Yellow",
"Skyy",
"Orange",
"Pink"
};
new const paleta_kolorow[LICZBA_KOLOROW][3] =
{
{ 255, 0, 0 },
{ 0, 255, 0 },
{ 0, 0, 255 },
{ 255, 0, 255 },
{ 255, 255, 0 },
{ 14, 244, 248 },
{ 252, 113, 10 },
{ 255, 6, 249 }
};
new kolory_przyznane;
new druzyna_gracza[MAX+1];
new budowanie, cos;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("HLTV", "NowaRunda", "a", "1=0", "2=0");
register_event("DeathMsg", "Death", "a");
register_touch("player","func_wall","wall_touch")
register_clcmd("say /team", "StworzDruzyne");
register_clcmd("say /team", "StworzDruzyne");
register_clcmd("say /test", "test");
pInfo = register_cvar("bb_one_info","1")
pInfoText = register_cvar("bb_one_text","[BaseBuilder]^x01 This block must already do^x03 <name>!")
}
public wall_touch(player,ent)
{
new pplayer = druzyna_gracza[player];
new Float:eorigins[3],Float:porigins[3]
new Float:emaxs[3],Float:pmins[3]
pev(ent,pev_origin,eorigins)
pev(ent,pev_maxs,emaxs)
pev(player,pev_origin,porigins)
pev(player,pev_mins,pmins)
new Float:result[2]
result[0]=eorigins[2]+emaxs[2]
result[1]=porigins[2]-pmins[2]
for(new i=1;i<9;i++)
{
if(result[0]<result[1])
{
klocekk[player] = ent;
if(GetLastMover(ent) && GetLastMover(ent) != player && !is_same_group(player, pplayer) && !bb_is_user_zombie(player) && cos)
{
user_slap(player, 0, 1);
}
}
}
}
public bb_drop_pre(id, ent)
{
if(get_user_flags(id) & ADMIN_BAN && GetLastMover(klocek[id]) != id && GetLastMover(klocek[id]) != 0)
set_task(0.2, "Wlasciciel", id+1128);
}
public Wlasciciel(id)
{
id -= 1128;
SetLastMover(klocek[id], wlasciciel[id]);
}
public bb_grab_pre(id, ent)
{
klocek[id] = ent;
wlasciciel[id] = GetLastMover(ent);
}
public bb_grab_post(id,ent)
{
if(get_user_flags(id) & ADMIN_BAN && !budowanie)
return PLUGIN_CONTINUE;
new id2 = druzyna_gracza[id];
if(pev(ent,pev_euser4) != id && pev(ent,pev_euser4) != 0)
{
static iLast;
iLast = pev(ent,pev_iuser4);
if(!druzyna_gracza[id])
{
SetLastMover(ent,wlasciciel[id]);
SetLastMover(ent,iLast);
set_task(0.2, "Give", id + 678);
bb_drop_user_block(id);
}
else
{
if(is_same_group(id, id2) && GetLastMover(ent) != id2)
{
SetLastMover(ent,wlasciciel[id]);
SetLastMover(ent,iLast);
set_task(0.2, "Give", id + 678);
bb_drop_user_block(id);
if(get_pcvar_num(pInfo))
{
static szText[128],szName[64]
get_pcvar_string(pInfoText,szText,charsmax(szText));
get_user_name(iLast,szName,charsmax(szName));
replace_all(szText,charsmax(szText),"<name>",szName);
ColorChat(id, GREEN, szText);
}
}
}
}
else
{
set_pev(ent,pev_euser4,id);
}
return PLUGIN_CONTINUE;
}
public Oddaj(id)
{
id -= 678;
SetLastMover(klocek[id], wlasciciel[id]);
}
public bb_buildphase_started(){
for (new iEnt = g_iMaxPlayers+1; iEnt < MAXENTS; iEnt++)
{
if (pev_valid(iEnt))
{
new szClass[10], szTarget[7];
pev(iEnt, pev_classname, szClass, 9);
pev(iEnt, pev_targetname, szTarget, 6);
if (!equal(szClass, "func_wall") || equal(szTarget, "ignore")){
continue;
}
set_pev(iEnt,pev_euser4,0);
}
}
}
public bb_prepphase_started()
{
new i = -1;
while(( i = find_ent_by_class( i, "func_wall" )) != 0 )
{
if( !pev_valid(i))
continue;
new szTargetname[32];
pev( i, pev_targetname, szTargetname, 31 );
if( equal( szTargetname, "ignore" ) )
continue;
if( equal( szTargetname, "barrier" ) )
continue;
if( is_user_alive( GetLastMover( i ) ) )
continue;
new Float:org[3];
pev(i, pev_origin, org );
org[2]-=1000.0;
set_pev( i, pev_origin, org );
}
mozna = true;
budowanie = false;
cos = true;
}
public test(id)
{
static name[64];
get_user_name(druzyna_gracza[id], name, 63);
client_print(id, print_chat, name);
}
public NowaRunda()
{
kolory_przyznane = 0;
mozna = false;
budowanie = true;
cos = false;
for(new id = 0; id < MAX; id ++)
{
if(is_user_connected(id))
{
UstawKolor(id);
druzyna_gracza[id] = 0;
}
}
}
public Death()
{
new vid = read_data(2);
new vid2 = druzyna_gracza[vid];
if(druzyna_gracza[vid])
{
new i = -1;
while(( i = find_ent_by_class( i, "func_wall" )) != 0 )
{
if( !pev_valid(i))
continue;
new szTargetname[32];
pev( i, pev_targetname, szTargetname, 31 );
if( equal( szTargetname, "ignore" ) )
continue;
if( equal( szTargetname, "barrier" ) )
continue;
if(GetLastMover(i) != vid)
continue;
SetLastMover(i, vid2);
}
}
else
{
if(mozna)
{
new i = -1;
while(( i = find_ent_by_class( i, "func_wall" )) != 0 )
{
if( !pev_valid(i))
continue;
new szTargetname[32];
pev( i, pev_targetname, szTargetname, 31 );
if( equal( szTargetname, "ignore" ) )
continue;
if( equal( szTargetname, "barrier" ) )
continue;
if(is_user_alive(GetLastMover(i)))
continue;
new Float:org[3];
pev(i, pev_origin, org );
org[2]-=1000.0;
set_pev( i, pev_origin, org );
}
}
else
{
new i = -1;
while((i = find_ent_by_class(i, "func_wall")) != 0)
{
if(!pev_valid(i))
continue;
new szTargetname[32];
pev(i, pev_targetname, szTargetname, 31 );
if(equal( szTargetname, "ignore"))
continue;
if(equal( szTargetname, "barrier"))
continue;
if(GetLastMover(i) != vid)
continue;
new Float:org[3];
pev(i, pev_origin, org);
org[2]-=1000.0;
set_pev(i, pev_origin, org);
}
}
}
UsunDruzyne(vid);
}
public client_disconnect(id)
{
new id2 = druzyna_gracza[id];
if(druzyna_gracza[id])
{
new i = -1;
while(( i = find_ent_by_class( i, "func_wall" )) != 0 )
{
if( !pev_valid(i))
continue;
new szTargetname[32];
pev( i, pev_targetname, szTargetname, 31 );
if( equal( szTargetname, "ignore" ) )
continue;
if( equal( szTargetname, "barrier" ) )
continue;
if(GetLastMover(i) != id)
continue;
SetLastMover(i, id2);
}
}
else
{
if(mozna)
{
new i = -1;
while(( i = find_ent_by_class( i, "func_wall" )) != 0 )
{
if( !pev_valid(i))
continue;
new szTargetname[32];
pev( i, pev_targetname, szTargetname, 31 );
if( equal( szTargetname, "ignore" ) )
continue;
if( equal( szTargetname, "barrier" ) )
continue;
if(is_user_alive(GetLastMover(i)))
continue;
new Float:org[3];
pev(i, pev_origin, org );
org[2]-=1000.0;
set_pev( i, pev_origin, org );
}
}
else
{
new i = -1;
while((i = find_ent_by_class(i, "func_wall")) != 0)
{
if(!pev_valid(i))
continue;
new szTargetname[32];
pev(i, pev_targetname, szTargetname, 31 );
if(equal( szTargetname, "ignore"))
continue;
if(equal( szTargetname, "barrier"))
continue;
if(GetLastMover(i) != id)
continue;
new Float:org[3];
pev(i, pev_origin, org);
org[2]-=1000.0;
set_pev(i, pev_origin, org);
}
}
}
UsunDruzyne(id);
}
public StworzDruzyne(id)
{
if(get_user_team(id) != 2)
{
ColorChat(id, GREEN, "You can not wear Team as a zombie!");
return PLUGIN_CONTINUE;
}
new menu = menu_create("Who do you want to wear the team :", "StworzDruzyne_Handler");
new callback = menu_makecallback("StworzDruzyne_Callback");
static name[64], players[32], target[8], num, pid;
get_players(players, num);
for(new i = 0; i <= num; i ++){
pid = players[i];
if(!is_user_connected(pid) || !is_same_team(pid, id) || !pid)
continue;
get_user_name(pid, name, 63);
num_to_str(pid, target, 7);
menu_additem(menu, name, target, _, callback);
}
menu_setprop(menu, MPROP_BACKNAME, "Previous Page");
menu_setprop(menu, MPROP_NEXTNAME, "Next page");
menu_setprop(menu, MPROP_EXITNAME, "Quit");
menu_display(id, menu);
return PLUGIN_CONTINUE;
}
public StworzDruzyne_Callback(id, menu, item)
{
static menu_name[64], data[8], acces, callback;
menu_item_getinfo(menu, item, acces, data, 7, menu_name, 63, callback);
new pid = str_to_num(data);
if(is_user_connecting(pid) || druzyna_gracza[id] || pid == id)
return ITEM_DISABLED;
return ITEM_ENABLED;
}
public StworzDruzyne_Handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
if(get_user_team(id) != 2)
{
ColorChat(id, GREEN, "You can not wear Team as a zombie!");
return PLUGIN_CONTINUE;
}
static data[8], menu_name[64], acces, callback;
menu_item_getinfo(menu, item, acces, data, 7, menu_name, 63, callback);
menu_destroy(menu);
new pid = str_to_num(data);
static name[64];
get_user_name(id, name, 63);
static title[64], target[8];
format(title, 63, "Want to join the Team \r^"%s^"?", name);
num_to_str(id, target, 7);
new menu_cd = menu_create(title, "StworzDruzyne_Execute");
menu_additem(menu_cd, "No", target);
menu_additem(menu_cd, "Yes", target);
menu_setprop(menu_cd, MPROP_BACKNAME, "Previous Page");
menu_setprop(menu_cd, MPROP_NEXTNAME, "Next page");
menu_setprop(menu_cd, MPROP_EXITNAME, "Quit");
menu_display(pid, menu_cd);
return PLUGIN_CONTINUE;
}
public StworzDruzyne_Execute(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
if(get_user_team(id) != 2)
{
ColorChat(id, GREEN, "You can not wear Team as a zombie!");
return PLUGIN_CONTINUE;
}
static menu_name[64], data[8], acces, callback;
menu_item_getinfo(menu, item, acces, data, 7, menu_name, 63, callback);
menu_destroy(menu);
new pid = str_to_num(data);
static name[2][64];
get_user_name(pid, name[0], 63);
get_user_name(id, name[1], 63);
if(!is_user_connected(pid))
return PLUGIN_HANDLED;
if(druzyna_gracza[pid])
{
ColorChat(id, RED, "[BB]^x01 The offer is already out of date.");
return PLUGIN_HANDLED;
}
if(druzyna_gracza[id])
{
ColorChat(id, RED, "[BB]^x01 Already have the team.");
return PLUGIN_HANDLED;
}
if(item)
{
new try, kolor = -1;
do{
kolor = random_num(0, LICZBA_KOLOROW);
try ++;
}
while(try != LICZBA_KOLOROW && ((1<<kolor) & kolory_przyznane));
if(try == LICZBA_KOLOROW)
{
ColorChat(id, RED, "[BB]^x01 You can not create Team - no colors to grant !!!");
return PLUGIN_HANDLED;
}
druzyna_gracza[pid] = id;
druzyna_gracza[id] = pid;
kolory_przyznane &= (1<<kolor);
ColorChat(pid, GREEN, "[BB]^x01 Player ^x04%s^x01 joined to your teams, your color is %s.", name[1], nazwa_koloru[kolor]);
ColorChat(id, GREEN, "[BB]^x01 Have joined the Team Player ^x04%s^x01, your color is %s.", name[0], nazwa_koloru[kolor]);
UstawKolor(pid, kolor);
UstawKolor(id, kolor);
}
else
ColorChat(pid, RED, "[BB]^x01 Player ^x04%s^x01 I do not want to join your Team.", name[1]);
return PLUGIN_HANDLED;
}
public UsunDruzyne(id)
{
new pid = druzyna_gracza[id];
druzyna_gracza[pid] = 0;
druzyna_gracza[id] = 0;
UstawKolor(pid);
UstawKolor(id);
}
stock UstawKolor(id, kolor = -1)
{
if(is_user_connected(id))
{
if(kolor >= 0)
{
if(is_user_alive(id))
set_user_rendering(id, kRenderFxGlowShell, paleta_kolorow[kolor][0], paleta_kolorow[kolor][1], paleta_kolorow[kolor][2], kRenderTransAlpha, 200);
}
else
set_user_rendering(id);
}
}
stock is_same_team(id, pid)
{
if(get_user_team(id) == get_user_team(pid))
return 1;
return 0;
}
stock is_same_group(id, target)
{
if((druzyna_gracza[id] && druzyna_gracza[id] == target) && (druzyna_gracza[target] && druzyna_gracza[target] == id))
return 1;
return 0;
}