teol

Untitled

Jul 5th, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.57 KB | None | 0 0
  1. /* AMX Mod Plugin
  2.  
  3. A3RA - Recording Assistant V2.3
  4.  
  5. * Installation *
  6.  
  7. Extract .amxx to plugins folder, add plugin to plugins.ini
  8. Restart server/map change.
  9.  
  10. * Client Commands *
  11.  
  12. a3_record - Brings up menu of players to record
  13. a3_stop - Stops recording and leaves recording session
  14. a3_ac or say /ac - Toggles autocycle of players
  15.  
  16. * Server CVARS *
  17.  
  18. a3r_revcycle [0|1] - Reverses the way plugin cycles through players (1 reverses)
  19. a3r_autocycle [1|0] - Sets autocycling on/off. On by default.
  20.  
  21. (c) Copyright 2006, Tim Ballantine (Alcedema)
  22. [email protected] // www.a3-gaming.co.uk // #a3.uk (QN)
  23. This file is provided as is (no warranties).
  24.  
  25. */
  26.  
  27. #include <amxmod>
  28. #include <amxmisc>
  29. #include <VexdUM>
  30.  
  31. new a3r_players[33][3]
  32. new maxplayers,ontarget
  33. new g_menuPosition[33]
  34. new g_menuPlayers[33][32]
  35. new g_menuPlayersNum[33]
  36.  
  37. public plugin_init() {
  38.     register_plugin("a3 record","2.3","A3 Alcedema")
  39.     register_clcmd("a3_record","cmdRecordMenu",0,"- displays record menu")
  40.     register_clcmd("a3_ac","toggleac",0,"")
  41.     register_clcmd("say /ac","toggleac")
  42.     register_clcmd("a3_stop","Recordstop",0,"- stops recording a demo")
  43.     register_menucmd(register_menuid("Record:"),1023,"actionRecordMenu")
  44.     register_clcmd("stop","manualstop")
  45.     register_cvar("a3r_revcycle", "0")
  46.     register_cvar("a3r_autocycle", "1")
  47.     maxplayers = get_maxplayers()
  48.     set_task(0.5, "check_spectated", 45421000, "", 0, "b")
  49.     set_task(1.0, "check_hudmessage", 45421000, "", 0, "b")
  50. }
  51.  
  52. public actionRecordMenu(id,key)
  53. {
  54.     switch(key){
  55.         case 8: displayRecordMenu(id,++g_menuPosition[id])
  56.             case 9: displayRecordMenu(id,--g_menuPosition[id])
  57.             default:{
  58.             new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
  59.             for(new a = 1; a <= maxplayers; ++a)
  60.             {
  61.                 if (a3r_players[a][1] == player)
  62.                 {
  63.                     new line[128], uName[32]
  64.                     get_user_name(a,uName,31)
  65.                     format (line, 127, "That player is already being recorded by %s", uName)
  66.                     set_hudmessage(200, 100, 0, -1.0,0.12, 0,6.0, 6.0, 0.1, 0.2, 3)
  67.                     show_hudmessage(id, line)
  68.                     return PLUGIN_HANDLED
  69.                 }
  70.             }
  71.             new authid[32],authid2[32],name[32]
  72.             get_user_authid(player,authid,31)
  73.             get_user_authid(player,authid2,31)
  74.             replace (authid2, 31, "STEAM_0:1:", "STEAM_0_1_")
  75.             replace (authid2, 31, "STEAM_0:0:", "STEAM_0_0_")
  76.             get_user_name(player,name,31)
  77.             new timestamp = get_systime()
  78.             new demoname[32]
  79.             format(demoname, 31, "%s_%d", authid2, timestamp)
  80.             strtolower(demoname)
  81.             log_message("[ A3R ] RECORD for %s", authid)
  82.             client_cmd(id,"record %s", demoname)
  83.             a3r_players[id][0] = 1
  84.             a3r_players[id][1] = player
  85.             new AC[4]
  86.             if (get_cvar_num("a3r_autocycle") == 1)
  87.             {
  88.                 a3r_players[id][2] = 1
  89.                 format (AC, 3, "On")
  90.                 } else {
  91.                 a3r_players[id][2] = 0
  92.                 format (AC, 3, "Off")
  93.             }
  94.             set_task(3.0,"record_sbstatus",id)
  95.             set_task(5.0,"record_status",id)
  96.            
  97.             client_print(id,print_chat,"[ A3R ] * Recording %s (%s) to %s.dem *", name, authid, demoname)
  98.             client_cmd(id, "amx_chat ** Recording player %s (%s) **", name, authid)
  99.            
  100.         }
  101.     }
  102.     return PLUGIN_HANDLED
  103. }
  104.  
  105. public Recordstop(id, type) {
  106.    
  107.     if(is_user_connected(id))
  108.     {
  109.         if (a3r_players[id][0] == 1)
  110.         {
  111.             set_hudmessage(200, 100, 0, -1.0,0.12, 0,0.0, 6.0, 0.0, 0.0, 3)
  112.             if (type == 1)
  113.             {
  114.                 show_hudmessage(id, "Player Left - Recording Halted")
  115.                 } else {
  116.                 show_hudmessage(id, "Recording Halted")
  117.             }
  118.             client_cmd(id, "stop")
  119.             } else {
  120.             set_hudmessage(200, 100, 0, -1.0,0.12, 0,0.0, 6.0, 0.0, 0.0, 3)
  121.             show_hudmessage(id, "Not Recording")
  122.         }
  123.     }
  124.    
  125.     a3r_players[id][0] = 0
  126.     a3r_players[id][1] = 0
  127.     a3r_players[id][2] = 0
  128.    
  129.     return PLUGIN_HANDLED
  130. }
  131.  
  132. public toggleac(id) {
  133.    
  134.     if(is_user_connected(id)) {
  135.         if(a3r_players[id][0] == 1)
  136.         {
  137.             new authid[32]
  138.             get_user_authid(a3r_players[id][1],authid,31)
  139.            
  140.             if(a3r_players[id][2] == 1)
  141.             {
  142.                 a3r_players[id][2] = 0
  143.             }
  144.             else
  145.             {
  146.                 a3r_players[id][2] = 1
  147.             }
  148.         }
  149.     }
  150.     return PLUGIN_HANDLED
  151. }
  152.  
  153. public manualstop(id) {
  154.    
  155.     if (a3r_players[id][0] == 1) {
  156.         Recordstop(id, 2)
  157.     }
  158.    
  159.     return PLUGIN_CONTINUE
  160. }
  161.  
  162. displayRecordMenu(id,pos){
  163.    
  164.     if (pos < 0)  return
  165.    
  166.     get_players(g_menuPlayers[id],g_menuPlayersNum[id])
  167.    
  168.     new menuBody[512]
  169.     new b = 0
  170.     new i
  171.     new name[32]
  172.     new start = pos * 8
  173.    
  174.     if (start >= g_menuPlayersNum[id])
  175.     {
  176.         start = pos = g_menuPosition[id] = 0
  177.     }
  178.    
  179.     new len = format(menuBody,511,"\yRecord:\R%d/%d^n\w^n",pos+1,(  g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0 )) )
  180.    
  181.     new end = start + 8
  182.     new keys = (1<<9)
  183.    
  184.     if (end > g_menuPlayersNum[id])
  185.         end = g_menuPlayersNum[id]
  186.    
  187.     for(new a = start; a < end; ++a)
  188.     {
  189.         i = g_menuPlayers[id][a]
  190.         get_user_name(i,name,31)
  191.        
  192.         if ( i == id ) {
  193.             ++b
  194.             len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name)
  195.         }
  196.         else
  197.         {
  198.             keys |= (1<<b)
  199.             len += format(menuBody[len],511-len,"%d. %s^n",++b,name)
  200.         }
  201.     }
  202.    
  203.     if (end != g_menuPlayersNum[id])
  204.     {
  205.         format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
  206.         keys |= (1<<8)
  207.     }
  208.     else  format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
  209.    
  210.     show_menu(id,keys,menuBody)
  211.    
  212. }
  213. //----------------------------------------------------------------------------------------------
  214. public cmdRecordMenu(id,level,cid)
  215. {
  216.     displayRecordMenu(id,g_menuPosition[id] = 0)
  217.    
  218.     return PLUGIN_HANDLED
  219. }
  220. //----------------------------------------------------------------------------------------------
  221.  
  222. public record_sbstatus(id)
  223. {
  224.     client_cmd(id, "sb_status")
  225.     client_print(id, print_chat, "[ A3R ] * sb_status completed *")
  226.    
  227.     return PLUGIN_CONTINUE
  228. }
  229.  
  230. public record_status(id)
  231. {
  232.     client_cmd(id, "status")
  233.     client_print(id, print_chat, "[ A3R ] * status completed *")
  234.    
  235.     return PLUGIN_CONTINUE
  236. }
  237.  
  238. public check_spectated()
  239. {
  240.     if(get_cvar_num("a3r_autocycle") == 0)
  241.     {
  242.         return PLUGIN_CONTINUE
  243.     }
  244.    
  245.     for(new id = 1 ; id <= maxplayers ; id++)
  246.     {
  247.         if(is_user_connected(id) && a3r_players[id][2] == 1 && !is_user_alive(id))
  248.         {
  249.             if (is_user_alive(a3r_players[id][1])) {
  250.                 if(entity_get_int(id, EV_INT_iuser1) != 4)
  251.                 {
  252.                     entity_set_int(id, EV_INT_iuser1, 4)
  253.                 }
  254.                
  255.                 new spectated = entity_get_int(id, EV_INT_iuser2)
  256.                
  257.                 if (!is_user_connected(id))
  258.                 {
  259.                     Recordstop(id, 1)
  260.                 }
  261.                 else
  262.                 {
  263.                     /*
  264.                     Problematic.. On publics this will cause your view to skew, the player
  265.                     will seem to be looking in only one direction and your POV will warp
  266.                     across the map. But this is what will replace the code below, so cycling
  267.                     will be a thing of the past.
  268.                    
  269.                     if(a3r_players[id][1] != spectated)
  270.                     {
  271.                         entity_set_int(id, EV_INT_iuser2, a3r_players[id][1])
  272.                         set_hudmessage(200, 100, 0, -1.0,0.14, 0,0.0, 1.0, 0.5, 0.5, 2)
  273.                         show_hudmessage(id, "On Target")
  274.                     }
  275.                     */
  276.                    
  277.                     if(a3r_players[id][1] != spectated)
  278.                     {
  279.                         ontarget = 0
  280.                        
  281.                         set_hudmessage(200, 100, 0, -1.0,0.14, 0,0.0, 1.0, 0.5, 0.5, 2)
  282.                         show_hudmessage(id, "Clycling...")
  283.                         if(get_cvar_num("a3r_revcycle") == 0) {
  284.                             client_cmd(id,"+attack2;wait;-attack2")
  285.                             } else {
  286.                             client_cmd(id,"+attack;wait;-attack")
  287.                         }
  288.                     }
  289.                     else
  290.                     {
  291.                         if (ontarget == 0)
  292.                         {
  293.                            
  294.                             set_hudmessage(200, 100, 0, -1.0,0.14, 0,0.0, 1.0, 0.5, 0.5, 2)
  295.                             show_hudmessage(id, "On Target")
  296.                             ontarget = 1
  297.                         }
  298.                     }
  299.                 }
  300.             }
  301.         }
  302.     }
  303.    
  304.     return PLUGIN_CONTINUE
  305. }
  306.  
  307. public check_hudmessage() {
  308.     for(new a = 1; a <= maxplayers; ++a) {
  309.        
  310.         if (a3r_players[a][0] == 1) {
  311.             new authid[32], line[128]
  312.             get_user_authid(a3r_players[a][1],authid,31)
  313.            
  314.             if(a3r_players[a][2] == 1)
  315.             {
  316.                 format (line, 127, "Recording %s | AutoCycle: On", authid)
  317.             }
  318.             else
  319.             {
  320.                 format (line, 127, "Recording %s | AutoCycle: Off", authid)
  321.             }
  322.            
  323.             set_hudmessage(200, 100, 0, -1.0,0.12, 0,6.0, 1.0, 0.5, 0.5, 3)
  324.             show_hudmessage(a, line)   
  325.            
  326.             if (!is_user_alive(a3r_players[a][1])) {
  327.                 new line2[128]
  328.                 format (line2, 127, "User is dead", authid)
  329.                
  330.                 set_hudmessage(200, 100, 0, -1.0,0.14, 0,0.0, 1.0, 0.5, 0.5, 2)
  331.                 show_hudmessage(a, line2)  
  332.             }
  333.            
  334.         }
  335.     }
  336.     return PLUGIN_CONTINUE
  337. }
  338.  
  339. public client_disconnect(id){
  340.    
  341.     for(new a = 1; a <= maxplayers; ++a) {
  342.        
  343.         if (a3r_players[a][1] == id) {
  344.             Recordstop(a, 1)
  345.         }
  346.     }
  347.    
  348.    
  349.     if (a3r_players[id][0] == 1) {
  350.         Recordstop(id, 2)
  351.     }
  352.    
  353.     return PLUGIN_CONTINUE
  354. }
  355. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  356. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2057\\ f0\\ fs16 \n\\ par }
  357. */
Advertisement
Add Comment
Please, Sign In to add comment