SHARE
TWEET

Untitled

a guest Jul 20th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5. #include <nox_mbhop>
  6. #include <nox_ashop>
  7. #include <smlib>
  8.  
  9. // ----------------------------- Macro ---------------------------
  10. #define LoopClients(%1) for(int %1 = 1; %1 <= MaxClients; %1++)\
  11. if(IsClientInGame(%1) && !IsFakeClient(%1))
  12.  
  13. enum VelocityOverride
  14. {
  15.     VelocityOvr_None = 0,
  16.     VelocityOvr_Velocity,
  17.     VelocityOvr_OnlyWhenNegative,
  18.     VelocityOvr_InvertReuseVelocity
  19. };
  20.  
  21. int g_iClientJumps                  [MAXPLAYERS+1];
  22. int g_iClientMaxJumps               [MAXPLAYERS+1];
  23. bool g_bAuto                        [MAXPLAYERS+1];
  24.  
  25. float g_flPlugin_Boost_Double       = 290.0;
  26. float g_flPlugin_Boost_Forward      = 50.0;
  27.  
  28. int g_Offset_m_flStamina            = -1;
  29. int g_Offset_m_flVelocityModifier   = -1;
  30.  
  31. public Plugin myinfo =
  32. {
  33.     name = "[n.o.x] Multi BHOP",
  34.     author = "n.o.x",
  35.     description = "| System BHOP pozwalający na wykonanie dodatkowych skoków w powietrzu |",
  36.     version = "1.0B",
  37.     url = "http://noxsp.pl"
  38. }
  39.  
  40. public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
  41. {
  42.     CreateNative("MBHOP_GetClientJumpsCount",   Native_GetClientJumpsCount);
  43.     CreateNative("MBHOP_SetClientJumpsCount",   Native_SetClientJumpsCount);
  44.     CreateNative("MBHOP_AddClientJumps",        Native_AddClientJumps);
  45.     CreateNative("MBHOP_SubClientJumps",        Native_SubClientJumps);
  46.    
  47.     RegPluginLibrary("nox_mbhop");
  48.     return APLRes_Success;
  49. }
  50.  
  51. public void OnPluginStart()
  52. {
  53.     RegConsoleCmd("sm_autobh",  CMD_AutoBH, "Wlacz/Wylacz AutoBHOP.");
  54.     RegConsoleCmd("sm_auto",    CMD_AutoBH, "Wlacz/Wylacz AutoBHOP.");
  55.     RegConsoleCmd("sm_ab",      CMD_AutoBH, "Wlacz/Wylacz AutoBHOP.");
  56. }
  57.  
  58. public Action ___________________________________________________________(){}
  59. public void OnClientPutInServer(int client)
  60. {
  61.     g_iClientMaxJumps[client] = 0;
  62.     if(g_Offset_m_flStamina != -1 && g_Offset_m_flVelocityModifier != -1)
  63.         return;
  64.    
  65.     if(!IsValidEntity(client))
  66.         return;
  67.    
  68.     char netclass[64];
  69.     GetEntityNetClass(client, netclass, sizeof(netclass));
  70.    
  71.     g_Offset_m_flStamina = FindSendPropInfo(netclass, "m_flStamina");
  72.     g_Offset_m_flVelocityModifier = FindSendPropInfo(netclass, "m_flVelocityModifier");
  73. }
  74.  
  75. public void OnClientDisconnect(int client)
  76. {
  77.     g_iClientMaxJumps[client] = 0;
  78. }
  79.  
  80. public Action __________________________________________________________(){}
  81. public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
  82. {
  83.     return HandleJumping(client, buttons);
  84. }
  85.  
  86. public Action _________________________________________________________(){}
  87. public Action CMD_AutoBH(int client, int args)
  88. {
  89.     if(!IsValidClient(client))
  90.         return Plugin_Handled;
  91.    
  92.     g_bAuto[client] = !g_bAuto[client];
  93.     PrintToChat(client, " \x02[\x04MBHOP\x02] \x04Autobhop został \x02%s.", g_bAuto[client]? "\x04włączony":"\x02wyłączony");
  94.  
  95.     return Plugin_Handled;
  96. }
  97.  
  98. public Action ________________________________________________________(){}
  99. public Action HandleJumping(int client, int &buttons)
  100. {
  101.     if(Client_GetWaterLevel(client) > Water_Level:WATER_LEVEL_FEET_IN_WATER)
  102.         return Plugin_Continue;
  103.    
  104.     if(Client_IsOnLadder(client))
  105.         return Plugin_Continue;
  106.    
  107.     static ls_iLastButtons[MAXPLAYERS+1] = {0,...};
  108.     static ls_iLastFlags[MAXPLAYERS+1] = {0,...};
  109.    
  110.     int flags = GetEntityFlags(client);
  111.    
  112.     float clientEyeAngles[3];
  113.     GetClientEyeAngles(client, clientEyeAngles);
  114.    
  115.     if(flags & FL_ONGROUND)
  116.         g_iClientJumps[client] = 1;
  117.    
  118.     if(buttons & IN_JUMP)
  119.     {
  120.         if(flags & FL_ONGROUND)
  121.         {
  122.             if(g_flPlugin_Boost_Forward != 0.0)
  123.             {
  124.                 clientEyeAngles[0] = 0.0;
  125.                
  126.                 if(buttons & IN_BACK){
  127.                     clientEyeAngles[1] += 180.0;
  128.                     Client_Push(client,clientEyeAngles,g_flPlugin_Boost_Forward,VelocityOverride:{VelocityOvr_None,VelocityOvr_None,VelocityOvr_None});
  129.                 }
  130.                
  131.                 if(buttons & IN_MOVELEFT){
  132.                     clientEyeAngles[1] += 90.0;
  133.                     Client_Push(client,clientEyeAngles,g_flPlugin_Boost_Forward,VelocityOverride:{VelocityOvr_None,VelocityOvr_None,VelocityOvr_None});
  134.                 }
  135.                
  136.                 if(buttons & IN_MOVERIGHT){
  137.                     clientEyeAngles[1] += -90.0;
  138.                     Client_Push(client,clientEyeAngles,g_flPlugin_Boost_Forward,VelocityOverride:{VelocityOvr_None,VelocityOvr_None,VelocityOvr_None});
  139.                 }
  140.             }
  141.            
  142.             ls_iLastButtons[client] = buttons;
  143.         }
  144.         else
  145.         {
  146.             if(!(ls_iLastButtons[client] & IN_JUMP))
  147.                 Client_DoubleJump(client);
  148.            
  149.             ls_iLastButtons[client] = buttons;
  150.             buttons &= ~IN_JUMP;
  151.         }
  152.     }
  153.     else
  154.         ls_iLastButtons[client] = buttons;
  155.     ls_iLastFlags[client] = flags;
  156.     return Plugin_Continue;
  157. }
  158.  
  159. public void Client_JumpSys_Initialize(client)
  160. {
  161.     if(g_Offset_m_flStamina != -1 && g_Offset_m_flVelocityModifier != -1)
  162.         return;
  163.    
  164.     if(!IsValidEntity(client))
  165.         return;
  166.    
  167.     char netclass[64];
  168.     GetEntityNetClass(client,netclass,sizeof(netclass));
  169.    
  170.     g_Offset_m_flStamina = FindSendPropInfo(netclass,"m_flStamina");
  171.     g_Offset_m_flVelocityModifier = FindSendPropInfo(netclass,"m_flVelocityModifier");
  172. }
  173.  
  174. public void Client_Push(int client, float clientEyeAngle[3], float power, VelocityOverride:override[3])
  175. {
  176.     float forwardVector[3], newVel[3];
  177.    
  178.     GetAngleVectors(clientEyeAngle, forwardVector, NULL_VECTOR, NULL_VECTOR);
  179.     NormalizeVector(forwardVector, forwardVector);
  180.     ScaleVector(forwardVector, power);
  181.    
  182.     Entity_GetAbsVelocity(client,newVel);
  183.    
  184.     for(int i=0;i<3;i++)
  185.     {
  186.         switch(override[i])
  187.         {
  188.             case VelocityOvr_Velocity: newVel[i] = 0.0;
  189.             case VelocityOvr_OnlyWhenNegative: if(newVel[i] < 0.0) newVel[i] = 0.0;
  190.             case VelocityOvr_InvertReuseVelocity: if(newVel[i] < 0.0) newVel[i] *= -1.0;
  191.         }
  192.        
  193.         newVel[i] += forwardVector[i];
  194.     }
  195.    
  196.     Entity_SetAbsVelocity(client,newVel);
  197. }
  198.  
  199. public void Client_DoubleJump(client)
  200. {
  201.     if((1 <= g_iClientJumps[client] <= g_iClientMaxJumps[client]))
  202.     {
  203.         g_iClientJumps[client]++;
  204.         Client_Push(client, view_as<float>({-90.0,0.0,0.0}),g_flPlugin_Boost_Double,VelocityOverride:{VelocityOvr_None,VelocityOvr_None,VelocityOvr_Velocity});
  205.     }
  206. }
  207.  
  208. public Action _______________________________________________________(){}
  209. public Native_GetClientJumpsCount(Handle plugin, int numParams)
  210. {
  211.     return g_iClientMaxJumps[GetNativeCell(1)];
  212. }
  213.  
  214. public Native_SetClientJumpsCount(Handle plugin, int numParams)
  215. {
  216.     g_iClientMaxJumps[GetNativeCell(1)] = GetNativeCell(2);
  217. }
  218.  
  219. public Native_AddClientJumps(Handle plugin, int numParams)
  220. {
  221.     g_iClientMaxJumps[GetNativeCell(1)] += GetNativeCell(2);
  222. }
  223.  
  224. public Native_SubClientJumps(Handle plugin, int numParams)
  225. {
  226.     g_iClientMaxJumps[GetNativeCell(1)] -= GetNativeCell(2);
  227. }
  228.  
  229. public Action _____________________________________________________(){}
  230. bool IsValidClient(client)
  231. {
  232.     if(client >= 1 && client <= MaxClients && IsClientInGame(client))
  233.         return true;
  234.  
  235.     return false;
  236. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top