haooy Napisano 29 Listopada 2019 (edytowane) Witam, szukam pluginu, który spowolni bicie kosą. Mam na myśli to, że gracz uderzy kosą i ma cooldown na ponowne udzerzenie przez np 5sec. Z góry dziękuje za pomoc. Pozdrawiam Edytowane 29 Listopada 2019 przez haooy Cytuj Udostępnij tę odpowiedź Odnośnik do odpowiedzi Udostępnij na innych stronach
Brum Brum 1 Napisano 29 Listopada 2019 Trzymaj. W 6 linijce zmieniasz sobie czas cooldownu 😉 Spoiler #include <sdktools> #pragma semicolon 1 #pragma newdecls required float cooldown = 5.0; float g_fClientUse[MAXPLAYERS + 1]; public Plugin myinfo = { name = "ADEPT --> Knife cooldown", description = "Autorski Plugin StudioADEPT.net", author = "Brum Brum", version = "1.0", url = "StudioADEPT.net/forum", }; public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float angles[3], float vel[3]){ if (!IsValidClient(client))return Plugin_Continue; if (CanUse(client) && buttons & IN_ATTACK || CanUse(client) && buttons & IN_ATTACK2) { char sWeapon[32]; GetClientWeapon(client, sWeapon, sizeof(sWeapon)); if (StrContains(sWeapon, "knife", false) != -1 || StrContains(sWeapon, "bayonet", false) != -1) { int knife = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"); RequestFrame(Cooldown, knife); g_fClientUse[client] = GetGameTime(); } } return Plugin_Continue; } public void Cooldown(int weapon){ SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime() + cooldown); SetEntPropFloat(weapon, Prop_Send, "m_flNextSecondaryAttack", GetGameTime() + cooldown); } bool CanUse(int client){ if (float(GetGameTime() - cooldown > g_fClientUse[client]))return true; return false; } public bool IsValidClient(int client) { if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || !IsClientConnected(client) || IsFakeClient(client) || IsClientSourceTV(client)) return false; return true; } Cytuj Udostępnij tę odpowiedź Odnośnik do odpowiedzi Udostępnij na innych stronach
haooy 1 Napisano 29 Listopada 2019 (edytowane) dzieki ❤️ wszystko ok, dodalem cvar na ten czas cooldownu i myslalem, ze plugin nie dziala(kilka razy moglem spamowac), ale to ja zle zmajstrowalem XD a wiec dzieki jeszcze raz:) z cvarem jak ktos woli: Spoiler #include <sdktools> #pragma semicolon 1 #pragma newdecls required ConVar cooldown; float cooldown1; float g_fClientUse[MAXPLAYERS + 1]; public Plugin myinfo = { name = "ADEPT --> Knife cooldown", description = "Autorski Plugin StudioADEPT.net", author = "Brum Brum", version = "1.0", url = "StudioADEPT.net/forum", }; public void OnPluginStart() { cooldown = CreateConVar("knife_cooldown", "5.0", "Ilosc czasu pomiedzy uderzaniem z kosy", _, true, 0.0, true, 100.0); AutoExecConfig(true, "knife_cooldown"); } public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float angles[3], float vel[3]){ if (!IsValidClient(client))return Plugin_Continue; if (CanUse(client) && buttons & IN_ATTACK || CanUse(client) && buttons & IN_ATTACK2) { char sWeapon[32]; GetClientWeapon(client, sWeapon, sizeof(sWeapon)); if (StrContains(sWeapon, "knife", false) != -1 || StrContains(sWeapon, "bayonet", false) != -1) { int knife = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"); RequestFrame(Cooldown, knife); g_fClientUse[client] = GetGameTime(); } } return Plugin_Continue; } public void Cooldown(int weapon){ cooldown1 = GetConVarFloat(cooldown); SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime() + cooldown1); SetEntPropFloat(weapon, Prop_Send, "m_flNextSecondaryAttack", GetGameTime() + cooldown1); } bool CanUse(int client){ cooldown1 = GetConVarFloat(cooldown); if (float(GetGameTime() - cooldown1 > g_fClientUse[client]))return true; return false; } public bool IsValidClient(int client) { if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || !IsClientConnected(client) || IsFakeClient(client) || IsClientSourceTV(client)) return false; return true; } Edytowane 29 Listopada 2019 przez haooy sprawdzone Cytuj Udostępnij tę odpowiedź Odnośnik do odpowiedzi Udostępnij na innych stronach