laurentiuarion

Prestrafe

Feb 11th, 2020
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fun>
  4. #include <colorchat>
  5.  
  6. new Float:fMaxGroundSpeed[33];
  7. new Float:fSpeed;
  8. new Float:vVelocity[3];
  9. new bool:gInAir[33];
  10.  
  11. new bool:gHasPre[33];
  12.  
  13. public plugin_init() {
  14.     register_plugin("Prestrafe Shower", "0.03", "Ex3cuTioN");
  15.    
  16.     register_clcmd("say /prestrafe", "cmdPre", ADMIN_ALL, "- enabled/disables visible prestrafe");
  17.     register_clcmd("say /pre", "cmdPre", ADMIN_ALL, "- enabled/disables visible prestrafe");
  18.    
  19.     register_forward(FM_PlayerPreThink,  "fwdPlayerPreThink",  0);
  20. }
  21.  
  22. public client_putinserver(id) gHasPre[id] = true;
  23.  
  24. public client_disconnect(id) gHasPre[id] = false;
  25.  
  26. public cmdPre(id) {
  27.     if(!gHasPre[id] ) {
  28.         gHasPre[id] = true;
  29.         ColorChat(id,GREEN,"[HNS]^x01 Prestrafe shower^x03 activat.");
  30.     }
  31.     else {
  32.         gHasPre[id] = false;
  33.         ColorChat(id,GREEN,"[HNS]^x01 Prestrafe shower^x03 dezactivat.");
  34.     }
  35. }
  36.  
  37. public gocheck(id) gInAir[id] = false;
  38.  
  39. public fwdPlayerPreThink(id) {
  40.     if(is_user_alive(id) && gHasPre[id]) {
  41.         static flags, buttons;
  42.        
  43.         flags = pev(id, pev_flags);
  44.         buttons = pev(id, pev_button);
  45.        
  46.         pev(id, pev_velocity, vVelocity);
  47.        
  48.         if(flags&FL_ONGROUND && flags&FL_INWATER) vVelocity[2] = 0.0;
  49.            
  50.         fSpeed = vector_length(vVelocity);
  51.        
  52.         pev(id, pev_velocity, vVelocity);
  53.        
  54.         if(vVelocity[2] != 0) vVelocity[2]-=vVelocity[2];
  55.        
  56.         if(buttons&IN_JUMP && flags&FL_ONGROUND && gInAir[id] == false) {
  57.             set_task(0.4,"gocheck", id);
  58.            
  59.             gInAir[id] = true;
  60.            
  61.             fMaxGroundSpeed[id] = fSpeed;
  62.            
  63.             new Float:maxspeed;
  64.             maxspeed = get_user_maxspeed(id);
  65.            
  66.             if(!fMaxGroundSpeed[id]) return FMRES_IGNORED;
  67.            
  68.             for(new i = 1; i < 33; i++) {
  69.                 if(i == id || is_user_spectating_player(i, id) && gHasPre[i]) {
  70.                     if(maxspeed * 1.2 < fMaxGroundSpeed[id]) {
  71.                         set_hudmessage(255, 0, 109, -1.0, 0.60, 0, 6.0, 0.5);
  72.                         show_hudmessage(i, "Prestrafe too high: %.03f (%.03f)",fMaxGroundSpeed[id], maxspeed * 1.2);
  73.                        
  74.                         client_cmd(i,"echo;echo Prestrafe too high: %.03f (%.03f);echo", fMaxGroundSpeed[id], maxspeed * 1.2);
  75.                     }
  76.                     else {
  77.                         set_hudmessage(255, 255, 255, -1.0, 0.60, 0, 6.0, 0.5);
  78.                         show_hudmessage(i, "Prestrafe: %.03f",fMaxGroundSpeed[id]);
  79.                    
  80.                         client_cmd(i,"echo;echo Prestrafe: %.03f;echo", fMaxGroundSpeed[id]);
  81.                     }
  82.                 }
  83.             }
  84.         }
  85.     }
  86.     return FMRES_IGNORED;
  87. }
  88.  
  89. stock is_user_spectating_player(spectator, player) {
  90.     if(!pev_valid(spectator) || !pev_valid(player))
  91.         return 0;
  92.     if(!is_user_connected(spectator) || !is_user_connected(player))
  93.         return 0;
  94.     if(is_user_alive(spectator) || !is_user_alive(player))
  95.         return 0;
  96.     if(pev(spectator, pev_deadflag) != 2)
  97.         return 0;
  98.    
  99.     static specmode;
  100.    
  101.     specmode = pev(spectator, pev_iuser1);
  102.    
  103.     if(!(specmode == 1 || specmode == 2 || specmode == 4))
  104.         return 0;
  105.    
  106.     if(pev(spectator, pev_iuser2) == player)
  107.         return 1;
  108.    
  109.     return 0;
  110. }
RAW Paste Data