Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sdktools
- #define MAXLIST 11
- float fNextAttack[MAXPLAYERS + 1], flGameTime[MAXPLAYERS + 1], flLastTime[MAXPLAYERS + 1];
- static const char gMelee[][] =
- {
- "baseball_bat",
- "cricket_bat",
- "crowbar",
- "electric_guitar",
- "fireaxe",
- "frying_pan",
- "golfclub",
- "katana",
- "machete",
- "tonfa",
- "knife"
- };
- static const char gModelsItemsList[MAXLIST][] =
- {
- "models/weapons/melee/v_katana.mdl", //0
- "models/weapons/melee/v_fireaxe.mdl", //1
- "models/weapons/melee/v_machete.mdl", //2
- "models/weapons/melee/v_crowbar.mdl", //3
- "models/v_models/v_knife_t.mdl", //4
- "models/weapons/melee/v_frying_pan.mdl", //5
- "models/weapons/melee/v_bat.mdl", //6
- "models/weapons/melee/v_cricket_bat.mdl", //7
- "models/weapons/melee/v_tonfa.mdl", //8
- "models/weapons/melee/v_electric_guitar.mdl", //9
- "models/weapons/melee/v_golfclub.mdl" //10
- };
- static const float gSpeed[] =
- {
- 0.04,
- 0.04,
- 0.04,
- 0.04,
- 0.00,
- 0.04,
- 0.04,
- 0.04,
- 0.04,
- 0.15,
- 0.04
- };
- int g_iNextPAttO;
- public void OnPluginStart()
- {
- g_iNextPAttO = FindSendPropInfo("CBaseCombatWeapon","m_flNextPrimaryAttack");
- }
- public void OnGameFrame()
- {
- for(int i = 1;i < MaxClients; i++)
- {
- if(IsClientInGame(i))
- {
- int iCurrentWeapon = GetEntPropEnt(i, Prop_Send, "m_hActiveWeapon");
- if(IsValidEntity(iCurrentWeapon))
- {
- char sWeaponEx[56];
- GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof sWeaponEx);
- if(strcmp(sWeaponEx, "weapon_melee") == 0)
- {
- GetEntPropString(iCurrentWeapon, Prop_Data, "m_strMapSetScriptName", sWeaponEx, sizeof sWeaponEx);
- if(sWeaponEx[0] == 0)
- {
- char ModelName[128], sExplodeString[MAXLIST - 6][36];
- int iNum;
- for(int l; l < MAXLIST; l++)
- {
- if(strcmp(ModelName, gModelsItemsList[l]) == 0)
- {
- iNum = ExplodeString(gModelsItemsList[l], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]);
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", "");
- if(StrContains(sExplodeString[iNum - 1], "knife") > 0)
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", "");
- else
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", "");
- TrimString(sExplodeString[iNum - 1]);
- Format(sWeaponEx, sizeof sWeaponEx, "%s", sExplodeString[iNum - 1]);
- break;
- }
- }
- }
- for(int v; v < 11; v++)
- {
- if(strcmp(sWeaponEx, gMelee[v]) == 0)
- {
- fNextAttack[i] = GetEntDataFloat(iCurrentWeapon, g_iNextPAttO);
- flGameTime[i] = GetGameTime();
- if ((flGameTime[i] - flLastTime[i]) > 0.5)
- {
- SetEntDataFloat(iCurrentWeapon, g_iNextPAttO, fNextAttack[i] - gSpeed[v], true);
- flLastTime[i] = GetGameTime();
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement