Advertisement
FlacoBey

Untitled

Jul 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.49 KB | None | 0 0
  1. #include sdktools
  2.  
  3. #define MAXLIST 11
  4.  
  5. float fNextAttack[MAXPLAYERS + 1], flGameTime[MAXPLAYERS + 1], flLastTime[MAXPLAYERS + 1];
  6.  
  7. static const char gMelee[][] =
  8. {
  9.     "baseball_bat",
  10.     "cricket_bat",
  11.     "crowbar",
  12.     "electric_guitar",
  13.     "fireaxe",
  14.     "frying_pan",
  15.     "golfclub",
  16.     "katana",
  17.     "machete",
  18.     "tonfa",
  19.     "knife"
  20. };
  21.  
  22. static const char gModelsItemsList[MAXLIST][] =
  23. {
  24.     "models/weapons/melee/v_katana.mdl",                //0
  25.     "models/weapons/melee/v_fireaxe.mdl",               //1
  26.     "models/weapons/melee/v_machete.mdl",               //2
  27.     "models/weapons/melee/v_crowbar.mdl",               //3
  28.     "models/v_models/v_knife_t.mdl",                    //4
  29.     "models/weapons/melee/v_frying_pan.mdl",            //5
  30.     "models/weapons/melee/v_bat.mdl",                   //6
  31.     "models/weapons/melee/v_cricket_bat.mdl",           //7
  32.     "models/weapons/melee/v_tonfa.mdl",                 //8
  33.     "models/weapons/melee/v_electric_guitar.mdl",       //9
  34.     "models/weapons/melee/v_golfclub.mdl"               //10
  35. };
  36.  
  37. static const float gSpeed[] =
  38. {
  39.     0.04,
  40.     0.04,
  41.     0.04,
  42.     0.04,
  43.     0.00,
  44.     0.04,
  45.     0.04,
  46.     0.04,
  47.     0.04,
  48.     0.15,
  49.     0.04
  50. };
  51.  
  52. int g_iNextPAttO;
  53.  
  54. public void OnPluginStart()
  55. {
  56.     g_iNextPAttO        =   FindSendPropInfo("CBaseCombatWeapon","m_flNextPrimaryAttack");
  57. }
  58.  
  59. public void OnGameFrame()
  60. {
  61.     for(int i = 1;i < MaxClients; i++)
  62.     {
  63.         if(IsClientInGame(i))
  64.         {
  65.             int iCurrentWeapon = GetEntPropEnt(i, Prop_Send, "m_hActiveWeapon");
  66.             if(IsValidEntity(iCurrentWeapon))
  67.             {
  68.                 char sWeaponEx[56];
  69.                 GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof sWeaponEx);
  70.                 if(strcmp(sWeaponEx, "weapon_melee") == 0)
  71.                 {
  72.                     GetEntPropString(iCurrentWeapon, Prop_Data, "m_strMapSetScriptName", sWeaponEx, sizeof sWeaponEx);
  73.                     if(sWeaponEx[0] == 0)
  74.                     {
  75.                         char ModelName[128], sExplodeString[MAXLIST - 6][36];
  76.                         int iNum;
  77.                         for(int l; l < MAXLIST; l++)
  78.                         {
  79.                             if(strcmp(ModelName, gModelsItemsList[l]) == 0)
  80.                             {
  81.                                 iNum = ExplodeString(gModelsItemsList[l], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]);
  82.                                 ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", "");
  83.                                 if(StrContains(sExplodeString[iNum - 1], "knife") > 0)
  84.                                     ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", "");
  85.                                 else
  86.                                     ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", "");
  87.                                 TrimString(sExplodeString[iNum - 1]);
  88.                                 Format(sWeaponEx, sizeof sWeaponEx, "%s", sExplodeString[iNum - 1]);
  89.                                 break;
  90.                             }
  91.                         }
  92.                     }
  93.                     for(int v; v < 11; v++)
  94.                     {
  95.                         if(strcmp(sWeaponEx, gMelee[v]) == 0)
  96.                         {
  97.                             fNextAttack[i] = GetEntDataFloat(iCurrentWeapon, g_iNextPAttO);
  98.                             flGameTime[i] = GetGameTime();
  99.                             if ((flGameTime[i] - flLastTime[i]) > 0.5)
  100.                             {
  101.                                 SetEntDataFloat(iCurrentWeapon, g_iNextPAttO, fNextAttack[i] - gSpeed[v], true);
  102.                                 flLastTime[i] = GetGameTime();
  103.                             }
  104.                         }
  105.                     }
  106.                 }
  107.             }
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement