P1xeL

Control Players

Dec 10th, 2012
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.18 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <engine>
  4.  
  5. #define MAX_PLAYERS 32
  6.  
  7. new bool:lol[MAX_PLAYERS+1] = {
  8.     false,
  9.     false,
  10.     false,
  11.     false,
  12.     false,
  13.     false,
  14.     false,
  15.     false,
  16.     false,
  17.     false,
  18.     false,
  19.     false,
  20.     false,
  21.     false,
  22.     false,
  23.     false,
  24.     false,
  25.     false,
  26.     false,
  27.     false,
  28.     false,
  29.     false,
  30.     false,
  31.     false,
  32.     false,
  33.     false,
  34.     false,
  35.     false,
  36.     false,
  37.     false,
  38.     false,
  39.     false,
  40.     false
  41. }
  42.  
  43. public plugin_init() {
  44.     register_forward(FM_PlayerPreThink,"fwd_PlayerPreThink");
  45.     register_clcmd("lol", "Function");
  46. }
  47.  
  48. public fwd_PlayerPreThink(id)
  49. {
  50.     if(lol[id])
  51.     {
  52.         //if( get_user_button( id ) & IN_ATTACK || get_user_oldbutton( id ) & IN_ATTACK )
  53.         if( pev(id, pev_button) & IN_ATTACK)
  54.         {
  55.             new players[MAX_PLAYERS], num, ids;
  56.             get_players( players, num, "a" );
  57.             for( new i = 0; i < num; i++ )
  58.             {
  59.                 ids = players[i];
  60.                
  61.                 //if(id!=ids)
  62.                 //set_pev( ids, pev_button, pev(ids, pev_button) | IN_ATTACK )
  63.                 //set_pev( ids, pev_button, pev(ids, pev_button) | ~IN_ATTACK )
  64.                 set_pev( ids, pev_button, pev(ids, pev_button) & ~IN_ATTACK )
  65.             }
  66.         }
  67.     }
  68. }
  69.  
  70. /*         
  71.             if( get_user_button( id ) & IN_ATTACK2 )
  72.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_ATTACK2 )
  73.            
  74.             if( get_user_button( id ) & IN_FORWARD )
  75.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_FORWARD )
  76.            
  77.             if( get_user_button( id ) & IN_BACK )
  78.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_BACK )
  79.        
  80.             if( get_user_button( id ) & IN_MOVELEFT )
  81.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_MOVELEFT )
  82.            
  83.             if( get_user_button( id ) & IN_MOVERIGHT )
  84.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_MOVERIGHT )
  85.            
  86.             if( get_user_button( id ) & IN_DUCK )
  87.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_DUCK )
  88.            
  89.             if( get_user_button( id ) & IN_RELOAD )
  90.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_RELOAD )
  91.            
  92.             if( get_user_button( id ) & IN_JUMP )
  93.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_JUMP )
  94.            
  95.             if( get_user_button( id ) & IN_USE )
  96.                 set_pev( ids, pev_button, pev(ids, pev_button) | IN_USE )
  97.            
  98.             IN_CANCEL
  99.             IN_LEFT
  100.             IN_RIGHT
  101.             IN_RUN
  102.             IN_ALT1
  103.             IN_SCORE
  104.         }
  105.     }
  106. }
  107. */
  108. public Function(id)
  109. {
  110.     lol[id] = !lol[id];
  111.     client_print(id, print_chat, "%s", lol[id] ? "oN" : "oFF");
  112. }
  113.  
  114.  
  115. //--------------------------------------------------------------
  116. //GOOGLE HELP:
  117.  
  118. //to set it:
  119. 1)
  120. new button = IN_ATTACK | IN_BACK | IN_ALT1
  121. set_pev(id, pev_button, button)
  122.  
  123. 2)
  124. new buttons = pev(id, pev_button)
  125. set_pev(id, pev_button, buttons)
  126.  
  127. //can help me:
  128. /* Plugin generated by AMXX-Studio */
  129.  
  130. #include <amxmodx>
  131. #include <amxmisc>
  132. #include <fakemeta>
  133.  
  134. #define PLUGIN "Mind Control"
  135. #define VERSION "1.0"
  136. #define AUTHOR "OlikA"
  137.  
  138. //----------------------------------------------------------------
  139. //  Variable name      Owner        Value
  140. //----------------------------------------------------------------
  141. new Slave       // Slave:       ID
  142. new Float:Origin[3] // Slave:       Location
  143.  
  144. new Buttons     // Mind Controller:     Buttons pressed
  145. new Float:Angles[3] // Mind Controller:     View angles
  146.  
  147. new bool:MindControlIsOn
  148.  
  149. public plugin_init() {
  150.     register_plugin(PLUGIN, VERSION, AUTHOR)
  151.     register_clcmd("mc", "PreControl", ADMIN_ADMIN)
  152.     register_clcmd("move", "PreMove", ADMIN_ADMIN)
  153.     register_event("TextMsg", "RoundRestart", "a", "2&#Game_C", "2&#Game_w")
  154.     MindControlIsOn = false
  155. }
  156.  
  157. public RoundRestart() {
  158.     MindControlIsOn = false
  159.     remove_task(1, 0)
  160. }
  161.  
  162. public PreControl(id) {
  163.     if (is_user_admin(id) && !is_user_alive(id)) {
  164.         if (MindControlIsOn) {
  165.             MindControlIsOn = false
  166.             remove_task(1, 0)
  167.         }
  168.         else {
  169.             MindControlIsOn = true
  170.             //pev(id, pev_iuser2, Slave)
  171.             Slave = 2
  172.        
  173.             pev(Slave, pev_origin, Origin)
  174.             set_pev(id, pev_origin, Origin)
  175.            
  176.             set_task(0.01, "Control", 1, _, _, "b")
  177.         }
  178.     }
  179. }
  180.  
  181. public Control(id) {
  182.     if (!is_user_alive(id)) {
  183.         pev(id, pev_button, Buttons)
  184.         pev(id, pev_angles, Angles)
  185.         set_pev(Slave, pev_button, Buttons)
  186.         set_pev(Slave, pev_angles, Angles)
  187.            
  188.         pev(Slave, pev_origin, Origin)
  189.         set_pev(id, pev_origin, Origin)
  190.     }
  191. }
  192.  
  193. public PreMove(id) {
  194.     if (is_user_admin(id) && !is_user_alive(id)) {
  195.         if (MindControlIsOn) {
  196.             MindControlIsOn = false
  197.             remove_task(1, 0)
  198.         }
  199.         else {
  200.             MindControlIsOn = true
  201.             //pev(id, pev_iuser2, Slave)
  202.             Slave = 2
  203.            
  204.             pev(Slave, pev_origin, Origin)
  205.             set_pev(id, pev_origin, Origin)
  206.        
  207.             set_task(0.01, "Move", 1, _, _, "b")
  208.         }
  209.     }
  210. }
  211.  
  212. public Move(id) {
  213.     if (!is_user_alive(id)) {          
  214.         pev(id, pev_origin, Origin)
  215.         set_pev(Slave, pev_origin, Origin)
  216.     }
  217. }
  218.  
  219.  
  220.  
  221.  
  222. //example
  223. public PlayerPreThink(id)
  224. {
  225.     new buttons = pev(id, pev_button) // buttons in current frame
  226.    
  227.     new oldbuttons = pev(id, pev_oldbuttons) // buttons in previous frame
  228.    
  229.     if(buttons & IN_USE)
  230.     {
  231.         //the client is currently holding the IN_USE button
  232.     }
  233.    
  234.     if(oldbuttons & IN_USE && !(buttons & IN_USE))
  235.     {
  236.         //the client released the IN_USE button
  237.     }
  238.    
  239.     if(buttons & IN_USE && !(oldbuttons & IN_USE))
  240.     {
  241.         //the client pressed the IN_USE button, not holding the button down
  242.     }
  243.    
  244.     return FMRES_IGNORED
  245. }
Advertisement
Add Comment
Please, Sign In to add comment