Advertisement
Hyuna

Beacon V 1.0 By Hyuna

Dec 17th, 2012
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.13 KB | None | 0 0
  1. /*
  2.     -------------------------------------------------------------------
  3.     Beacon V 1.0
  4.     Copyright (C) 2012 Hyuna aka NorToN
  5.  
  6.     This program is free software: you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation, either version 3 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.    
  19.     -------------------------------------------------------------------
  20.    
  21.     I'm not allowing to Yosi/Stav/Noam use/take/change anything on this plugin!
  22.    
  23.     Thankyou,
  24.     Hyuna - Plugin creator.
  25. */
  26.  
  27. #include <amxmodx>
  28. #include <amxmisc>
  29. #include <fakemeta>
  30.  
  31. enum _:Teams{
  32.     FM_TEAM_UNASSIGNED,
  33.     FM_TEAM_T,
  34.     FM_TEAM_CT,
  35.     FM_TEAM_SPECTATOR
  36. };
  37.  
  38. new g_beacon_sprite,activity;
  39. new bool:g_beacon[33];
  40.  
  41. public plugin_init(){
  42.     register_plugin("Beacon","1.0","Hyuna");
  43.    
  44.     register_clcmd("amx_beaconmenu","Beacon_Menu",ADMIN_MENU,"- Opens Beacon player menu");
  45.     register_concmd("amx_beacon_give","Cmd_GiveBeacon",ADMIN_KICK,"<name or userid> - Gives beacon to target");
  46.     register_concmd("amx_beacon_remove","Cmd_RemoveBeacon",ADMIN_KICK,"<name or userid> - Removes beacon from target");
  47.    
  48.     register_event("DeathMsg","Event_DeathMsg","a");
  49.    
  50.     activity = get_cvar_pointer("amx_show_activity");
  51. }
  52.  
  53. public plugin_precache(){
  54.     g_beacon_sprite = precache_model("sprites/laserbeam.spr");
  55.     precache_sound("buttons/blip1.wav");
  56. }
  57.  
  58. public client_disconnect(id){
  59.     remove_task(id);
  60.     g_beacon[id] = false;
  61. }
  62.  
  63. public Event_DeathMsg(){
  64.     new Victim = read_data(2);
  65.    
  66.     if (!is_user_connected(Victim) || is_user_bot(Victim))
  67.         return;
  68.        
  69.     g_beacon[Victim] = false;
  70.     remove_task(Victim);
  71. }
  72.  
  73. public Cmd_GiveBeacon(id,level,cid){
  74.     if(!cmd_access(id,level,cid,2))
  75.         return 1;
  76.        
  77.     new arg[32];
  78.     read_argv(1, arg, 31);
  79.     new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE);
  80.    
  81.     if(!player)
  82.         return 1;
  83.        
  84.     else if (g_beacon[player])
  85.     {
  86.         client_print(id,print_console,"Client already has beacon!");
  87.         return 1;
  88.     }
  89.        
  90.     new name[32], name2[32],authid[32],authid2[32];
  91.    
  92.     get_user_name(id,name,charsmax(name));
  93.     get_user_name(player,name2,charsmax(name));
  94.     get_user_authid(id,authid,charsmax(authid));
  95.     get_user_authid(player,authid2, charsmax(authid2));
  96.    
  97.     g_beacon[player] = true;
  98.     set_task(1.0,"create_beacon",player,.flags="b");
  99.            
  100.     switch(get_pcvar_num(activity))
  101.     {
  102.         case 1: client_print(0,print_chat,"[AMXX] Admin turn on beacon to player %s",name2);
  103.         case 2: client_print(0,print_chat,"[AMXX] Admin %s turn on beacon to player %s",name,name2);
  104.     }
  105.            
  106.     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);
  107.    
  108.     return 1;
  109.        
  110. }
  111.  
  112. public Cmd_RemoveBeacon(id,level,cid){
  113.     if(!cmd_access(id,level,cid,2))
  114.         return 1;
  115.        
  116.     new arg[32];
  117.     read_argv(1, arg, 31);
  118.     new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE);
  119.    
  120.     if(!player)
  121.         return 1;
  122.        
  123.     else if (!g_beacon[player])
  124.     {
  125.         client_print(id,print_console,"Client don't have beacon!");
  126.         return 1;
  127.     }
  128.        
  129.     new name[32], name2[32],authid[32],authid2[32];
  130.    
  131.     get_user_name(id,name,charsmax(name));
  132.     get_user_name(player,name2,charsmax(name));
  133.     get_user_authid(id,authid,charsmax(authid));
  134.     get_user_authid(player,authid2, charsmax(authid2));
  135.    
  136.     g_beacon[player] = false;
  137.     remove_task(player);
  138.            
  139.     switch(get_pcvar_num(activity))
  140.     {
  141.         case 1: client_print(0,print_chat,"[AMXX] Admin turn off beacon to player %s",name2);
  142.         case 2: client_print(0,print_chat,"[AMXX] Admin %s turn off beacon to player %s",name,name2);
  143.     }
  144.            
  145.     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);
  146.    
  147.     return 1;
  148.        
  149. }
  150.  
  151. public Beacon_Menu(id,level,cid){
  152.     if(!cmd_access(id,level,cid,1))
  153.         return 1;
  154.    
  155.     new BeaconM = menu_create("\wBeacon Player Menu","Beacon_handle");
  156.     new cb = menu_makecallback("Beacon_Callback");
  157.    
  158.     new szName[32],players[32],szTemp[10],pnum,player,temp[128];   
  159.     get_players(players,pnum,"ch");
  160.    
  161.     for (new i; i < pnum; i++)
  162.     {
  163.         player = players[i];
  164.        
  165.         if (!is_user_connected(player))
  166.             continue;
  167.        
  168.         get_user_name(player,szName,charsmax(szName));
  169.         formatex(temp,127,"%s - \d[\yBeacon \r%s\d]",szName,g_beacon[player] ? "ON":"OFF");
  170.         num_to_str(player,szTemp,charsmax(szTemp));
  171.         menu_additem(BeaconM,temp,szTemp,.callback=cb);
  172.     }
  173.    
  174.     menu_setprop(BeaconM,MPROP_EXITNAME,"\yExit");
  175.     menu_setprop(BeaconM,MPROP_EXIT,MENU_EXIT);
  176.     menu_display(id,BeaconM);
  177.    
  178.     return 1;
  179. }
  180.  
  181. public Beacon_Callback(id,BeaconM,item){
  182.     new data[6],szName[64],access,callback;
  183.    
  184.     menu_item_getinfo(BeaconM,item,access,data,charsmax(data),szName,charsmax(szName),callback);
  185.    
  186.     new player = str_to_num(data);
  187.    
  188.     if (!is_user_alive(player) || is_user_bot(player) || is_user_hltv(player))
  189.          return ITEM_DISABLED;
  190.          
  191.     return ITEM_ENABLED;
  192. }
  193.  
  194. public Beacon_handle(id,BeaconM,item){
  195.     if (item == MENU_EXIT)
  196.     {
  197.         menu_destroy(BeaconM);
  198.         return;
  199.     }
  200.    
  201.     new data[6],szName[64],PName[32],PName2[32],authid[32],authid2[32],access,callback;
  202.    
  203.     menu_item_getinfo(BeaconM,item,access,data,charsmax(data),szName,charsmax(szName),callback);
  204.    
  205.     new player = str_to_num(data);
  206.    
  207.     if (!is_user_alive(player))
  208.         return;
  209.  
  210.     get_user_name(id,PName,31);
  211.     get_user_name(player,PName2,31);
  212.     get_user_authid(id,authid,charsmax(authid));
  213.     get_user_authid(player,authid2, charsmax(authid2));
  214.    
  215.     switch(g_beacon[player])
  216.     {
  217.         case false:
  218.         {
  219.             g_beacon[player] = true;
  220.             set_task(1.0,"create_beacon",player,.flags="b");
  221.            
  222.             switch(get_pcvar_num(activity))
  223.             {
  224.                 case 1: client_print(0,print_chat,"[AMXX] Admin turn on beacon to player %s",PName2);
  225.                 case 2: client_print(0,print_chat,"[AMXX] Admin %s turn on beacon to player %s",PName,PName2);
  226.             }
  227.            
  228.             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);
  229.         }
  230.        
  231.         case true:
  232.         {
  233.             g_beacon[player] = false;
  234.             remove_task(player);
  235.            
  236.             switch(get_pcvar_num(activity))
  237.             {
  238.                 case 1: client_print(0,print_chat,"[AMXX] Admin turn off beacon to player %s",PName2);
  239.                 case 2: client_print(0,print_chat,"[AMXX] Admin %s turn off beacon to player %s",PName,PName2);
  240.             }
  241.            
  242.             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);
  243.         }
  244.     }
  245.    
  246.     client_cmd(id,"amx_beaconmenu");
  247. }
  248.  
  249. public create_beacon(player){
  250.     if (!is_user_alive(player) || !g_beacon[player])
  251.         return;
  252.    
  253.     static origin[3];
  254.     emit_sound(player,CHAN_ITEM,"buttons/blip1.wav",1.0,ATTN_NORM,0,PITCH_NORM);
  255.    
  256.     get_user_origin(player,origin);
  257.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  258.     write_byte(TE_BEAMCYLINDER);
  259.     write_coord(origin[0]); //position.x
  260.     write_coord(origin[1]); //position.y
  261.     write_coord(origin[2] - (pev(player,pev_button) & IN_DUCK ? 7:25)); //position.z
  262.     write_coord(origin[0]);    //axis.x
  263.     write_coord(origin[1]);    //axis.y
  264.     write_coord(origin[2]+200); //axis.z
  265.     write_short(g_beacon_sprite); //sprite index
  266.     write_byte(0);       //starting frame
  267.     write_byte(1);        //frame rate in 0.1's
  268.     write_byte(6);        //life in 0.1's
  269.     write_byte(2);        //line width in 0.1's
  270.     write_byte(1);        //noise amplitude in 0.01's
  271.    
  272.     new bool:is_terrorist = (fm_get_user_team(player) == FM_TEAM_T) ? true:false;
  273.    
  274.     write_byte(is_terrorist ? 255:0);   //red
  275.     write_byte(0);          //green
  276.     write_byte(is_terrorist ? 0:255);   //blue
  277.    
  278.     write_byte(255);     //brightness
  279.     write_byte(6);       //scroll speed in 0.1's
  280.     message_end();
  281. }
  282.  
  283. stock fm_get_user_team(index)
  284.     return get_pdata_int(index,114);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement