Misc improvements to certain plugins
Fixed bug in SprayManager.sp Added sm_setscore and sm_setteamscore to ExtraCommands.sp Misc improvements to Status.sp (serverfps.inc made by GoD-Tony, I just updated win sig) Logging and misc improvements to Teleport.sp
This commit is contained in:
parent
ebbb7b4d62
commit
4037006f98
@ -28,7 +28,7 @@ public Plugin myinfo =
|
||||
name = "Advanced Commands",
|
||||
author = "BotoX + Obus",
|
||||
description = "Adds extra commands for admins.",
|
||||
version = "1.8",
|
||||
version = "1.9",
|
||||
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/ExtraCommands/"
|
||||
};
|
||||
|
||||
@ -50,6 +50,8 @@ public void OnPluginStart()
|
||||
RegAdminCmd("sm_modelscale", Command_ModelScale, ADMFLAG_GENERIC, "sm_modelscale <#userid|name> <scale>");
|
||||
RegAdminCmd("sm_resize", Command_ModelScale, ADMFLAG_GENERIC, "sm_resize <#userid|name> <scale>");
|
||||
RegAdminCmd("sm_setmodel", Command_SetModel, ADMFLAG_GENERIC, "sm_setmodel <#userid|name> <modelpath>");
|
||||
RegAdminCmd("sm_setscore", Command_SetScore, ADMFLAG_GENERIC, "sm_setscore <#userid|name> <value>");
|
||||
RegAdminCmd("sm_setteamscore", Command_SetTeamScore, ADMFLAG_GENERIC, "sm_setteamscore <team> <value>");
|
||||
RegAdminCmd("sm_waila", Command_WAILA, ADMFLAG_GENERIC);
|
||||
RegAdminCmd("sm_getinfo", Command_WAILA, ADMFLAG_GENERIC);
|
||||
RegAdminCmd("sm_getmodel", Command_WAILA, ADMFLAG_GENERIC);
|
||||
@ -800,7 +802,7 @@ public Action Command_SetModel(int client, int argc)
|
||||
PrecacheModel(sArgs2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < iTargetCount; i++)
|
||||
for(int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
SetEntityModel(iTargets[i], sArgs2);
|
||||
}
|
||||
@ -811,6 +813,83 @@ public Action Command_SetModel(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_SetScore(int client, int argc)
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_setscore <#userid|name> <value>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
char sArgs[32];
|
||||
char sArgs2[32];
|
||||
char sTargetName[MAX_TARGET_LENGTH];
|
||||
int iTargets[MAXPLAYERS];
|
||||
int iTargetCount;
|
||||
bool bIsML;
|
||||
|
||||
GetCmdArg(1, sArgs, sizeof(sArgs));
|
||||
GetCmdArg(2, sArgs2, sizeof(sArgs2));
|
||||
|
||||
int iVal = StringToInt(sArgs2);
|
||||
|
||||
if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, 0, sTargetName, sizeof(sTargetName), bIsML)) <= 0)
|
||||
{
|
||||
ReplyToTargetError(client, iTargetCount);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
for(int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
SetEntProp(iTargets[i], Prop_Data, "m_iFrags", iVal);
|
||||
}
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Set score to \x04%d\x01 on target \x04%s", iVal, sTargetName);
|
||||
LogAction(client, -1, "\"%L\" set score to \"%d\" on target \"%s\"", client, iVal, sTargetName);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_SetTeamScore(int client, int argc)
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_setteamscore <team> <value>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
char sArgs[32];
|
||||
char sArgs2[32];
|
||||
|
||||
GetCmdArg(1, sArgs, sizeof(sArgs));
|
||||
GetCmdArg(2, sArgs2, sizeof(sArgs2));
|
||||
|
||||
int iVal = StringToInt(sArgs2);
|
||||
|
||||
if(strcmp(sArgs, "@ct", false) == 0 || strcmp(sArgs, "@cts", false) == 0)
|
||||
{
|
||||
SetTeamScore(CS_TEAM_CT, iVal);
|
||||
CS_SetTeamScore(CS_TEAM_CT, iVal);
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Set team-score to \x04%d\x01 on team \x04Counter-Terrorists", iVal);
|
||||
LogAction(client, -1, "\"%L\" set team-score to \"%d\" on team \"Counter-Terrorists\"", client, iVal);
|
||||
}
|
||||
else if(strcmp(sArgs, "@t", false) == 0 || strcmp(sArgs, "@ts", false) == 0)
|
||||
{
|
||||
SetTeamScore(CS_TEAM_T, iVal);
|
||||
CS_SetTeamScore(CS_TEAM_T, iVal);
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Set team-score to \x04%d\x01 on team \x04Terrorists", iVal);
|
||||
LogAction(client, -1, "\"%L\" set team-score to \"%d\" on team \"Terrorists\"", client, iVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Invalid team.");
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_WAILA(int client, int argc)
|
||||
{
|
||||
if(!client)
|
||||
@ -825,7 +904,7 @@ public Action Command_WAILA(int client, int argc)
|
||||
GetClientEyeAngles(client, vecEyeAngles);
|
||||
GetClientEyePosition(client, vecEyeOrigin);
|
||||
|
||||
Handle hTraceRay = TR_TraceRayFilterEx(vecEyeOrigin, vecEyeAngles, MASK_ALL, RayType_Infinite, TraceFilterCaller, client);
|
||||
Handle hTraceRay = TR_TraceRayFilterEx(vecEyeOrigin, vecEyeAngles, MASK_ALL, RayType_Infinite, TraceEntityFilter_FilterCaller, client);
|
||||
|
||||
if(TR_DidHit(hTraceRay))
|
||||
{
|
||||
@ -842,7 +921,7 @@ public Action Command_WAILA(int client, int argc)
|
||||
{
|
||||
PrintToChat(client, "[SM] Trace hit the world.");
|
||||
|
||||
CloseHandle(hTraceRay);
|
||||
delete hTraceRay;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -856,19 +935,19 @@ public Action Command_WAILA(int client, int argc)
|
||||
|
||||
PrintToChat(client, "[SM] Trace hit something, check your console for more information.");
|
||||
|
||||
CloseHandle(hTraceRay);
|
||||
delete hTraceRay;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
CloseHandle(hTraceRay);
|
||||
delete hTraceRay;
|
||||
|
||||
PrintToChat(client, "[SM] Couldn't find anything under your crosshair.");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
stock bool TraceFilterCaller(int entity, int contentsMask, int client)
|
||||
stock bool TraceEntityFilter_FilterCaller(int entity, int contentsMask, int client)
|
||||
{
|
||||
return entity != client;
|
||||
}
|
||||
@ -894,6 +973,7 @@ public Action Command_ForceCVar(int client, int argc)
|
||||
GetCmdArg(3, sArg3, sizeof(sArg3));
|
||||
|
||||
ConVar cvar = FindConVar(sArg2);
|
||||
|
||||
if(cvar == null)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] No such cvar.");
|
||||
@ -906,7 +986,7 @@ public Action Command_ForceCVar(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
for (int i = 0; i < iTargetCount; i++)
|
||||
for(int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
cvar.ReplicateToClient(iTargets[i], sArg3);
|
||||
}
|
||||
@ -932,7 +1012,7 @@ public Action Command_SetClanTag(int client, int argc)
|
||||
GetCmdArg(1, sArg, sizeof(sArg));
|
||||
GetCmdArg(2, sArg2, sizeof(sArg2));
|
||||
|
||||
if((iTargetCount = ProcessTargetString(sArg, client, iTargets, MAXPLAYERS, COMMAND_FILTER_CONNECTED, sTargetName, sizeof(sTargetName), bIsML)) <= 0)
|
||||
if((iTargetCount = ProcessTargetString(sArg, client, iTargets, MAXPLAYERS, 0, sTargetName, sizeof(sTargetName), bIsML)) <= 0)
|
||||
{
|
||||
ReplyToTargetError(client, iTargetCount);
|
||||
return Plugin_Handled;
|
||||
@ -940,9 +1020,6 @@ public Action Command_SetClanTag(int client, int argc)
|
||||
|
||||
for(int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
if(!IsClientInGame(iTargets[i]))
|
||||
continue;
|
||||
|
||||
CS_SetClientClanTag(iTargets[i], sArg2);
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,9 @@ ConVar g_cvarHookedDecalFrequency = null;
|
||||
ConVar g_cvarDecalFrequency = null;
|
||||
ConVar g_cvarUseProximityCheck = null;
|
||||
|
||||
int g_iAllowSpray;
|
||||
|
||||
bool g_bLoadedLate;
|
||||
bool g_bAllowSpray;
|
||||
bool g_bSQLite;
|
||||
bool g_bGotBans;
|
||||
bool g_bGotBlacklist;
|
||||
@ -64,7 +65,7 @@ public Plugin myinfo =
|
||||
name = "Spray Manager",
|
||||
description = "A plugin to help manage player sprays.",
|
||||
author = "Obus",
|
||||
version = "1.2.6",
|
||||
version = "1.2.7",
|
||||
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/SprayManager"
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ public void OnPluginStart()
|
||||
|
||||
TopMenu hTopMenu;
|
||||
|
||||
if (LibraryExists("adminmenu") && ((hTopMenu = GetAdminTopMenu()) != INVALID_HANDLE))
|
||||
if (LibraryExists("adminmenu") && ((hTopMenu = GetAdminTopMenu()) != null))
|
||||
OnAdminMenuReady(hTopMenu);
|
||||
|
||||
if (g_cvarHookedDecalFrequency != null)
|
||||
@ -137,7 +138,7 @@ public void OnPluginEnd()
|
||||
if (g_vecSprayOrigin[i][0] == 0.0)
|
||||
continue;
|
||||
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = i;
|
||||
SprayClientDecal(i, 0, ACTUAL_NULL_VECTOR);
|
||||
}
|
||||
|
||||
@ -166,7 +167,7 @@ public void OnClientPostAdminCheck(int client)
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = client;
|
||||
SprayClientDecal(client, 0, ACTUAL_NULL_VECTOR);
|
||||
ClearPlayerInfo(client);
|
||||
}
|
||||
@ -183,7 +184,7 @@ public Action CS_OnTerminateRound(float &fDelay, CSRoundEndReason &reason)
|
||||
|
||||
if (g_iSprayLifetime[i] >= 2)
|
||||
{
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = i;
|
||||
SprayClientDecal(i, 0, ACTUAL_NULL_VECTOR);
|
||||
g_iSprayLifetime[i] = 0;
|
||||
}
|
||||
@ -279,7 +280,7 @@ public void Handler_TraceSpray(Handle hMenu, TopMenuAction hAction, TopMenuObjec
|
||||
|
||||
PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Trace did not hit any sprays.");
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
@ -361,7 +362,7 @@ int MenuHandler_Menu_ListBans(Menu hMenu, MenuAction action, int iParam1, int iP
|
||||
|
||||
case MenuAction_Cancel:
|
||||
{
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
|
||||
@ -376,7 +377,7 @@ int MenuHandler_Menu_ListBans(Menu hMenu, MenuAction action, int iParam1, int iP
|
||||
{
|
||||
PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available.");
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -423,7 +424,7 @@ int MenuHandler_Menu_Trace(Menu hMenu, MenuAction action, int iParam1, int iPara
|
||||
|
||||
case MenuAction_Cancel:
|
||||
{
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
|
||||
@ -440,7 +441,7 @@ int MenuHandler_Menu_Trace(Menu hMenu, MenuAction action, int iParam1, int iPara
|
||||
|
||||
g_bInvokedThroughTopMenu[iParam1] = false;
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -535,7 +536,7 @@ int MenuHandler_Menu_Trace_SprayBan(Menu hMenu, MenuAction action, int iParam1,
|
||||
{
|
||||
Menu_Trace(iParam1, g_iSprayBanTarget[iParam1]);
|
||||
}
|
||||
else if (g_hTopMenu != INVALID_HANDLE)
|
||||
else if (g_hTopMenu != null)
|
||||
{
|
||||
g_bInvokedThroughTopMenu[iParam1] = false;
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
@ -562,7 +563,7 @@ int MenuHandler_Menu_Trace_SprayBan(Menu hMenu, MenuAction action, int iParam1,
|
||||
g_iSprayBanTarget[iParam1] = 0;
|
||||
g_bInvokedThroughTopMenu[iParam1] = false;
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -597,7 +598,7 @@ int MenuHandler_Menu_Trace_Ban(Menu hMenu, MenuAction action, int iParam1, int i
|
||||
{
|
||||
Menu_Trace(iParam1, g_iBanTarget[iParam1]);
|
||||
}
|
||||
else if (g_hTopMenu != INVALID_HANDLE)
|
||||
else if (g_hTopMenu != null)
|
||||
{
|
||||
g_bInvokedThroughTopMenu[iParam1] = false;
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
@ -624,7 +625,7 @@ int MenuHandler_Menu_Trace_Ban(Menu hMenu, MenuAction action, int iParam1, int i
|
||||
g_iBanTarget[iParam1] = 0;
|
||||
g_bInvokedThroughTopMenu[iParam1] = false;
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -697,7 +698,7 @@ int MenuHandler_Menu_Spray(Menu hMenu, MenuAction action, int iParam1, int iPara
|
||||
|
||||
case MenuAction_Cancel:
|
||||
{
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
|
||||
@ -712,14 +713,14 @@ int MenuHandler_Menu_Spray(Menu hMenu, MenuAction action, int iParam1, int iPara
|
||||
{
|
||||
PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available.");
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = target;
|
||||
ForceSpray(iParam1, target);
|
||||
|
||||
PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Sprayed \x04%N\x01's spray(s).", target);
|
||||
@ -775,7 +776,7 @@ int MenuHandler_Menu_SprayBan(Menu hMenu, MenuAction action, int iParam1, int iP
|
||||
|
||||
case MenuAction_Cancel:
|
||||
{
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
|
||||
@ -790,7 +791,7 @@ int MenuHandler_Menu_SprayBan(Menu hMenu, MenuAction action, int iParam1, int iP
|
||||
{
|
||||
PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available.");
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -904,7 +905,7 @@ int MenuHandler_Menu_BanSpray(Menu hMenu, MenuAction action, int iParam1, int iP
|
||||
|
||||
case MenuAction_Cancel:
|
||||
{
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
|
||||
@ -978,7 +979,7 @@ int MenuHandler_Menu_UnbanSpray(Menu hMenu, MenuAction action, int iParam1, int
|
||||
|
||||
case MenuAction_Cancel:
|
||||
{
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
|
||||
if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
|
||||
@ -1149,7 +1150,7 @@ int MenuHandler_Menu_UnbanMode(Menu hMenu, MenuAction action, int iParam1, int i
|
||||
{
|
||||
if (IsValidClient(g_iSprayUnbanTarget[iParam1]))
|
||||
Menu_ListBans_Target(iParam1, g_iSprayUnbanTarget[iParam1]);
|
||||
else if (g_hTopMenu != INVALID_HANDLE)
|
||||
else if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -1169,7 +1170,7 @@ int MenuHandler_Menu_UnbanMode(Menu hMenu, MenuAction action, int iParam1, int i
|
||||
|
||||
g_iSprayUnbanTarget[iParam1] = 0;
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -1220,7 +1221,7 @@ int MenuHandler_Menu_ConfirmUnban(Menu hMenu, MenuAction action, int iParam1, in
|
||||
{
|
||||
if (IsValidClient(g_iSprayUnbanTarget[iParam1]))
|
||||
Menu_ListBans_Target(iParam1, g_iSprayUnbanTarget[iParam1]);
|
||||
else if (g_hTopMenu != INVALID_HANDLE)
|
||||
else if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -1240,7 +1241,7 @@ int MenuHandler_Menu_ConfirmUnban(Menu hMenu, MenuAction action, int iParam1, in
|
||||
|
||||
g_iSprayUnbanTarget[iParam1] = 0;
|
||||
|
||||
if (g_hTopMenu != INVALID_HANDLE)
|
||||
if (g_hTopMenu != null)
|
||||
DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory);
|
||||
else
|
||||
delete hMenu;
|
||||
@ -1312,7 +1313,7 @@ public Action Command_AdminSpray(int client, int argc)
|
||||
|
||||
for (int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = iTargets[i];
|
||||
ForceSpray(client, iTargets[i], false);
|
||||
}
|
||||
|
||||
@ -1321,7 +1322,7 @@ public Action Command_AdminSpray(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = client;
|
||||
ForceSpray(client, client, false);
|
||||
|
||||
PrintToChat(client, "\x01\x04[SprayManager]\x01 Sprayed your own spray.");
|
||||
@ -1509,7 +1510,7 @@ public Action Command_RemoveSpray(int client, int argc)
|
||||
|
||||
for (int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = iTargets[i];
|
||||
SprayClientDecal(iTargets[i], 0, ACTUAL_NULL_VECTOR);
|
||||
}
|
||||
|
||||
@ -1527,7 +1528,7 @@ public Action Command_RemoveSpray(int client, int argc)
|
||||
if (!IsPointInsideAABB(vecEndPos, g_SprayAABB[i]))
|
||||
continue;
|
||||
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = i;
|
||||
SprayClientDecal(i, 0, ACTUAL_NULL_VECTOR);
|
||||
|
||||
PrintToChat(client, "\x01\x04[SprayManager]\x01 Removed \x04%N\x01's spray.", i);
|
||||
@ -1560,7 +1561,12 @@ public Action HookDecal(const char[] sTEName, const int[] iClients, int iNumClie
|
||||
int client = TE_ReadNum("m_nPlayer");
|
||||
|
||||
if (!IsValidClient(client))
|
||||
{
|
||||
if (g_iAllowSpray == client)
|
||||
g_iAllowSpray = 0;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
float vecOrigin[3];
|
||||
float AABBTemp[AABBTotalPoints];
|
||||
@ -1574,7 +1580,7 @@ public Action HookDecal(const char[] sTEName, const int[] iClients, int iNumClie
|
||||
AABBTemp[AABBMinZ] = vecOrigin[2] - 32.0;
|
||||
AABBTemp[AABBMaxZ] = vecOrigin[2] + 32.0;
|
||||
|
||||
if (!g_bAllowSpray)
|
||||
if (g_iAllowSpray != client)
|
||||
{
|
||||
if (g_bSprayHashBanned[client])
|
||||
{
|
||||
@ -1636,7 +1642,7 @@ public Action HookDecal(const char[] sTEName, const int[] iClients, int iNumClie
|
||||
}
|
||||
}
|
||||
|
||||
g_bAllowSpray = false;
|
||||
g_iAllowSpray = 0;
|
||||
|
||||
g_iSprayLifetime[client] = 0;
|
||||
|
||||
@ -1963,7 +1969,7 @@ bool SprayBanClient(int client, int target, int iBanLength, const char[] sReason
|
||||
g_iSprayUnbanTimestamp[target] = iBanLength ? (GetTime() + (iBanLength * 60)) : 0;
|
||||
g_fNextSprayTime[target] = 0.0;
|
||||
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = target;
|
||||
SprayClientDecal(target, 0, ACTUAL_NULL_VECTOR);
|
||||
|
||||
return true;
|
||||
@ -2052,7 +2058,7 @@ bool BanClientSpray(int client, int target)
|
||||
|
||||
g_bSprayHashBanned[target] = true;
|
||||
|
||||
g_bAllowSpray = true;
|
||||
g_iAllowSpray = target;
|
||||
SprayClientDecal(target, 0, ACTUAL_NULL_VECTOR);
|
||||
|
||||
return true;
|
||||
@ -2295,9 +2301,6 @@ bool TracePlayerAnglesRanged(int client, float fMaxDistance)
|
||||
|
||||
void ClearPlayerInfo(int client)
|
||||
{
|
||||
if (!IsValidClient(client))
|
||||
return;
|
||||
|
||||
strcopy(g_sBanIssuer[client], sizeof(g_sBanIssuer[]), "");
|
||||
strcopy(g_sBanIssuerSID[client], sizeof(g_sBanIssuerSID[]), "");
|
||||
strcopy(g_sBanReason[client], sizeof(g_sBanReason[]), "");
|
||||
|
45
Status/gamedata/serverfps.games.txt
Normal file
45
Status/gamedata/serverfps.games.txt
Normal file
@ -0,0 +1,45 @@
|
||||
"Games"
|
||||
{
|
||||
"#default"
|
||||
{
|
||||
"Addresses"
|
||||
{
|
||||
"HostTimeFrame"
|
||||
{
|
||||
"windows"
|
||||
{
|
||||
"signature" "GetStatsString"
|
||||
"read" "79"
|
||||
// ALTERNATIVE 1: -4
|
||||
}
|
||||
"linux"
|
||||
{
|
||||
"signature" "host_frametime"
|
||||
}
|
||||
"mac"
|
||||
{
|
||||
"signature" "host_frametime"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"Signatures"
|
||||
{
|
||||
"GetStatsString"
|
||||
{
|
||||
"library" "engine"
|
||||
"windows" "\x55\x8B\xEC\x83\xEC\x0C\xD9\xEE\x8D\x45\xFC\x56\x57\x50\x8D\x45\xF8"
|
||||
/* 55 8B EC 83 EC 0C D9 EE 8D 45 FC 56 57 50 8D 45 F8 */
|
||||
/* ALTERNATIVE 1: 2B F0 D9 E8 8D 47 FF DE F1 56 83 EC 08 DD 1C 24 50 */
|
||||
}
|
||||
|
||||
"host_frametime"
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@host_frametime"
|
||||
"mac" "@host_frametime"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
|
||||
#tryinclude "serverfps.inc"
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
ConVar g_Cvar_HostIP;
|
||||
@ -13,12 +15,16 @@ ConVar g_Cvar_HostTags;
|
||||
Handle g_hPlayerList[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
|
||||
bool g_bDataAvailable = false;
|
||||
|
||||
#if !defined _serverfps_included
|
||||
int g_iTickRate;
|
||||
#endif
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Status Fixer",
|
||||
author = "zaCade + BotoX + Obus",
|
||||
description = "Fixes the 'status' command",
|
||||
version = "1.3",
|
||||
description = "Fixes the \"status\" command",
|
||||
version = "2.0",
|
||||
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/Status/"
|
||||
};
|
||||
|
||||
@ -34,145 +40,183 @@ public void OnPluginStart()
|
||||
|
||||
public Action Command_Status(int client, const char[] command, int args)
|
||||
{
|
||||
if(client)
|
||||
if(!client)
|
||||
return Plugin_Continue;
|
||||
|
||||
if(g_hPlayerList[client] != INVALID_HANDLE)
|
||||
return Plugin_Handled;
|
||||
|
||||
static char sServerName[128];
|
||||
static char sServerTags[128];
|
||||
static char sServerAdress[128];
|
||||
|
||||
int iServerIP = g_Cvar_HostIP.IntValue;
|
||||
int iServerPort = g_Cvar_HostPort.IntValue;
|
||||
|
||||
g_Cvar_HostName.GetString(sServerName, sizeof(sServerName));
|
||||
g_Cvar_HostTags.GetString(sServerTags, sizeof(sServerTags));
|
||||
|
||||
Format(sServerAdress, sizeof(sServerAdress), "%d.%d.%d.%d:%d", iServerIP >>> 24 & 255, iServerIP >>> 16 & 255, iServerIP >>> 8 & 255, iServerIP & 255, iServerPort);
|
||||
|
||||
static char sMapName[128];
|
||||
GetCurrentMap(sMapName, sizeof(sMapName));
|
||||
|
||||
float fPosition[3];
|
||||
GetClientAbsOrigin(client, fPosition);
|
||||
|
||||
float fClientDataIn = GetClientAvgData(client, NetFlow_Incoming);
|
||||
float fClientDataOut = GetClientAvgData(client, NetFlow_Outgoing);
|
||||
float fServerDataIn;
|
||||
float fServerDataOut;
|
||||
|
||||
GetServerNetStats(fServerDataIn, fServerDataOut);
|
||||
|
||||
int iRealClients;
|
||||
int iFakeClients;
|
||||
int iTotalClients;
|
||||
|
||||
for(int player = 1; player <= MaxClients; player++)
|
||||
{
|
||||
if(g_hPlayerList[client] != INVALID_HANDLE)
|
||||
return Plugin_Handled;
|
||||
|
||||
static char sServerName[128];
|
||||
static char sServerTags[128];
|
||||
static char sServerAdress[128];
|
||||
|
||||
int iServerIP = g_Cvar_HostIP.IntValue;
|
||||
int iServerPort = g_Cvar_HostPort.IntValue;
|
||||
|
||||
g_Cvar_HostName.GetString(sServerName, sizeof(sServerName));
|
||||
g_Cvar_HostTags.GetString(sServerTags, sizeof(sServerTags));
|
||||
|
||||
Format(sServerAdress, sizeof(sServerAdress), "%d.%d.%d.%d:%d", iServerIP >>> 24 & 255, iServerIP >>> 16 & 255, iServerIP >>> 8 & 255, iServerIP & 255, iServerPort);
|
||||
|
||||
static char sMapName[128];
|
||||
GetCurrentMap(sMapName, sizeof(sMapName));
|
||||
|
||||
float fPosition[3];
|
||||
GetClientAbsOrigin(client, fPosition);
|
||||
|
||||
int iRealClients;
|
||||
int iFakeClients;
|
||||
int iTotalClients;
|
||||
|
||||
for(int player = 1; player <= MaxClients; player++)
|
||||
if(IsClientConnected(player))
|
||||
{
|
||||
if(IsClientConnected(player))
|
||||
{
|
||||
iTotalClients++;
|
||||
iTotalClients++;
|
||||
|
||||
if(IsFakeClient(player))
|
||||
iFakeClients++;
|
||||
else
|
||||
iRealClients++;
|
||||
}
|
||||
if(IsFakeClient(player))
|
||||
iFakeClients++;
|
||||
else
|
||||
iRealClients++;
|
||||
}
|
||||
}
|
||||
|
||||
static char sSendBuffer[1024];
|
||||
int iBufLength = 0;
|
||||
|
||||
#if defined _serverfps_included
|
||||
float fServerTickRate = 1.0 / GetTickInterval();
|
||||
float fServerFPS = GetServerFPS();
|
||||
|
||||
fServerFPS = fServerFPS <= fServerTickRate ? fServerFPS : fServerTickRate;
|
||||
#else
|
||||
int iServerTickRate = RoundToZero(1.0 / GetTickInterval());
|
||||
int iTickRate = g_iTickRate;
|
||||
|
||||
iTickRate = iTickRate <= iServerTickRate ? iTickRate : iServerTickRate;
|
||||
#endif
|
||||
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "hostname: %s\n", sServerName);
|
||||
|
||||
#if defined _serverfps_included
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%stickrate : %.2f/%.2f (%d%%%%)\n", sSendBuffer, fServerFPS, fServerTickRate, RoundToNearest((fServerFPS / fServerTickRate) * 100));
|
||||
#else
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%stickrate : %d/%d (%d%%%%)\n", sSendBuffer, iTickRate, iServerTickRate, RoundToNearest((float(iTickRate) / float(iServerTickRate)) * 100));
|
||||
#endif
|
||||
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%sudp/ip : %s\n", sSendBuffer, sServerAdress);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%snet I/O : %.2f/%.2f KiB/s (You: %.2f/%.2f KiB/s)\n", sSendBuffer, fServerDataIn / 1024, fServerDataOut / 1024, fClientDataIn / 1024, fClientDataOut / 1024);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%smap : %s at: %.0f x, %.0f y, %.0f z\n", sSendBuffer, sMapName, fPosition[0], fPosition[1], fPosition[2]);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%stags : %s\n", sSendBuffer, sServerTags);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%sedicts : %d/%d/%d (used/max/free)\n", sSendBuffer, GetEntityCount(), GetMaxEntities(), GetMaxEntities() - GetEntityCount());
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%splayers : %d %s | %d %s (%d/%d)\n", sSendBuffer, iRealClients, Multiple(iRealClients) ? "humans" : "human", iFakeClients, Multiple(iFakeClients) ? "bots" : "bot", iTotalClients, MaxClients);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%s# %8s %40s %24s %12s %4s %4s %s %s", sSendBuffer, "userid", "name", "uniqueid", "connected", "ping", "loss", "state", "addr");
|
||||
|
||||
g_hPlayerList[client] = CreateArray(ByteCountToCells(1024));
|
||||
|
||||
PushArrayString(g_hPlayerList[client], sSendBuffer);
|
||||
g_bDataAvailable = true;
|
||||
sSendBuffer[0] = 0;
|
||||
|
||||
for(int player = 1; player <= MaxClients; player++)
|
||||
{
|
||||
if(!IsClientConnected(player))
|
||||
continue;
|
||||
|
||||
static char sPlayerID[8];
|
||||
static char sPlayerName[MAX_NAME_LENGTH];
|
||||
char sPlayerAuth[24];
|
||||
char sPlayerTime[12];
|
||||
char sPlayerPing[4];
|
||||
char sPlayerLoss[4];
|
||||
static char sPlayerState[16];
|
||||
char sPlayerAddr[16];
|
||||
|
||||
Format(sPlayerID, sizeof(sPlayerID), "%d", GetClientUserId(player));
|
||||
Format(sPlayerName, sizeof(sPlayerName), "\"%N\"", player);
|
||||
|
||||
if(!GetClientAuthId(player, AuthId_Steam2, sPlayerAuth, sizeof(sPlayerAuth)))
|
||||
Format(sPlayerAuth, sizeof(sPlayerAuth), "STEAM_ID_PENDING");
|
||||
|
||||
if(!IsFakeClient(player))
|
||||
{
|
||||
int iHours = RoundToFloor((GetClientTime(player) / 3600));
|
||||
int iMinutes = RoundToFloor((GetClientTime(player) - (iHours * 3600)) / 60);
|
||||
int iSeconds = RoundToFloor((GetClientTime(player) - (iHours * 3600)) - (iMinutes * 60));
|
||||
|
||||
if (iHours)
|
||||
Format(sPlayerTime, sizeof(sPlayerTime), "%d:%02d:%02d", iHours, iMinutes, iSeconds);
|
||||
else
|
||||
Format(sPlayerTime, sizeof(sPlayerTime), "%d:%02d", iMinutes, iSeconds);
|
||||
|
||||
Format(sPlayerPing, sizeof(sPlayerPing), "%d", RoundFloat(GetClientLatency(player, NetFlow_Outgoing) * 800));
|
||||
Format(sPlayerLoss, sizeof(sPlayerLoss), "%d", RoundFloat(GetClientAvgLoss(player, NetFlow_Outgoing) * 100));
|
||||
}
|
||||
|
||||
static char sSendBuffer[989];
|
||||
int iBufLength = 0;
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "hostname: %s\n", sServerName);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%stickrate: %d\n", sSendBuffer, RoundToZero(1.0 / GetTickInterval()));
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%sudp/ip : %s\n", sSendBuffer, sServerAdress);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%smap : %s at: %.0f x, %.0f y, %.0f z\n", sSendBuffer, sMapName, fPosition[0], fPosition[1], fPosition[2]);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%stags : %s\n", sSendBuffer, sServerTags);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%s%edicts : %d/%d/%d (used/max/free)\n", sSendBuffer, GetEntityCount(), GetMaxEntities(), GetMaxEntities() - GetEntityCount());
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%splayers : %d %s | %d %s (%d/%d)\n", sSendBuffer, iRealClients, Multiple(iRealClients) ? "humans" : "human", iFakeClients, Multiple(iFakeClients) ? "bots" : "bot", iTotalClients, MaxClients);
|
||||
Format(sSendBuffer, sizeof(sSendBuffer), "%s# %8s %40s %24s %12s %4s %4s %s %s", sSendBuffer, "userid", "name", "uniqueid", "connected", "ping", "loss", "state", "addr");
|
||||
if(IsClientInGame(player))
|
||||
Format(sPlayerState, sizeof(sPlayerState), "active");
|
||||
else
|
||||
Format(sPlayerState, sizeof(sPlayerState), "spawning");
|
||||
|
||||
g_hPlayerList[client] = CreateArray(ByteCountToCells(989));
|
||||
if(GetAdminFlag(GetUserAdmin(client), Admin_Ban))
|
||||
GetClientIP(player, sPlayerAddr, sizeof(sPlayerAddr));
|
||||
|
||||
PushArrayString(g_hPlayerList[client], sSendBuffer);
|
||||
g_bDataAvailable = true;
|
||||
sSendBuffer[0] = 0;
|
||||
static char sFormatted[128];
|
||||
Format(sFormatted, sizeof(sFormatted), "# %8s %40s %24s %12s %4s %4s %s %s\n", sPlayerID, sPlayerName, sPlayerAuth, sPlayerTime, sPlayerPing, sPlayerLoss, sPlayerState, sPlayerAddr);
|
||||
|
||||
for(int player = 1; player <= MaxClients; player++)
|
||||
{
|
||||
if(IsClientConnected(player))
|
||||
{
|
||||
static char sPlayerID[8];
|
||||
static char sPlayerName[40];
|
||||
char sPlayerAuth[24];
|
||||
char sPlayerTime[12];
|
||||
char sPlayerPing[4];
|
||||
char sPlayerLoss[4];
|
||||
static char sPlayerState[16];
|
||||
char sPlayerAddr[16];
|
||||
int iFormattedLength = strlen(sFormatted);
|
||||
|
||||
Format(sPlayerID, sizeof(sPlayerID), "%d", GetClientUserId(player));
|
||||
Format(sPlayerName, sizeof(sPlayerName), "\"%N\"", player);
|
||||
|
||||
if(!GetClientAuthId(player, AuthId_Steam2, sPlayerAuth, sizeof(sPlayerAuth)))
|
||||
Format(sPlayerAuth, sizeof(sPlayerAuth), "STEAM_ID_PENDING");
|
||||
|
||||
if(!IsFakeClient(player))
|
||||
{
|
||||
int iHours = RoundToFloor((GetClientTime(player) / 3600));
|
||||
int iMinutes = RoundToFloor((GetClientTime(player) - (iHours * 3600)) / 60);
|
||||
int iSeconds = RoundToFloor((GetClientTime(player) - (iHours * 3600)) - (iMinutes * 60));
|
||||
|
||||
if (iHours)
|
||||
Format(sPlayerTime, sizeof(sPlayerTime), "%d:%02d:%02d", iHours, iMinutes, iSeconds);
|
||||
else
|
||||
Format(sPlayerTime, sizeof(sPlayerTime), "%d:%02d", iMinutes, iSeconds);
|
||||
|
||||
Format(sPlayerPing, sizeof(sPlayerPing), "%d", RoundFloat(GetClientLatency(player, NetFlow_Outgoing) * 800));
|
||||
Format(sPlayerLoss, sizeof(sPlayerLoss), "%d", RoundFloat(GetClientAvgLoss(player, NetFlow_Outgoing) * 100));
|
||||
}
|
||||
|
||||
if(IsClientInGame(player))
|
||||
Format(sPlayerState, sizeof(sPlayerState), "active");
|
||||
else
|
||||
Format(sPlayerState, sizeof(sPlayerState), "spawning");
|
||||
|
||||
if(GetAdminFlag(GetUserAdmin(client), Admin_Ban))
|
||||
GetClientIP(player, sPlayerAddr, sizeof(sPlayerAddr));
|
||||
|
||||
static char sFormatted[128];
|
||||
Format(sFormatted, sizeof(sFormatted), "# %8s %40s %24s %12s %4s %4s %s %s\n", sPlayerID, sPlayerName, sPlayerAuth, sPlayerTime, sPlayerPing, sPlayerLoss, sPlayerState, sPlayerAddr);
|
||||
|
||||
int iFormattedLength = strlen(sFormatted);
|
||||
if(iBufLength + iFormattedLength >= 989)
|
||||
{
|
||||
sSendBuffer[iBufLength - 1] = 0;
|
||||
PushArrayString(g_hPlayerList[client], sSendBuffer);
|
||||
sSendBuffer[0] = 0;
|
||||
iBufLength = 0;
|
||||
|
||||
StrCat(sSendBuffer, sizeof(sSendBuffer), sFormatted);
|
||||
iBufLength += iFormattedLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
StrCat(sSendBuffer, sizeof(sSendBuffer), sFormatted);
|
||||
iBufLength += iFormattedLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(iBufLength)
|
||||
if(iBufLength + iFormattedLength >= 1024)
|
||||
{
|
||||
sSendBuffer[iBufLength - 1] = 0;
|
||||
PushArrayString(g_hPlayerList[client], sSendBuffer);
|
||||
sSendBuffer[0] = 0;
|
||||
iBufLength = 0;
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
StrCat(sSendBuffer, sizeof(sSendBuffer), sFormatted);
|
||||
iBufLength += iFormattedLength;
|
||||
}
|
||||
return Plugin_Continue;
|
||||
|
||||
if(iBufLength)
|
||||
{
|
||||
sSendBuffer[iBufLength - 1] = 0;
|
||||
PushArrayString(g_hPlayerList[client], sSendBuffer);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void OnGameFrame()
|
||||
{
|
||||
#if !defined _serverfps_included //Inaccurate fallback
|
||||
static float fLastEngineTime;
|
||||
static int iTicks;
|
||||
float fCurEngineTime = GetEngineTime(); //GetEngineTime() will become less and less accurate as server uptime goes up!
|
||||
|
||||
iTicks++;
|
||||
|
||||
if (fCurEngineTime - fLastEngineTime >= 1.0)
|
||||
{
|
||||
g_iTickRate = iTicks;
|
||||
iTicks = 0;
|
||||
fLastEngineTime = fCurEngineTime;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(!g_bDataAvailable)
|
||||
return;
|
||||
|
||||
bool bGotData = false;
|
||||
for(int client = 0; client < MAXPLAYERS + 1; client++)
|
||||
|
||||
for(int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if(g_hPlayerList[client] == INVALID_HANDLE)
|
||||
continue;
|
||||
@ -184,7 +228,7 @@ public void OnGameFrame()
|
||||
continue;
|
||||
}
|
||||
|
||||
static char sBuffer[989];
|
||||
static char sBuffer[1024];
|
||||
GetArrayString(g_hPlayerList[client], 0, sBuffer, sizeof(sBuffer));
|
||||
RemoveFromArray(g_hPlayerList[client], 0);
|
||||
|
||||
|
50
Status/scripting/include/serverfps.inc
Normal file
50
Status/scripting/include/serverfps.inc
Normal file
@ -0,0 +1,50 @@
|
||||
#if defined _serverfps_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _serverfps_included
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
|
||||
stock float GetServerFPS()
|
||||
{
|
||||
return 1.0 / view_as<float>(LoadFromAddress(GetHostTimeFrame(), NumberType_Int32));
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal Functions
|
||||
*/
|
||||
stock Handle GetServerFPSConf()
|
||||
{
|
||||
static Handle hGameConf = null;
|
||||
|
||||
if (hGameConf == null)
|
||||
{
|
||||
hGameConf = LoadGameConfigFile("serverfps.games");
|
||||
|
||||
if (hGameConf == null)
|
||||
{
|
||||
SetFailState("Couldn't find \"serverfps.games\" configuration file");
|
||||
}
|
||||
}
|
||||
|
||||
return hGameConf;
|
||||
}
|
||||
|
||||
stock Address GetHostTimeFrame()
|
||||
{
|
||||
static Address pHostTimeFrame = Address_Null;
|
||||
|
||||
if (pHostTimeFrame == Address_Null)
|
||||
{
|
||||
pHostTimeFrame = GameConfGetAddress(GetServerFPSConf(), "HostTimeFrame");
|
||||
|
||||
if (pHostTimeFrame == Address_Null)
|
||||
{
|
||||
SetFailState("Failed to find time frame address");
|
||||
}
|
||||
}
|
||||
|
||||
return pHostTimeFrame;
|
||||
}
|
||||
|
@ -9,19 +9,19 @@ public Plugin myinfo =
|
||||
{
|
||||
name = "Teleport Commands",
|
||||
author = "Obus",
|
||||
description = "Adds commands to teleport players.",
|
||||
version = "1.1",
|
||||
url = "https://github.com/CSSZombieEscape/sm-plugins/blob/master/Teleport/"
|
||||
description = "Adds commands to teleport clients.",
|
||||
version = "1.2",
|
||||
url = "https://github.com/CSSZombieEscape/sm-plugins/blob/master/Teleport/"
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
|
||||
RegAdminCmd("sm_bring", Command_Bring, ADMFLAG_GENERIC, "Brings a player to your position.");
|
||||
RegAdminCmd("sm_goto", Command_Goto, ADMFLAG_GENERIC, "Teleports you to a player.");
|
||||
RegAdminCmd("sm_send", Command_Send, ADMFLAG_GENERIC, "Sends a player to another player.");
|
||||
RegAdminCmd("sm_tpaim", Command_TpAim, ADMFLAG_GENERIC, "Teleports a player to your crosshair.");
|
||||
RegAdminCmd("sm_bring", Command_Bring, ADMFLAG_GENERIC, "Brings a client to your position.");
|
||||
RegAdminCmd("sm_goto", Command_Goto, ADMFLAG_GENERIC, "Teleport to a client.");
|
||||
RegAdminCmd("sm_send", Command_Send, ADMFLAG_GENERIC, "Send a client to another client.");
|
||||
RegAdminCmd("sm_tpaim", Command_TpAim, ADMFLAG_GENERIC, "Teleport a client to your aimpoint.");
|
||||
}
|
||||
|
||||
public Action Command_Bring(int client, int argc)
|
||||
@ -38,7 +38,6 @@ public Action Command_Bring(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
float vecClientPos[3];
|
||||
char sArgs[64];
|
||||
char sTargetName[MAX_TARGET_LENGTH];
|
||||
int iTargets[MAXPLAYERS];
|
||||
@ -46,7 +45,6 @@ public Action Command_Bring(int client, int argc)
|
||||
bool bIsML;
|
||||
|
||||
GetCmdArg(1, sArgs, sizeof(sArgs));
|
||||
GetClientAbsOrigin(client, vecClientPos);
|
||||
|
||||
if ((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_ALIVE, sTargetName, sizeof(sTargetName), bIsML)) <= 0)
|
||||
{
|
||||
@ -54,13 +52,17 @@ public Action Command_Bring(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
float vecClientPos[3];
|
||||
|
||||
GetClientAbsOrigin(client, vecClientPos);
|
||||
|
||||
for (int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
TeleportEntity(iTargets[i], vecClientPos, NULL_VECTOR, NULL_VECTOR);
|
||||
}
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Brought \x04%s\x01.", sTargetName);
|
||||
LogAction(client, -1, "Brought %s", sTargetName);
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Brought \x04%s\x01", sTargetName);
|
||||
LogAction(client, -1, "\"%L\" brought \"%s\"", client, sTargetName);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -84,7 +86,7 @@ public Action Command_Goto(int client, int argc)
|
||||
|
||||
GetCmdArg(1, sTarget, sizeof(sTarget));
|
||||
|
||||
if (!strcmp(sTarget, "@aim"))
|
||||
if (strcmp(sTarget, "@aim") == 0)
|
||||
{
|
||||
if (argc > 1)
|
||||
{
|
||||
@ -94,39 +96,41 @@ public Action Command_Goto(int client, int argc)
|
||||
|
||||
if (StringToInt(sOption) <= 0)
|
||||
{
|
||||
float vecEndPos[3];
|
||||
float vecAimPoint[3];
|
||||
|
||||
if (!TracePlayerAngles(client, vecEndPos))
|
||||
if (!TracePlayerAngles(client, vecAimPoint))
|
||||
{
|
||||
PrintToChat(client, "[SM] Couldn't perform trace to your crosshair.");
|
||||
PrintToChat(client, "[SM] Couldn't perform trace to your aimpoint.");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
TeleportEntity(client, vecEndPos, NULL_VECTOR, NULL_VECTOR);
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Teleported to their crosshair.");
|
||||
LogAction(client, -1, "Teleported to their crosshair");
|
||||
TeleportEntity(client, vecAimPoint, NULL_VECTOR, NULL_VECTOR);
|
||||
|
||||
ShowActivity3(client, "\x01[SM] \x04", "\x01Teleported to their aimpoint.");
|
||||
ReplyToCommand(client, "[SM] Teleported you to your aimpoint.");
|
||||
LogAction(client, -1, "\"%L\" teleported to their aimpoint", client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
||||
int AimTarget = GetClientAimTarget(client, true);
|
||||
int iAimTarget = GetClientAimTarget(client, true);
|
||||
|
||||
if (AimTarget == -1)
|
||||
if (iAimTarget == -1)
|
||||
{
|
||||
float vecEndPos[3];
|
||||
float vecAimPoint[3];
|
||||
|
||||
if (!TracePlayerAngles(client, vecEndPos))
|
||||
if (!TracePlayerAngles(client, vecAimPoint))
|
||||
{
|
||||
PrintToChat(client, "[SM] Couldn't perform trace to your crosshair.");
|
||||
PrintToChat(client, "[SM] Couldn't perform trace to your aimpoint.");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
TeleportEntity(client, vecEndPos, NULL_VECTOR, NULL_VECTOR);
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Teleported to their crosshair.");
|
||||
LogAction(client, -1, "Teleported to their crosshair");
|
||||
TeleportEntity(client, vecAimPoint, NULL_VECTOR, NULL_VECTOR);
|
||||
|
||||
ShowActivity3(client, "\x01[SM] \x04", "\x01Teleported to their aimpoint.");
|
||||
ReplyToCommand(client, "[SM] Teleported you to your aimpoint.");
|
||||
LogAction(client, -1, "\"%L\" teleported to their aimpoint", client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -142,7 +146,7 @@ public Action Command_Goto(int client, int argc)
|
||||
TeleportEntity(client, vecTargetPos, NULL_VECTOR, NULL_VECTOR);
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Teleported to \x04%N\x01.", iTarget);
|
||||
LogAction(client, iTarget, "Teleported to %N", iTarget);
|
||||
LogAction(client, iTarget, "\"%L\" teleported to \"%L\"", client, iTarget);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -155,7 +159,6 @@ public Action Command_Send(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
float vecTargetPos[3];
|
||||
int iTarget;
|
||||
char sArgs[32];
|
||||
char sTarget[32];
|
||||
@ -173,29 +176,30 @@ public Action Command_Send(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!strcmp(sTarget, "@aim"))
|
||||
if (strcmp(sTarget, "@aim") == 0)
|
||||
{
|
||||
if (!client)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Cannot use @aim from server console.");
|
||||
ReplyToCommand(client, "[SM] Cannot use \"sm_send @aim\" from server console.");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
float vecEndPos[3];
|
||||
float vecAimPoint[3];
|
||||
|
||||
if (!TracePlayerAngles(client, vecEndPos))
|
||||
if (!TracePlayerAngles(client, vecAimPoint))
|
||||
{
|
||||
PrintToChat(client, "[SM] Couldn't perform trace to your crosshair.");
|
||||
PrintToChat(client, "[SM] Couldn't perform trace to your aimpoint.");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
for (int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
TeleportEntity(iTargets[i], vecEndPos, NULL_VECTOR, NULL_VECTOR);
|
||||
TeleportEntity(iTargets[i], vecAimPoint, NULL_VECTOR, NULL_VECTOR);
|
||||
}
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to their crosshair.", sTargetName);
|
||||
LogAction(client, -1, "Teleported %s to their crosshair", sTargetName);
|
||||
ShowActivity3(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to their aimpoint.", sTargetName);
|
||||
ReplyToCommand(client, "\x01[SM] Teleported \x04%s\x01 to your aimpoint.", sTargetName);
|
||||
LogAction(client, -1, "\"%L\" teleported target \"%s\" to their aimpoint", client, sTargetName);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -203,6 +207,8 @@ public Action Command_Send(int client, int argc)
|
||||
if ((iTarget = FindTarget(client, sTarget)) <= 0)
|
||||
return Plugin_Handled;
|
||||
|
||||
float vecTargetPos[3];
|
||||
|
||||
GetClientAbsOrigin(iTarget, vecTargetPos);
|
||||
|
||||
for (int i = 0; i < iTargetCount; i++)
|
||||
@ -211,7 +217,7 @@ public Action Command_Send(int client, int argc)
|
||||
}
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to \x04%N\x01.", sTargetName, iTarget);
|
||||
LogAction(client, iTarget, "Teleported %s to %N", sTargetName, iTarget);
|
||||
LogAction(client, iTarget, "\"%L\" teleported target \"%s\" to \"%L\"", client, sTargetName, iTarget);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -224,7 +230,6 @@ public Action Command_TpAim(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
float vecEndPos[3];
|
||||
char sArgs[32];
|
||||
char sTargetName[MAX_TARGET_LENGTH];
|
||||
int iTargets[MAXPLAYERS];
|
||||
@ -239,16 +244,19 @@ public Action Command_TpAim(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
TracePlayerAngles(client, vecEndPos);
|
||||
float vecAimPoint[3];
|
||||
|
||||
TracePlayerAngles(client, vecAimPoint);
|
||||
|
||||
for (int i = 0; i < iTargetCount; i++)
|
||||
{
|
||||
TeleportEntity(iTargets[i], vecEndPos, NULL_VECTOR, NULL_VECTOR);
|
||||
TeleportEntity(iTargets[i], vecAimPoint, NULL_VECTOR, NULL_VECTOR);
|
||||
}
|
||||
|
||||
ShowActivity2(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to their crosshair.", sTargetName);
|
||||
LogAction(client, -1, "Teleported %s to their crosshair", sTargetName);
|
||||
|
||||
ShowActivity3(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to their aimpoint.", sTargetName);
|
||||
ReplyToCommand(client, "\x01[SM] Teleported \x04%s\x01 to your aimpoint.", sTargetName);
|
||||
LogAction(client, -1, "\"%L\" teleported \"%s\" to their aimpoint", client, sTargetName);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
@ -263,22 +271,44 @@ bool TracePlayerAngles(int client, float vecResult[3])
|
||||
GetClientEyeAngles(client, vecEyeAngles);
|
||||
GetClientEyePosition(client, vecEyeOrigin);
|
||||
|
||||
Handle hTraceRay = TR_TraceRayFilterEx(vecEyeOrigin, vecEyeAngles, MASK_SHOT_HULL, RayType_Infinite, FilterPlayers);
|
||||
Handle hTraceRay = TR_TraceRayFilterEx(vecEyeOrigin, vecEyeAngles, MASK_SHOT_HULL, RayType_Infinite, TraceEntityFilter_FilterPlayers);
|
||||
|
||||
if (TR_DidHit(hTraceRay))
|
||||
{
|
||||
TR_GetEndPosition(vecResult, hTraceRay);
|
||||
CloseHandle(hTraceRay);
|
||||
|
||||
delete hTraceRay;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CloseHandle(hTraceRay);
|
||||
delete hTraceRay;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
stock bool FilterPlayers(int entity, int contentsMask)
|
||||
stock bool TraceEntityFilter_FilterPlayers(int entity, int contentsMask)
|
||||
{
|
||||
return entity > MaxClients;
|
||||
}
|
||||
|
||||
stock void ShowActivity3(int client, const char[] tag, const char[] fmt, any ...)
|
||||
{
|
||||
char sFinal[255];
|
||||
char sFormatted[255];
|
||||
char sActivitySource[MAX_NAME_LENGTH];
|
||||
|
||||
FormatActivitySource(client, client, sActivitySource, sizeof(sActivitySource));
|
||||
|
||||
VFormat(sFormatted, sizeof(sFormatted), fmt, 4);
|
||||
|
||||
Format(sFinal, sizeof(sFinal), "%s%s: %s", tag, sActivitySource, sFormatted);
|
||||
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i) || IsFakeClient(i) || i == client)
|
||||
continue;
|
||||
|
||||
PrintToChat(i, sFinal);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user