Ruzio Napisano 5 Listopada 2020 (edytowane) // [BIBLIOTEKI FUNKCJI] #include <sourcemod> #include <sdktools> #include <sdkhooks> #include <cstrike> // [Rejestrowanie eventu] public OnPluginStart() { HookEvent("player_spawn", player_spawn); } // [Funkcja] public player_spawn(Handle:event, const String:name[], bool:dontBroadcast) { if(GetClientTeam(victim)==CS_TEAM_T) } public void OnPluginStart() { g_cMessage_Type = CreateConVar("sm_no_knife_damage_", "1", "Powiadomienie: 0 - Brak | 1 - Czat | 2 - Hint | 3 - Czat + Hint", 0); g_cMessage_Type.AddChangeHook(OnCvarChange); g_iMessage_Type = g_cMessage_Type.IntValue; AutoExecConfig(true, "No_Knife_Damage"); } public void OnCvarChange(ConVar cvar, char[] oldValue, char[] newValue) { g_iMessage_Type = StringToInt(newValue); } public void OnClientPutInServer(int client) { SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); } public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) { if(!IsValidClient(attacker)) return Plugin_Continue; char sWeaponName[64]; GetClientWeapon(attacker, sWeaponName, sizeof(sWeaponName)); if(StrContains(sWeaponName, "knife", false) != -1 || StrContains(sWeaponName, "bayonet", false) != -1 && if(GetClientTeam(victim)==CS_TEAM_T) { damage = 0.0; return Plugin_Changed; } return Plugin_Continue; } bool IsValidClient(int client) { return (1 <= client <= MaxClients && IsClientInGame(client)); } Prosilbym kogos o przerobienie tego pluginu w taki sposob zeby nie szlo zadawac terroryscie zadnego dmg z wszystkich nozy istniejacych lub zrobic jakis nowy krotszy Edytowane 5 Listopada 2020 przez Ruzio Cytuj Udostępnij tę odpowiedź Odnośnik do odpowiedzi Udostępnij na innych stronach
Maroxx Napisano 5 Listopada 2020 (edytowane) if(StrContains(sWeaponName, "knife", false) != -1 || StrContains(sWeaponName, "bayonet", false) != -1 && if(GetClientTeam(victim)==CS_TEAM_T) XD Edytowane 6 Listopada 2020 przez Maroxx Cytuj Udostępnij tę odpowiedź Odnośnik do odpowiedzi Udostępnij na innych stronach
Ruzio Napisano 5 Listopada 2020 59 minut temu, Maroxx napisał: if(StrContains(sWeaponName, "knife", false) != -1 || StrContains(sWeaponName, "bayonet", false) != -1 && if(GetClientTeam(victim)==CS_TEAM_T) za -1 dodajesz StrContains(sWeaponName, "bayonet", false) != -1 tylko zmieniasz sobie to co jest w "" niezbyt rozumiem 😞 Mozna troszke bardziej wytlumaczyc? Cytuj Udostępnij tę odpowiedź Odnośnik do odpowiedzi Udostępnij na innych stronach
Paweł Napisano 5 Listopada 2020 Spoiler Analiza wstawionego przez ciebie kodu: Spoiler // [BIBLIOTEKI FUNKCJI] #include <sourcemod> #include <sdktools> #include <sdkhooks> #include <cstrike> /* Nic to nie wnosi do kodu, poza tym masz 2x zaimplementowane OnPluginStart public OnPluginStart() { HookEvent("player_spawn", player_spawn); } // [Funkcja] public player_spawn(Handle:event, const String:name[], bool:dontBroadcast) { if(GetClientTeam(victim)==CS_TEAM_T) } */ public void OnPluginStart() { // Zdefiniuj może te zmienne globalne? g_cMessage_Type = CreateConVar("sm_no_knife_damage_", "1", "Powiadomienie: 0 - Brak | 1 - Czat | 2 - Hint | 3 - Czat + Hint", 0); g_cMessage_Type.AddChangeHook(OnCvarChange); g_iMessage_Type = g_cMessage_Type.IntValue; AutoExecConfig(true, "No_Knife_Damage"); } // XD? Nie zhookowałeś tej funkcji public void OnCvarChange(ConVar cvar, char[] oldValue, char[] newValue) { g_iMessage_Type = StringToInt(newValue); } public void OnClientPutInServer(int client) { // Jeżeli robisz hoooka dla clienta to wypada jeszcze zrobić unhooka, jeżeli gracz wychodzi z serwera. SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); } public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) { if (!IsValidClient(attacker)) return Plugin_Continue; char sWeaponName[64]; GetClientWeapon(attacker, sWeaponName, sizeof(sWeaponName)); // Jakim prawem robisz if'a w if'ie ??? if (StrContains(sWeaponName, "knife", false) != -1 || StrContains(sWeaponName, "bayonet", false) != -1 && if (GetClientTeam(victim) == CS_TEAM_T) damage = 0.0; return Plugin_Changed; } return Plugin_Continue; bool IsValidClient(int client) { return (1 <= client <= MaxClients && IsClientInGame(client)); } Poprawny kod: Spoiler #include <sourcemod> #include <sdktools> #include <sdkhooks> #include <cstrike> public void OnClientPutInServer(int client) { SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); } public void OnClientDisconnect(int client) { SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); } public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) { if (!IsValidClient(attacker) || !IsPlayerAlive(attacker)) return Plugin_Continue; if (GetClientTeam(attacker) == CS_TEAM_CT) { char sWeaponName[64]; GetClientWeapon(attacker, sWeaponName, sizeof(sWeaponName)); if (StrContains(sWeaponName, "knife", false) != -1 || StrContains(sWeaponName, "bayonet", false) != -1) { damage = 0.0; return Plugin_Changed; } } return Plugin_Continue; } bool IsValidClient(int client) { return (1 <= client <= MaxClients && IsClientInGame(client)); } Cytuj Udostępnij tę odpowiedź Odnośnik do odpowiedzi Udostępnij na innych stronach