Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- #pragma newdecls required
- #pragma semicolon 1
- bool IsPoint[MAXPLAYERS+1] = false;
- int iCount[MAXPLAYERS+1] = 0;
- bool IsHeal[MAXPLAYERS+1] = false;
- int iCountHeal[MAXPLAYERS+1] = 0;
- public void OnPluginStart()
- {
- AddCommandListener(HookPlayerChat, "say");
- RegAdminCmd("sm_a", iAdmin, ADMFLAG_ROOT);
- }
- public Action iAdmin (int client, int args)
- {
- DisplayPlayersControl(client);
- }
- public Action HookPlayerChat(int iClient, const char[] sCommand, int iArgs)
- {
- if (StrEqual(sCommand, "say") || StrEqual(sCommand, "say_team"))
- {
- if(IsPoint[iClient])
- {
- char sArg[56];
- GetCmdArg(1, sArg, sizeof(sArg));
- if(StrEqual(sArg, "reset"))
- {
- IsPoint[iClient] = false;
- PrintToChat(iClient, "\x04•[A++] \x05Сброшено.");
- return Plugin_Handled;
- }
- else
- {
- DisplayHurtTarget(iClient);
- iCount[iClient] = StringToInt(sArg);
- IsPoint[iClient] = false;
- return Plugin_Handled;
- }
- }
- if(IsHeal[iClient])
- {
- char sArg[56];
- GetCmdArg(1, sArg, sizeof(sArg));
- if(StrEqual(sArg, "reset"))
- {
- IsPoint[iClient] = false;
- PrintToChat(iClient, "\x04•[A++] \x05Сброшено.");
- return Plugin_Handled;
- }
- else
- {
- DisplaySetHealT(iClient);
- iCountHeal[iClient] = StringToInt(sArg);
- IsHeal[iClient] = false;
- return Plugin_Handled;
- }
- }
- }
- return Plugin_Continue;
- }
- void DisplayPlayersControl(int client)
- {
- Handle MainPlayerControl = CreateMenu(CallbackPlayerControl);
- SetMenuTitle(MainPlayerControl, "Меню управление:");
- AddMenuItem(MainPlayerControl, "0", "Убить");
- AddMenuItem(MainPlayerControl, "1", "Кикнуть");
- AddMenuItem(MainPlayerControl, "2", "Нанести урон");
- AddMenuItem(MainPlayerControl, "3", "Вылечить");
- AddMenuItem(MainPlayerControl, "4", "Установить хп");
- SetMenuExitButton(MainPlayerControl, true);
- DisplayMenu(MainPlayerControl, client, MENU_TIME_FOREVER);
- }
- void DisplaySetHealT(int client)
- {
- Handle MainHurtTarget = CreateMenu(CallbackSetHealth);
- SetMenuTitle(MainHurtTarget, "Кому:");
- char userid[15];
- char name[32];
- AddMenuItem(MainHurtTarget, "0", "Всем");
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- IntToString(GetClientUserId(i), userid, 15);
- GetClientName(i, name, 32);
- AddMenuItem(MainHurtTarget, userid, name);
- }
- }
- SetMenuExitButton(MainHurtTarget, true);
- DisplayMenu(MainHurtTarget, client, MENU_TIME_FOREVER);
- }
- public int CallbackSetHealth(Handle CallbackMainHealTarget, MenuAction action, int client, int symbol)
- {
- if (action == MenuAction_End)
- {
- CloseHandle(CallbackMainHealTarget);
- return;
- }
- if (action != MenuAction_Select) return;
- if(symbol != 0)
- {
- char userid[15];
- GetMenuItem(CallbackMainHealTarget, symbol, userid, sizeof(userid));
- int target = GetClientOfUserId(StringToInt(userid));
- if (IsValidClient(target))
- {
- SetEntityHealth(target, iCountHeal[client]);
- SetEntPropFloat(target, Prop_Send, "m_healthBuffer", 0.0);
- PrintToChatAll("\x04•[A++] \x04%N установил игроку %N %i хп", client, target, iCountHeal[client]);
- }
- }
- else
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- SetEntityHealth(i, iCountHeal[client]);
- SetEntPropFloat(client, Prop_Send, "m_healthBuffer", 0.0);
- PrintToChat(i, "\x04•[A++] \x04%N установил всем %i хп", client, iCountHeal[client]);
- }
- }
- }
- }
- void DisplayHealTarget(int client)
- {
- Handle MainHurtTarget = CreateMenu(CallbackMainHealTarget);
- SetMenuTitle(MainHurtTarget, "Кого вылечить:");
- char userid[15];
- char name[32];
- AddMenuItem(MainHurtTarget, "0", "Всех");
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- IntToString(GetClientUserId(i), userid, 15);
- GetClientName(i, name, 32);
- AddMenuItem(MainHurtTarget, userid, name);
- }
- }
- SetMenuExitButton(MainHurtTarget, true);
- DisplayMenu(MainHurtTarget, client, MENU_TIME_FOREVER);
- }
- public int CallbackMainHealTarget(Handle CallbackMainHealTarget, MenuAction action, int client, int symbol)
- {
- if (action == MenuAction_End)
- {
- CloseHandle(CallbackMainHealTarget);
- return;
- }
- if (action != MenuAction_Select) return;
- if(symbol != 0)
- {
- char userid[15];
- GetMenuItem(CallbackMainHealTarget, symbol, userid, sizeof(userid));
- int target = GetClientOfUserId(StringToInt(userid));
- if (IsValidClient(target))
- {
- GiveFunction(target, "health");
- SetEntityHealth(target, 100);
- SetEntPropFloat(target, Prop_Send, "m_healthBuffer", 0.0);
- PrintToChatAll("\x04•[A++] \x04%N полечил игрока %N", client, target);
- }
- }
- else
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- GiveFunction(client, "health");
- SetEntityHealth(i, 100);
- SetEntPropFloat(client, Prop_Send, "m_healthBuffer", 0.0);
- PrintToChat(i, "\x04•[A++] \x04%N полечил всех", client);
- }
- }
- }
- }
- public int CallbackPlayerControl(Handle CallbackPlayerControl, MenuAction action, int client, int symbol)
- {
- if (action == MenuAction_End)
- {
- CloseHandle(CallbackPlayerControl);
- return;
- }
- if (action != MenuAction_Select) return;
- if(IsValidClient(client))
- {
- if(symbol == 0)
- {
- DisplayPlayersKill(client);
- }
- else if(symbol == 1)
- {
- DisplayPlayersKick(client);
- }
- else if(symbol == 2)
- {
- IsPoint[client] = true;
- PrintToChat(client, "\x04•[A++]\x05Напишите в чат кол-во урона, для отмены введите reset.");
- }
- else if(symbol == 3)
- {
- DisplayHealTarget(client);
- }
- else if(symbol == 4)
- {
- IsHeal[client] = true;
- PrintToChat(client, "\x04•[A++]\x05Напишите в чат кол-во хп, для отмены введите reset.");
- }
- else if(symbol == 5)
- {
- DisplayPlayersKick(client);
- }
- }
- }
- void DisplayHurtTarget(int client)
- {
- Handle MainHurtTarget = CreateMenu(CallbackMainHurtTarget);
- SetMenuTitle(MainHurtTarget, "Кого ранить:");
- char userid[15];
- char name[32];
- AddMenuItem(MainHurtTarget, "0", "Всех");
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- IntToString(GetClientUserId(i), userid, 15);
- GetClientName(i, name, 32);
- AddMenuItem(MainHurtTarget, userid, name);
- }
- }
- SetMenuExitButton(MainHurtTarget, true);
- DisplayMenu(MainHurtTarget, client, MENU_TIME_FOREVER);
- }
- public int CallbackMainHurtTarget(Handle CallbackMainHurtTarget, MenuAction action, int client, int symbol)
- {
- if (action == MenuAction_End)
- {
- CloseHandle(CallbackMainHurtTarget);
- return;
- }
- if (action != MenuAction_Select) return;
- if(symbol != 0)
- {
- char userid[15];
- GetMenuItem(CallbackMainHurtTarget, symbol, userid, sizeof(userid));
- int target = GetClientOfUserId(StringToInt(userid));
- if (IsValidClient(target))
- {
- ForceDamageEntity(client, iCount[client], target);
- }
- }
- else
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- ForceDamageEntity(client, iCount[client], i);
- }
- }
- }
- }
- void DisplayPlayersKick(int client)
- {
- Handle MainKicker = CreateMenu(CallbackMainKicker);
- SetMenuTitle(MainKicker, "Кого убить:");
- char userid[15];
- char name[32];
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && IsPlayerAlive(i))
- {
- IntToString(GetClientUserId(i), userid, 15);
- GetClientName(i, name, 32);
- AddMenuItem(MainKicker, userid, name);
- }
- }
- SetMenuExitButton(MainKicker, true);
- DisplayMenu(MainKicker, client, MENU_TIME_FOREVER);
- }
- public int CallbackMainKicker(Handle CallbackMainKicker, MenuAction action, int client, int symbol)
- {
- if (action == MenuAction_End)
- {
- CloseHandle(CallbackMainKicker);
- return;
- }
- if (action != MenuAction_Select) return;
- char userid[15];
- GetMenuItem(CallbackMainKicker, symbol, userid, 15);
- int target = GetClientOfUserId(StringToInt(userid));
- if (IsValidClient(target))
- {
- KickClient(target, "Вы кикнуты администратором");
- PrintToChatAll("\x04•[A++] \x05Игрок %N кикнут", target);
- for (int i = 1; i <= MaxClients; i++)
- {
- if(!IsValidClient(i)) continue;
- if(GetAdminFlags(GetUserAdmin(i), Access_Effective) & ~ADMFLAG_ROOT)
- {
- PrintToChat(i, "\x04•[A++] \x05%N был кикнут администратором %N", target, client);
- DisplayPlayersKill(client);
- }
- }
- }
- }
- void DisplayPlayersKill(int client)
- {
- Handle MainKiller = CreateMenu(CallbackMainKiller);
- SetMenuTitle(MainKiller, "Кого убить:");
- char userid[15];
- char name[32];
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- IntToString(GetClientUserId(i), userid, 15);
- GetClientName(i, name, 32);
- AddMenuItem(MainKiller, userid, name);
- }
- }
- SetMenuExitButton(MainKiller, true);
- DisplayMenu(MainKiller, client, MENU_TIME_FOREVER);
- }
- public int CallbackMainKiller(Handle CallbackMainKiller, MenuAction action, int client, int symbol)
- {
- if (action == MenuAction_End)
- {
- CloseHandle(CallbackMainKiller);
- return;
- }
- if (action != MenuAction_Select) return;
- char userid[15];
- GetMenuItem(CallbackMainKiller, symbol, userid, 15);
- int target = GetClientOfUserId(StringToInt(userid));
- if (IsValidClient(target))
- {
- ForcePlayerSuicide(target);
- PrintToChatAll("\x04•[A++] \x05Игрок %N убит", target);
- }
- }
- stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
- {
- float victim_origin[3];
- char rupture[32];
- char damage_victim[32];
- IntToString(damage, rupture, sizeof(rupture));
- Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
- GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
- int entity = CreateEntityByName("point_hurt");
- DispatchKeyValue(victim, "targetname", damage_victim);
- DispatchKeyValue(entity, "DamageTarget", damage_victim);
- DispatchKeyValue(entity, "Damage", rupture);
- DispatchSpawn(entity);
- TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
- AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
- DispatchKeyValue(entity, "classname", "point_hurt");
- DispatchKeyValue(victim, "targetname", "null");
- AcceptEntityInput(entity, "Kill");
- }
- stock bool IsValidClient(int client)
- {
- if ( client < 1 || client > MaxClients ) return false;
- if ( !IsClientConnected( client )) return false;
- if ( !IsClientInGame( client )) return false;
- return true;
- }
- void GiveFunction(int client, char[] name)
- {
- char sBuf[32];
- int flags = GetCommandFlags("give");
- SetCommandFlags("give", flags & ~FCVAR_CHEAT);
- FormatEx(sBuf, sizeof sBuf, "give %s", name);
- FakeClientCommand(client, sBuf);
- }
- stock void GetLookPos(int client, float v[3])
- {
- float EyePosition[3], EyeAngles[3];
- Handle h_trace;
- GetClientEyePosition(client, EyePosition);
- GetClientEyeAngles(client, EyeAngles);
- h_trace = TR_TraceRayFilterEx(EyePosition, EyeAngles, MASK_SOLID, RayType_Infinite, GetLookPos_Filter, client);
- TR_GetEndPosition(v, h_trace);
- CloseHandle(h_trace);
- }
- public bool GetLookPos_Filter(int ent, int mask, int client)
- {
- return client != ent;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement