mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-16 03:17:18 +00:00
commit
c294408c43
@ -59,6 +59,7 @@
|
||||
// Special flags
|
||||
"special" "0" // For third-party modules. The core plugins will not need this setting.
|
||||
"specialstring" "" // For third-party modules. The core plugins will not need this setting.
|
||||
"permission" "" // Permission required. Syntax: "flag;override". For example "p;style_tas" to require the 'p' flag or the "style_tas" override.
|
||||
}
|
||||
|
||||
"1"
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#endif
|
||||
#define _shavit_included
|
||||
|
||||
#define SHAVIT_VERSION "2.0.2"
|
||||
#define SHAVIT_VERSION "2.0.3"
|
||||
#define STYLE_LIMIT 256
|
||||
#define MAX_ZONES 64
|
||||
|
||||
@ -81,6 +81,7 @@ enum
|
||||
sChangeCommand,
|
||||
sClanTag,
|
||||
sSpecialString,
|
||||
sStylePermission,
|
||||
STYLESTRINGS_SIZE
|
||||
};
|
||||
|
||||
@ -1097,6 +1098,15 @@ native int Shavit_GetMapTier(const char[] map);
|
||||
*/
|
||||
native StringMap Shavit_GetMapTiers();
|
||||
|
||||
/**
|
||||
* Retrieves style access for a player.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param style Style.
|
||||
* @return Boolean value.
|
||||
*/
|
||||
native bool Shavit_HasStyleAccess(int client, int style);
|
||||
|
||||
/**
|
||||
* Use this native when printing anything in chat if it's related to the timer.
|
||||
* This native will auto-assign colors and a chat prefix.
|
||||
@ -1191,6 +1201,7 @@ public void __pl_shavit_SetNTVOptional()
|
||||
MarkNativeAsOptional("Shavit_GetWRName");
|
||||
MarkNativeAsOptional("Shavit_GetWRRecordID");
|
||||
MarkNativeAsOptional("Shavit_GetWRTime");
|
||||
MarkNativeAsOptional("Shavit_HasStyleAccess");
|
||||
MarkNativeAsOptional("Shavit_InsideZone");
|
||||
MarkNativeAsOptional("Shavit_IsClientCreatingZone");
|
||||
MarkNativeAsOptional("Shavit_IsKZMap");
|
||||
|
||||
@ -134,6 +134,10 @@ bool gB_StopChatSound = false;
|
||||
bool gB_HookedJump = false;
|
||||
char gS_LogPath[PLATFORM_MAX_PATH];
|
||||
|
||||
// flags
|
||||
int gI_StyleFlag[STYLE_LIMIT];
|
||||
char gS_StyleOverride[STYLE_LIMIT][32];
|
||||
|
||||
// kz support
|
||||
bool gB_KZMap = false;
|
||||
|
||||
@ -164,6 +168,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
CreateNative("Shavit_GetSync", Native_GetSync);
|
||||
CreateNative("Shavit_GetTimer", Native_GetTimer);
|
||||
CreateNative("Shavit_GetTimerStatus", Native_GetTimerStatus);
|
||||
CreateNative("Shavit_HasStyleAccess", Native_HasStyleAccess);
|
||||
CreateNative("Shavit_IsKZMap", Native_IsKZMap);
|
||||
CreateNative("Shavit_IsPracticeMode", Native_IsPracticeMode);
|
||||
CreateNative("Shavit_LoadSnapshot", Native_LoadSnapshot);
|
||||
@ -660,7 +665,7 @@ public Action Command_Style(int client, int args)
|
||||
}
|
||||
}
|
||||
|
||||
menu.AddItem(sInfo, sDisplay, (gI_Style[client] == i)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
|
||||
menu.AddItem(sInfo, sDisplay, (gI_Style[client] == i || !Shavit_HasStyleAccess(client, i))? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
|
||||
}
|
||||
|
||||
// should NEVER happen
|
||||
@ -729,6 +734,16 @@ void ChangeClientStyle(int client, int style, bool manual)
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Shavit_HasStyleAccess(client, style))
|
||||
{
|
||||
if(manual)
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "StyleNoAccess", client, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(manual)
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "StyleSelection", client, gS_ChatStrings[sMessageStyle], gS_StyleStrings[style][sStyleName], gS_ChatStrings[sMessageText]);
|
||||
@ -921,6 +936,13 @@ public int Native_GetTimerStatus(Handle handler, int numParams)
|
||||
return GetTimerStatus(GetNativeCell(1));
|
||||
}
|
||||
|
||||
public int Native_HasStyleAccess(Handle handler, int numParams)
|
||||
{
|
||||
int style = GetNativeCell(2);
|
||||
|
||||
return CheckCommandAccess(GetNativeCell(1), (strlen(gS_StyleOverride[style]) > 0)? gS_StyleOverride[style]:"<none>", gI_StyleFlag[style]);
|
||||
}
|
||||
|
||||
public int Native_IsKZMap(Handle handler, int numParams)
|
||||
{
|
||||
return view_as<bool>(gB_KZMap);
|
||||
@ -1149,7 +1171,7 @@ public int Native_LoadSnapshot(Handle handler, int numParams)
|
||||
|
||||
gI_Track[client] = view_as<int>(snapshot[iTimerTrack]);
|
||||
|
||||
if(gI_Style[client] != snapshot[bsStyle])
|
||||
if(gI_Style[client] != snapshot[bsStyle] && Shavit_HasStyleAccess(client, snapshot[bsStyle]))
|
||||
{
|
||||
CallOnStyleChanged(client, gI_Style[client], snapshot[bsStyle], false);
|
||||
}
|
||||
@ -1321,7 +1343,11 @@ public void OnClientCookiesCached(int client)
|
||||
}
|
||||
|
||||
int newstyle = (style >= 0 && style < gI_Styles)? style:gI_DefaultStyle;
|
||||
CallOnStyleChanged(client, gI_Style[client], newstyle, false);
|
||||
|
||||
if(Shavit_HasStyleAccess(client, newstyle))
|
||||
{
|
||||
CallOnStyleChanged(client, gI_Style[client], newstyle, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClientPutInServer(int client)
|
||||
@ -1345,6 +1371,7 @@ public void OnClientPutInServer(int client)
|
||||
OnClientCookiesCached(client);
|
||||
}
|
||||
|
||||
// not adding style permission check here for obvious reasons
|
||||
else
|
||||
{
|
||||
CallOnStyleChanged(client, 0, gI_DefaultStyle, false);
|
||||
@ -1445,6 +1472,7 @@ bool LoadStyles()
|
||||
kv.GetString("command", gS_StyleStrings[i][sChangeCommand], 128, "");
|
||||
kv.GetString("clantag", gS_StyleStrings[i][sClanTag], 128, "<MISSING STYLE CLAN TAG>");
|
||||
kv.GetString("specialstring", gS_StyleStrings[i][sSpecialString], 128, "");
|
||||
kv.GetString("permission", gS_StyleStrings[i][sStylePermission], 128, "");
|
||||
|
||||
gA_StyleSettings[i][bAutobhop] = view_as<bool>(kv.GetNum("autobhop", 1));
|
||||
gA_StyleSettings[i][bEasybhop] = view_as<bool>(kv.GetNum("easybhop", 1));
|
||||
@ -1500,6 +1528,21 @@ bool LoadStyles()
|
||||
}
|
||||
}
|
||||
|
||||
if(StrContains(gS_StyleStrings[i][sStylePermission], ";") != -1)
|
||||
{
|
||||
char[][] sText = new char[2][32];
|
||||
int iCount = ExplodeString(gS_StyleStrings[i][sStylePermission], ";", sText, 2, 32);
|
||||
|
||||
AdminFlag flag = Admin_Reservation;
|
||||
|
||||
if(FindFlagByChar(sText[0][0], flag))
|
||||
{
|
||||
gI_StyleFlag[i] = FlagToBit(flag);
|
||||
}
|
||||
|
||||
strcopy(gS_StyleOverride[i], 32, (iCount >= 2)? sText[1]:"");
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
@ -511,18 +511,15 @@ public void OnMapStart()
|
||||
if(gI_CreateSpawnPoints > 0)
|
||||
{
|
||||
int iEntity = -1;
|
||||
float fOrigin[3];
|
||||
|
||||
if((iEntity = FindEntityByClassname(iEntity, "info_player_terrorist")) != INVALID_ENT_REFERENCE || // CS:S/CS:GO T
|
||||
(iEntity = FindEntityByClassname(iEntity, "info_player_counterterrorist")) != INVALID_ENT_REFERENCE || // CS:S/CS:GO CT
|
||||
(iEntity = FindEntityByClassname(iEntity, "info_player_teamspawn")) != INVALID_ENT_REFERENCE || // TF2 spawn point
|
||||
(iEntity = FindEntityByClassname(iEntity, "info_player_start")) != INVALID_ENT_REFERENCE)
|
||||
if((iEntity = FindEntityByClassname(iEntity, "info_player_terrorist")) != -1 || // CS:S/CS:GO T
|
||||
(iEntity = FindEntityByClassname(iEntity, "info_player_counterterrorist")) != -1 || // CS:S/CS:GO CT
|
||||
(iEntity = FindEntityByClassname(iEntity, "info_player_teamspawn")) != -1 || // TF2 spawn point
|
||||
(iEntity = FindEntityByClassname(iEntity, "info_player_start")) != -1)
|
||||
{
|
||||
float fOrigin[3];
|
||||
GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fOrigin);
|
||||
}
|
||||
|
||||
if(iEntity != -1)
|
||||
{
|
||||
for(int i = 1; i <= gI_CreateSpawnPoints; i++)
|
||||
{
|
||||
for(int iTeam = 1; iTeam <= 2; iTeam++)
|
||||
|
||||
@ -806,7 +806,7 @@ void UpdatePlayerRank(int client)
|
||||
// if there's any issue with this query,
|
||||
// add "ORDER BY points DESC " before "LIMIT 1"
|
||||
char[] sQuery = new char[512];
|
||||
FormatEx(sQuery, 512, "SELECT COUNT(*) rank, p.points FROM %susers u JOIN (SELECT points FROM %susers WHERE auth = '%s' LIMIT 1) p WHERE u.points >= p.points LIMIT 1;",
|
||||
FormatEx(sQuery, 512, "SELECT p.points, COUNT(*) rank FROM %susers u JOIN (SELECT points FROM %susers WHERE auth = '%s' LIMIT 1) p WHERE u.points >= p.points LIMIT 1;",
|
||||
gS_MySQLPrefix, gS_MySQLPrefix, sAuthID);
|
||||
|
||||
gH_SQL.Query(SQL_UpdatePlayerRank_Callback, sQuery, GetClientSerial(client), DBPrio_Low);
|
||||
@ -831,8 +831,8 @@ public void SQL_UpdatePlayerRank_Callback(Database db, DBResultSet results, cons
|
||||
|
||||
if(results.FetchRow())
|
||||
{
|
||||
gI_Rank[client] = results.FetchInt(0);
|
||||
gF_Points[client] = results.FetchFloat(1);
|
||||
gF_Points[client] = results.FetchFloat(0);
|
||||
gI_Rank[client] = (gF_Points[client] > 0.0)? results.FetchInt(1):0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -182,12 +182,8 @@ public void OnMapStart()
|
||||
gSM_RankSounds.SetString(sRank, sExploded[1]);
|
||||
}
|
||||
|
||||
// thanks TotallyMehis for this workaround
|
||||
// make sure to star his amazing StandUp plugin! https://github.com/TotallyMehis/StandUp
|
||||
if(gEV_Type == Engine_CSGO || PrecacheSound(sExploded[1]))
|
||||
if(PrecacheSoundAny(sExploded[1]))
|
||||
{
|
||||
PrefetchSound(sExploded[1]);
|
||||
|
||||
FormatEx(sDownloadString, PLATFORM_MAX_PATH, "sound/%s", sExploded[1]);
|
||||
AddFileToDownloadsTable(sDownloadString);
|
||||
}
|
||||
@ -202,6 +198,28 @@ public void OnMapStart()
|
||||
delete fFile;
|
||||
}
|
||||
|
||||
bool PrecacheSoundAny(const char[] path)
|
||||
{
|
||||
if(gEV_Type == Engine_CSGO)
|
||||
{
|
||||
char[] sCSGOPath = new char[PLATFORM_MAX_PATH];
|
||||
FormatEx(sCSGOPath, PLATFORM_MAX_PATH, "*%s", path);
|
||||
|
||||
static int table = INVALID_STRING_TABLE;
|
||||
|
||||
if(table == INVALID_STRING_TABLE)
|
||||
{
|
||||
table = FindStringTable("soundprecache");
|
||||
}
|
||||
|
||||
AddToStringTable(table, sCSGOPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return PrecacheSound(path, true);
|
||||
}
|
||||
|
||||
public void Shavit_OnFinish_Post(int client, int style, float time, int jumps, int strafes, float sync, int rank, int overwrite, int track)
|
||||
{
|
||||
float fOldTime = 0.0;
|
||||
@ -255,7 +273,7 @@ public void Shavit_OnWorstRecord(int client, int style, float time, int jumps, i
|
||||
}
|
||||
}
|
||||
|
||||
void PlayEventSound(int client, bool everyone, const char[] sound)
|
||||
void PlayEventSound(int client, bool everyone, char[] sound)
|
||||
{
|
||||
int[] clients = new int[MaxClients];
|
||||
int count = 0;
|
||||
@ -287,18 +305,9 @@ void PlayEventSound(int client, bool everyone, const char[] sound)
|
||||
{
|
||||
if(gEV_Type == Engine_CSGO)
|
||||
{
|
||||
char[] sPlay = new char[PLATFORM_MAX_PATH+8];
|
||||
FormatEx(sPlay, PLATFORM_MAX_PATH+8, "play */%s", sound);
|
||||
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
ClientCommand(clients[i], sPlay);
|
||||
}
|
||||
Format(sound, PLATFORM_MAX_PATH, "*%s", sound);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
EmitSound(clients, count, sound);
|
||||
}
|
||||
EmitSound(clients, count, sound);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,6 +112,7 @@ Handle gH_AdminMenu = INVALID_HANDLE;
|
||||
|
||||
// misc cache
|
||||
bool gB_Late = false;
|
||||
ConVar sv_gravity = null;
|
||||
|
||||
// cvars
|
||||
ConVar gCV_FlatZones = null;
|
||||
@ -251,6 +252,9 @@ public void OnPluginStart()
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
// misc cvars
|
||||
sv_gravity = FindConVar("sv_gravity");
|
||||
|
||||
for(int i = 0; i < ZONETYPES_SIZE; i++)
|
||||
{
|
||||
for(int j = 0; j < TRACKS_SIZE; j++)
|
||||
@ -1656,19 +1660,19 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
|
||||
|
||||
if(InsideZone(client, Zone_Slide, (gB_EnforceTracks)? track:-1) && GetEntPropEnt(client, Prop_Send, "m_hGroundEntity") == -1)
|
||||
{
|
||||
// raytrace down, see if there's 5 distance or less to ground
|
||||
// trace down, see if there's 8 distance or less to ground
|
||||
float fPosition[3];
|
||||
GetClientAbsOrigin(client, fPosition);
|
||||
TR_TraceRayFilter(fPosition, view_as<float>({90.0, 0.0, 0.0}), MASK_PLAYERSOLID, RayType_Infinite, TRFilter_NoPlayers, client);
|
||||
|
||||
float fGroundPosition[3];
|
||||
|
||||
if(TR_DidHit() && TR_GetEndPosition(fGroundPosition) && GetVectorDistance(fPosition, fGroundPosition) <= 5.0)
|
||||
if(TR_DidHit() && TR_GetEndPosition(fGroundPosition) && GetVectorDistance(fPosition, fGroundPosition) <= 8.0)
|
||||
{
|
||||
float fSpeed[3];
|
||||
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed);
|
||||
|
||||
fSpeed[2] = 5.0;
|
||||
fSpeed[2] = 8.0 * GetEntityGravity(client) * GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue") * (sv_gravity.FloatValue / 800);
|
||||
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,11 @@
|
||||
"#format" "{1:s},{2:s},{3:s}"
|
||||
"en" "The command ({1}{2}{3}) is disabled."
|
||||
}
|
||||
"StyleNoAccess"
|
||||
{
|
||||
"#format" "{1:s},{2:s}"
|
||||
"en" "You lack the {1}permissions{2} for this style."
|
||||
}
|
||||
// ---------- Errors ---------- //
|
||||
"VerificationFailed"
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user