Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -------------------------------------------------------------------
- Beacon V 1.0
- Copyright (C) 2012 Hyuna aka NorToN
- 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/>.
- -------------------------------------------------------------------
- I'm not allowing to Yosi/Stav/Noam use/take/change anything on this plugin!
- Thankyou,
- Hyuna - Plugin creator.
- */
- #include <amxmodx>
- #include <amxmisc>
- #include <fakemeta>
- enum _:Teams{
- FM_TEAM_UNASSIGNED,
- FM_TEAM_T,
- FM_TEAM_CT,
- FM_TEAM_SPECTATOR
- };
- new g_beacon_sprite,activity;
- new bool:g_beacon[33];
- public plugin_init(){
- register_plugin("Beacon","1.0","Hyuna");
- register_clcmd("amx_beaconmenu","Beacon_Menu",ADMIN_MENU,"- Opens Beacon player menu");
- register_concmd("amx_beacon_give","Cmd_GiveBeacon",ADMIN_KICK,"<name or userid> - Gives beacon to target");
- register_concmd("amx_beacon_remove","Cmd_RemoveBeacon",ADMIN_KICK,"<name or userid> - Removes beacon from target");
- register_event("DeathMsg","Event_DeathMsg","a");
- activity = get_cvar_pointer("amx_show_activity");
- }
- public plugin_precache(){
- g_beacon_sprite = precache_model("sprites/laserbeam.spr");
- precache_sound("buttons/blip1.wav");
- }
- public client_disconnect(id){
- remove_task(id);
- g_beacon[id] = false;
- }
- public Event_DeathMsg(){
- new Victim = read_data(2);
- if (!is_user_connected(Victim) || is_user_bot(Victim))
- return;
- g_beacon[Victim] = false;
- remove_task(Victim);
- }
- public Cmd_GiveBeacon(id,level,cid){
- if(!cmd_access(id,level,cid,2))
- return 1;
- new arg[32];
- read_argv(1, arg, 31);
- new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE);
- if(!player)
- return 1;
- else if (g_beacon[player])
- {
- client_print(id,print_console,"Client already has beacon!");
- return 1;
- }
- new name[32], name2[32],authid[32],authid2[32];
- get_user_name(id,name,charsmax(name));
- get_user_name(player,name2,charsmax(name));
- get_user_authid(id,authid,charsmax(authid));
- get_user_authid(player,authid2, charsmax(authid2));
- g_beacon[player] = true;
- set_task(1.0,"create_beacon",player,.flags="b");
- switch(get_pcvar_num(activity))
- {
- case 1: client_print(0,print_chat,"[AMXX] Admin turn on beacon to player %s",name2);
- case 2: client_print(0,print_chat,"[AMXX] Admin %s turn on beacon to player %s",name,name2);
- }
- log_amx("Cmd: ^"%s<%d><%s><>^" turn on beacon to ^"%s<%d><%s><>^"",name, get_user_userid(id), authid,name2,get_user_userid(player), authid2);
- return 1;
- }
- public Cmd_RemoveBeacon(id,level,cid){
- if(!cmd_access(id,level,cid,2))
- return 1;
- new arg[32];
- read_argv(1, arg, 31);
- new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE);
- if(!player)
- return 1;
- else if (!g_beacon[player])
- {
- client_print(id,print_console,"Client don't have beacon!");
- return 1;
- }
- new name[32], name2[32],authid[32],authid2[32];
- get_user_name(id,name,charsmax(name));
- get_user_name(player,name2,charsmax(name));
- get_user_authid(id,authid,charsmax(authid));
- get_user_authid(player,authid2, charsmax(authid2));
- g_beacon[player] = false;
- remove_task(player);
- switch(get_pcvar_num(activity))
- {
- case 1: client_print(0,print_chat,"[AMXX] Admin turn off beacon to player %s",name2);
- case 2: client_print(0,print_chat,"[AMXX] Admin %s turn off beacon to player %s",name,name2);
- }
- log_amx("Cmd: ^"%s<%d><%s><>^" turn off beacon to ^"%s<%d><%s><>^"",name, get_user_userid(id), authid,name2,get_user_userid(player), authid2);
- return 1;
- }
- public Beacon_Menu(id,level,cid){
- if(!cmd_access(id,level,cid,1))
- return 1;
- new BeaconM = menu_create("\wBeacon Player Menu","Beacon_handle");
- new cb = menu_makecallback("Beacon_Callback");
- new szName[32],players[32],szTemp[10],pnum,player,temp[128];
- get_players(players,pnum,"ch");
- for (new i; i < pnum; i++)
- {
- player = players[i];
- if (!is_user_connected(player))
- continue;
- get_user_name(player,szName,charsmax(szName));
- formatex(temp,127,"%s - \d[\yBeacon \r%s\d]",szName,g_beacon[player] ? "ON":"OFF");
- num_to_str(player,szTemp,charsmax(szTemp));
- menu_additem(BeaconM,temp,szTemp,.callback=cb);
- }
- menu_setprop(BeaconM,MPROP_EXITNAME,"\yExit");
- menu_setprop(BeaconM,MPROP_EXIT,MENU_EXIT);
- menu_display(id,BeaconM);
- return 1;
- }
- public Beacon_Callback(id,BeaconM,item){
- new data[6],szName[64],access,callback;
- menu_item_getinfo(BeaconM,item,access,data,charsmax(data),szName,charsmax(szName),callback);
- new player = str_to_num(data);
- if (!is_user_alive(player) || is_user_bot(player) || is_user_hltv(player))
- return ITEM_DISABLED;
- return ITEM_ENABLED;
- }
- public Beacon_handle(id,BeaconM,item){
- if (item == MENU_EXIT)
- {
- menu_destroy(BeaconM);
- return;
- }
- new data[6],szName[64],PName[32],PName2[32],authid[32],authid2[32],access,callback;
- menu_item_getinfo(BeaconM,item,access,data,charsmax(data),szName,charsmax(szName),callback);
- new player = str_to_num(data);
- if (!is_user_alive(player))
- return;
- get_user_name(id,PName,31);
- get_user_name(player,PName2,31);
- get_user_authid(id,authid,charsmax(authid));
- get_user_authid(player,authid2, charsmax(authid2));
- switch(g_beacon[player])
- {
- case false:
- {
- g_beacon[player] = true;
- set_task(1.0,"create_beacon",player,.flags="b");
- switch(get_pcvar_num(activity))
- {
- case 1: client_print(0,print_chat,"[AMXX] Admin turn on beacon to player %s",PName2);
- case 2: client_print(0,print_chat,"[AMXX] Admin %s turn on beacon to player %s",PName,PName2);
- }
- log_amx("Cmd: ^"%s<%d><%s><>^" turn on beacon to ^"%s<%d><%s><>^"",PName, get_user_userid(id), authid, PName2, get_user_userid(player), authid2);
- }
- case true:
- {
- g_beacon[player] = false;
- remove_task(player);
- switch(get_pcvar_num(activity))
- {
- case 1: client_print(0,print_chat,"[AMXX] Admin turn off beacon to player %s",PName2);
- case 2: client_print(0,print_chat,"[AMXX] Admin %s turn off beacon to player %s",PName,PName2);
- }
- log_amx("Cmd: ^"%s<%d><%s><>^" turn off beacon to ^"%s<%d><%s><>^"",PName, get_user_userid(id), authid, PName2, get_user_userid(player), authid2);
- }
- }
- client_cmd(id,"amx_beaconmenu");
- }
- public create_beacon(player){
- if (!is_user_alive(player) || !g_beacon[player])
- return;
- static origin[3];
- emit_sound(player,CHAN_ITEM,"buttons/blip1.wav",1.0,ATTN_NORM,0,PITCH_NORM);
- get_user_origin(player,origin);
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(TE_BEAMCYLINDER);
- write_coord(origin[0]); //position.x
- write_coord(origin[1]); //position.y
- write_coord(origin[2] - (pev(player,pev_button) & IN_DUCK ? 7:25)); //position.z
- write_coord(origin[0]); //axis.x
- write_coord(origin[1]); //axis.y
- write_coord(origin[2]+200); //axis.z
- write_short(g_beacon_sprite); //sprite index
- write_byte(0); //starting frame
- write_byte(1); //frame rate in 0.1's
- write_byte(6); //life in 0.1's
- write_byte(2); //line width in 0.1's
- write_byte(1); //noise amplitude in 0.01's
- new bool:is_terrorist = (fm_get_user_team(player) == FM_TEAM_T) ? true:false;
- write_byte(is_terrorist ? 255:0); //red
- write_byte(0); //green
- write_byte(is_terrorist ? 0:255); //blue
- write_byte(255); //brightness
- write_byte(6); //scroll speed in 0.1's
- message_end();
- }
- stock fm_get_user_team(index)
- return get_pdata_int(index,114);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement