#include //#include #define PLUGIN_VERSION "1.3.3.7" public Plugin:myinfo = { name = "No Freekilling", author = "Akuba", description = "A plugin for Bjorn", version = PLUGIN_VERSION }; int Kills[34] = 0; // 32 + console + replay int KillCheck[34] = -1; // -1 means disabled, -2 means deactivated Handle hTimer = INVALID_HANDLE; public void OnPluginStart() { HookEvent("player_death", OnPlayerDeath); RegAdminCmd("sm_freekill", FreeKillCmd, ADMFLAG_ROOT); if(hTimer == INVALID_HANDLE) { hTimer = CreateTimer(1.0, OnKillTimerCheck, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE); } } public void OnMapStart() { if(hTimer == INVALID_HANDLE) { hTimer = CreateTimer(1.0, OnKillTimerCheck, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE); } } public Action FreeKillCmd(client, args) { char arg1[32], arg2[32]; int state = 0; char target_name[MAX_TARGET_LENGTH]; int target_list[MAXPLAYERS], target_count; bool tn_is_ml; if (args < 1) { ReplyToCommand(client, "[SM] Usage: sm_freekill [on(1)/off(0)*]"); return Plugin_Handled; } if (args >= 2 && GetCmdArg(2, arg2, sizeof(arg2))) { state = StringToInt(arg2); } /*decl String:s2[12]; decl String:targetname[32]; GetCmdArg(1, targetname, sizeof(targetname)); GetCmdArg(2, s2, sizeof(s2)); new target = FindTarget(client, targetname); if (IsValidClient(target)) { if(KillCheck[target] != -2) { KillCheck[target] = -2; Kills[target] = 0; ReplyToCommand(client, "[SM] You disabled Anti-Freekilling for %N.", target); PrintToChat(target, "[SM] An Administrator disabled Anti-Freekilling on you."); } else { KillCheck[target] = -1; Kills[target] = 0; ReplyToCommand(client, "[SM] You enabled Anti-Freekilling for %N.", target); PrintToChat(target, "[SM] An Administrator enabled Anti-Freekilling on you. Better do not kill someone anymore."); } } else { ReplyToCommand(client, "[SM] Target is not valid."); }*/ if ((target_count = ProcessTargetString( arg1, client, target_list, MAXPLAYERS, 0, /* Allow All Players, set to COMMAND_FILTER_ALIVE to only select alive players */ target_name, sizeof(target_name), tn_is_ml)) <= 0) { ReplyToTargetError(client, target_count); return Plugin_Handled; } for (int i = 0; i < target_count; i++) { if(state == 1) { KillCheck[target_list[i]] = -1; Kills[target_list[i]] = 0; LogAction(client, target_list[i], "\"%L\" enabled Anti-Freekilling for \"%L\".", client, target_list[i]); PrintToChat(target_list[i], "[SM] An Administrator enabled Anti-Freekilling on you. Better do not kill someone anymore."); } else { KillCheck[target_list[i]] = -2; Kills[target_list[i]] = 0; LogAction(client, target_list[i], "\"%L\" disabled Anti-Freekilling for \"%L\".", client, target_list[i]); PrintToChat(target_list[i], "[SM] An Administrator disabled Anti-Freekilling on you."); } } if (tn_is_ml) // Translation needed? { if(state == 1) { ShowActivity2(client, "[SM] ", "enabled Anti-Freekilling on %t.", target_name); } else { ShowActivity2(client, "[SM] ", "disabled Anti-Freekilling on %t.", target_name); } } else { if(state == 1) { ShowActivity2(client, "[SM] ", "enabled Anti-Freekilling on %s.", target_name); } else { ShowActivity2(client, "[SM] ", "disabled Anti-Freekilling on %s.", target_name); } } return Plugin_Handled; } public void OnClientPostAdminCheck(int client) { if(!CheckCommandAccess(client, "sm_freekill_flag", ADMFLAG_ROOT, false)) { Kills[client] = 0; KillCheck[client] = -1; } else { Kills[client] = 0; KillCheck[client] = -2; } } public Action OnKillTimerCheck(Handle Timer) { for(new client=1; client<=MaxClients; client++) { if(KillCheck[client] > 0) { KillCheck[client]--; } else if (KillCheck[client] == 0) { KillCheck[client] = -1; Kills[client] = 0; } } } public Action OnPlayerDeath(Handle event, const String:name[], bool dontBroadcast) { int iClient = GetClientOfUserId(GetEventInt(event, "userid")); int iKiller = GetClientOfUserId(GetEventInt(event, "attacker")); if(KillCheck[iKiller] == -2) return Plugin_Continue; if((iKiller > 0 && iKiller <= 32) && IsClientInGame(iKiller) && (iKiller != iClient)) { Kills[iKiller]++; if(Kills[iKiller] == 3) { KillCheck[iKiller] = 60; PrintToChat(iKiller, "[SM] You killed 3 people so far. Cooldown for some time or you will be kicked."); } else if(Kills[iKiller] >= 3) { KickClient(iKiller, "You have been kicked for Freekilling."); return Plugin_Handled; } } return Plugin_Continue; } stock bool:IsValidClient(client, bool:replaycheck=true) { if(client<=0 || client>MaxClients) { return false; } if(!IsClientInGame(client)) { return false; } if(GetEntProp(client, Prop_Send, "m_bIsCoaching")) { return false; } if(replaycheck) { if(IsClientSourceTV(client) || IsClientReplay(client)) { return false; } } return true; }