Merge branch 'very_good_yes' into delete_replay

This commit is contained in:
Joe 2021-03-01 02:12:30 +00:00 committed by GitHub
commit b62352835f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 491 additions and 105 deletions

View File

@ -222,6 +222,8 @@ enum struct timer_snapshot_t
int iPerfectJumps;
float fTimeOffset[2];
float fDistanceOffset[2];
float fAvgVelocity;
float fMaxVelocity;
}
enum struct cp_cache_t
@ -249,6 +251,8 @@ enum struct cp_cache_t
int iSerial;
bool bPractice;
int iGroundEntity;
float fAvgVelocity;
float fMaxVelocity;
}
#if defined USES_CHAT_COLORS
@ -457,11 +461,17 @@ stock bool GuessBestMapName(ArrayList maps, const char[] input, char[] output, i
stock void GetTrackName(int client, int track, char[] output, int size)
{
if (track == Track_Main)
FormatEx(output, size, "%T", "Track_Main", client, track);
{
FormatEx(output, size, "%T", "Track_Main", client);
}
else if (track >= Track_Bonus)
{
FormatEx(output, size, "%T", "Track_Bonus", client, track);
}
else //if (track < Track_Main)
{
FormatEx(output, size, "%T", "Track_Unknown", client);
}
}
/**
@ -578,9 +588,12 @@ forward Action Shavit_OnFinishPre(int client, timer_snapshot_t snapshot);
* @param track Timer track.
* @param oldtime The player's best time on the map before this finish.
* @param perfs Perfect jump percentage (0.0 to 100.0) or 100.0 when not measured.
* @param avgvel Player's average velocity throughout the run.
* @param maxvel Player's highest reached velocity.
* @param timestamp System time of when player finished.
* @noreturn
*/
forward void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs);
forward void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp);
/**
* Like Shavit_OnFinish, but after the insertion query was called.
@ -597,9 +610,12 @@ forward void Shavit_OnFinish(int client, int style, float time, int jumps, int s
* @param track Timer track.
* @param oldtime The player's best time on the map before this finish.
* @param perfs Perfect jump percentage (0.0 to 100.0) or 100.0 when not measured.
* @param avgvel Player's average velocity throughout the run.
* @param maxvel Player's highest reached velocity.
* @param timestamp System time of when player finished.
* @noreturn
*/
forward void Shavit_OnFinish_Post(int client, int style, float time, int jumps, int strafes, float sync, int rank, int overwrite, int track, float oldtime, float perfs);
forward void Shavit_OnFinish_Post(int client, int style, float time, int jumps, int strafes, float sync, int rank, int overwrite, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp);
/**
* Called when there's a new WR on the map.
@ -614,9 +630,12 @@ forward void Shavit_OnFinish_Post(int client, int style, float time, int jumps,
* @param oldwr Time of the old WR. 0.0 if there's none.
* @param oldtime The player's best time on the map before this finish.
* @param perfs Perfect jump percentage (0.0 to 100.0) or 100.0 when not measured.
* @param avgvel Player's average velocity throughout the run.
* @param maxvel Player's highest reached velocity.
* @param timestamp System time of when player finished.
* @noreturn
*/
forward void Shavit_OnWorldRecord(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldwr, float oldtime, float perfs);
forward void Shavit_OnWorldRecord(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldwr, float oldtime, float perfs, float avgvel, float maxvel, int timestamp);
/**
* Called when an admin deletes a WR.
@ -772,9 +791,12 @@ forward Action Shavit_OnStageMessage(int client, int stageNumber, char[] message
* @param track Timer track.
* @param oldtime The player's best time on the map before this finish.
* @param perfs Perfect jump percentage (0.0 to 100.0) or 100.0 when not measured.
* @param avgvel Player's average velocity throughout the run.
* @param maxvel Player's highest reached velocity.
* @param timestamp System time of when player finished.
* @noreturn
*/
forward void Shavit_OnWorstRecord(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs);
forward void Shavit_OnWorstRecord(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp);
/**
* Gets called when a map's tier is assigned.
@ -822,6 +844,50 @@ forward void Shavit_OnReplayEnd(int client);
*/
forward void Shavit_OnReplaysLoaded();
/**
* Called when a player finishes a time. Allows you to save a replay even if the run is not a WR.
*
* @param client Client index.
* @param style Style the record was done on.
* @param time Record time.
* @param jumps Jumps amount.
* @param strafes Amount of strafes.
* @param sync Sync percentage (0.0 to 100.0) or -1.0 when not measured.
* @param track Timer track.
* @param oldtime The player's best time on the map before this finish.
* @param perfs Perfect jump percentage (0.0 to 100.0) or 100.0 when not measured.
* @param avgvel Player's average velocity throughout the run.
* @param maxvel Player's highest reached velocity.
* @param timestamp System time of when player finished.
* @param iswr If the time is the new WR.
* @param istoolong If the time is too long to save a replay if the time is a WR.
* @return Return Plugin_Changed (or higher) to cause a copy of the replay to be saved. Return Plugin_Continue otherwise.
*/
forward Action Shavit_ShouldSaveReplayCopy(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool iswr, bool istoolong);
/**
* Called when either a WR replay or a copy of a replay has been saved.
*
* @param client Client index.
* @param style Style the record was done on.
* @param time Record time.
* @param jumps Jumps amount.
* @param strafes Amount of strafes.
* @param sync Sync percentage (0.0 to 100.0) or -1.0 when not measured.
* @param track Timer track.
* @param oldtime The player's best time on the map before this finish.
* @param perfs Perfect jump percentage (0.0 to 100.0) or 100.0 when not measured.
* @param avgvel Player's average velocity throughout the run.
* @param maxvel Player's highest reached velocity.
* @param timestamp System time of when player finished.
* @param iswr If the time is the new WR.
* @param istoolong If the time is too long to save a replay if the time is a WR.
* @param iscopy If the path points to a copy of the replay.
* @param replaypath Path to the saved replay.
* @noreturn
*/
forward void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool iswr, bool istoolong, bool iscopy, const char[] replaypath);
/**
* Called when top left HUD updates.
*
@ -1548,7 +1614,6 @@ native int Shavit_GetWRCount(int client);
*/
native bool Shavit_GetStyleSetting(int style, const char[] key, char[] value, int maxlength);
/*
* Gets an int value from the style config for the given style. Returns 0 if key is not found.
* e.g. Shavit_GetStyleSettingInt(Shavit_GetBhopStyle(client), "TAS");
@ -1560,7 +1625,6 @@ native bool Shavit_GetStyleSetting(int style, const char[] key, char[] value, in
*/
native int Shavit_GetStyleSettingInt(int style, const char[] key);
/*
* Gets the bool value from the style config for the given style. Returns false if key is not found.
* e.g. if(Shavit_GetStyleSettingBool(Shavit_GetBhopStyle(client), "TAS"))
@ -1572,7 +1636,6 @@ native int Shavit_GetStyleSettingInt(int style, const char[] key);
*/
native bool Shavit_GetStyleSettingBool(int style, const char[] key);
/*
* Gets a float value from the style config for the given style. Returns 0.0 if key is not found
* e.g. Shavit_GetStyleSettingFloat(Shavit_GetBhopStyle(client), "speed");
@ -1584,7 +1647,6 @@ native bool Shavit_GetStyleSettingBool(int style, const char[] key);
*/
native float Shavit_GetStyleSettingFloat(int style, const char[] key);
/*
* Checks if the given key exists for that style
* e.g. Shavit_HasStyleSetting(Shavit_GetBhopStyle(client), "tas");
@ -1596,6 +1658,42 @@ native float Shavit_GetStyleSettingFloat(int style, const char[] key);
*/
native bool Shavit_HasStyleSetting(int style, const char[] key);
/*
* Set the style setting to the given float value
*
* @param style Style index.
* @param key Style key to set.
* @param value Value to set the style key to.
* @param replace Should the value be set if the given key already exists.
*
* @return True on success, false on failure. .
*/
native bool Shavit_SetStyleSettingFloat(int style, const char[] key, float value, bool replace = true);
/*
* Set the style setting to the given bool value
*
* @param style Style index.
* @param key Style key to set.
* @param value Value to set the style key to.
* @param replace Should the value be set if the given key already exists.
*
* @return True on success, false on failure. .
*/
native bool Shavit_SetStyleSettingBool(int style, const char[] key, bool value, bool replace = true);
/*
* Set the style setting to the given int value
*
* @param style Style index.
* @param key Style key to set.
* @param value Value to set the style key to.
* @param replace Should the value be set if the given key already exists.
*
* @return True on success, false on failure. .
*/
native bool Shavit_SetStyleSettingInt(int style, const char[] key, int value, bool replace = true);
/**
* Saves the style settings on `any` references.
*
@ -1841,6 +1939,41 @@ native int Shavit_PrintToChat(int client, const char[] format, any ...);
*/
native void Shavit_LogMessage(const char[] format, any ...);
/**
* Gets the average velocity of a player.
* Average calculation: avg += (vel - avg) / frames
*
* @param client Client index
* @return Client's average velocity
*/
native float Shavit_GetAvgVelocity(int client);
/**
* Gets the max velocity of a player.
*
* @param client Client index
* @return Client's highest velocity
*/
native float Shavit_GetMaxVelocity(int client);
/**
* Sets the average velocity of a player.
*
* @param client Client index
* @param vel Average velocity
* @noreturn
*/
native void Shavit_SetAvgVelocity(int client, float vel);
/**
* Gets the max velocity of a player.
*
* @param client Client index
* @param vel Max velocity
* @noreturn
*/
native void Shavit_SetMaxVelocity(int client, float vel);
/**
* Gets the total number of CPs that a client has saved
*
@ -1961,6 +2094,15 @@ native int Shavit_GetCurrentCheckpoint(int client);
*/
native void Shavit_SetCurrentCheckpoint(int client, int index);
/**
* Gets how many times the client has teleported to checkpoints.
*
* @param client Client index
*
* @return The number of times the client has teleported to checkpoints.
*/
native int Shavit_GetTimesTeleported(int client);
/*
* returns the number of preframes in the players current run.
*
@ -2135,10 +2277,15 @@ public void __pl_shavit_SetNTVOptional()
MarkNativeAsOptional("Shavit_SaveCheckpoint");
MarkNativeAsOptional("Shavit_GetCurrentCheckpoint");
MarkNativeAsOptional("Shavit_SetCurrentCheckpoint");
MarkNativeAsOptional("Shavit_GetTimesTeleported");
MarkNativeAsOptional("Shavit_GetPlayerPreFrame");
MarkNativeAsOptional("Shavit_GetPlayerTimerFrame");
MarkNativeAsOptional("Shavit_SetPlayerPreFrame");
MarkNativeAsOptional("Shavit_GetClosestReplayTime");
MarkNativeAsOptional("Shavit_SetPlayerTimerFrame");
MarkNativeAsOptional("Shavit_SetStyleSetting");
MarkNativeAsOptional("Shavit_SetStyleSettingFloat");
MarkNativeAsOptional("Shavit_SetStyleSettingBool");
MarkNativeAsOptional("Shavit_SetStyleSettingInt");
}
#endif

View File

@ -1203,12 +1203,12 @@ void FormatRandom(char[] buffer, int size)
{
if(IsSource2013(gEV_Type))
{
FormatEx(temp, 8, "\x07%06X", RealRandomInt(0, 0xFFFFFF));
FormatEx(temp, 8, "\x07%06X", GetRandomInt(0, 0xFFFFFF));
}
else
{
strcopy(temp, 8, gS_CSGOColors[RealRandomInt(0, sizeof(gS_CSGOColors) - 1)]);
strcopy(temp, 8, gS_CSGOColors[GetRandomInt(0, sizeof(gS_CSGOColors) - 1)]);
}
}
@ -1257,18 +1257,6 @@ void FormatChat(int client, char[] buffer, int size)
ReplaceString(buffer, size, "{name}", sName);
}
int RealRandomInt(int min, int max)
{
int random = GetURandomInt();
if(random == 0)
{
random++;
}
return (RoundToCeil(float(random) / (2147483647.0 / float(max - min + 1))) + min - 1);
}
void SQL_DBConnect()
{
GetTimerSQLPrefix(gS_MySQLPrefix, 32);

View File

@ -65,6 +65,8 @@ enum struct playertimer_t
float fDistanceOffset[2];
// convert to array for per zone offsets
int iZoneIncrement;
float fAvgVelocity;
float fMaxVelocity;
}
// game type (CS:S/CS:GO/TF2)
@ -233,11 +235,19 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_ResumeTimer", Native_ResumeTimer);
CreateNative("Shavit_SaveSnapshot", Native_SaveSnapshot);
CreateNative("Shavit_SetPracticeMode", Native_SetPracticeMode);
CreateNative("Shavit_SetStyleSetting", Native_SetStyleSetting);
CreateNative("Shavit_SetStyleSettingFloat", Native_SetStyleSettingFloat);
CreateNative("Shavit_SetStyleSettingBool", Native_SetStyleSettingBool);
CreateNative("Shavit_SetStyleSettingInt", Native_SetStyleSettingInt);
CreateNative("Shavit_StartTimer", Native_StartTimer);
CreateNative("Shavit_StopChatSound", Native_StopChatSound);
CreateNative("Shavit_StopTimer", Native_StopTimer);
CreateNative("Shavit_GetClientTimescale", Native_GetClientTimescale);
CreateNative("Shavit_SetClientTimescale", Native_SetClientTimescale);
CreateNative("Shavit_GetAvgVelocity", Native_GetAvgVelocity);
CreateNative("Shavit_GetMaxVelocity", Native_GetMaxVelocity);
CreateNative("Shavit_SetAvgVelocity", Native_SetAvgVelocity);
CreateNative("Shavit_SetMaxVelocity", Native_SetMaxVelocity);
// registers library, check "bool LibraryExists(const char[] name)" in order to use with other plugins
RegPluginLibrary("shavit");
@ -256,7 +266,7 @@ public void OnPluginStart()
gH_Forwards_Stop = CreateGlobalForward("Shavit_OnStop", ET_Event, Param_Cell, Param_Cell);
gH_Forwards_StopPre = CreateGlobalForward("Shavit_OnStopPre", ET_Event, Param_Cell, Param_Cell);
gH_Forwards_FinishPre = CreateGlobalForward("Shavit_OnFinishPre", ET_Event, Param_Cell, Param_Array);
gH_Forwards_Finish = CreateGlobalForward("Shavit_OnFinish", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_Forwards_Finish = CreateGlobalForward("Shavit_OnFinish", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_Forwards_OnRestart = CreateGlobalForward("Shavit_OnRestart", ET_Event, Param_Cell, Param_Cell);
gH_Forwards_OnEnd = CreateGlobalForward("Shavit_OnEnd", ET_Event, Param_Cell, Param_Cell);
gH_Forwards_OnPause = CreateGlobalForward("Shavit_OnPause", ET_Event, Param_Cell, Param_Cell);
@ -1662,6 +1672,8 @@ public int Native_FinishMap(Handle handler, int numParams)
snapshot.iPerfectJumps = gA_Timers[client].iPerfectJumps;
snapshot.fTimeOffset = gA_Timers[client].fTimeOffset;
snapshot.fDistanceOffset = gA_Timers[client].fDistanceOffset;
snapshot.fAvgVelocity = gA_Timers[client].fAvgVelocity;
snapshot.fMaxVelocity = gA_Timers[client].fMaxVelocity;
Action result = Plugin_Continue;
Call_StartForward(gH_Forwards_FinishPre);
@ -1714,6 +1726,19 @@ public int Native_FinishMap(Handle handler, int numParams)
Call_PushCell(oldtime);
Call_PushCell(perfs);
if(result == Plugin_Continue)
{
Call_PushCell(gA_Timers[client].fAvgVelocity);
Call_PushCell(gA_Timers[client].fMaxVelocity);
}
else
{
Call_PushCell(snapshot.fAvgVelocity);
Call_PushCell(snapshot.fMaxVelocity);
}
Call_PushCell(GetTime());
Call_Finish();
StopTimer(client);
@ -2004,6 +2029,8 @@ public int Native_SaveSnapshot(Handle handler, int numParams)
snapshot.iPerfectJumps = gA_Timers[client].iPerfectJumps;
snapshot.fTimeOffset = gA_Timers[client].fTimeOffset;
snapshot.fDistanceOffset = gA_Timers[client].fDistanceOffset;
snapshot.fAvgVelocity = gA_Timers[client].fAvgVelocity;
snapshot.fMaxVelocity = gA_Timers[client].fMaxVelocity;
return SetNativeArray(2, snapshot, sizeof(timer_snapshot_t));
}
@ -2050,6 +2077,8 @@ public int Native_LoadSnapshot(Handle handler, int numParams)
gA_Timers[client].iPerfectJumps = snapshot.iPerfectJumps;
gA_Timers[client].fTimeOffset = snapshot.fTimeOffset;
gA_Timers[client].fDistanceOffset = snapshot.fDistanceOffset;
gA_Timers[client].fAvgVelocity = snapshot.fAvgVelocity;
gA_Timers[client].fMaxVelocity = snapshot.fMaxVelocity;
return 0;
}
@ -2169,14 +2198,98 @@ public any Native_HasStyleSetting(Handle handler, int numParams)
return HasStyleSetting(style, sKey);
}
public any Native_GetAvgVelocity(Handle plugin, int numParams)
{
return gA_Timers[GetNativeCell(1)].fAvgVelocity;
}
public any Native_GetMaxVelocity(Handle plugin, int numParams)
{
return gA_Timers[GetNativeCell(1)].fMaxVelocity;
}
public any Native_SetAvgVelocity(Handle plugin, int numParams)
{
gA_Timers[GetNativeCell(1)].fAvgVelocity = GetNativeCell(2);
}
public any Native_SetMaxVelocity(Handle plugin, int numParams)
{
gA_Timers[GetNativeCell(1)].fMaxVelocity = GetNativeCell(2);
}
bool HasStyleSetting(int style, char[] key)
{
char sValue[1];
gSM_StyleKeys[style].GetString(key, sValue, 1);
return gSM_StyleKeys[style].GetString(key, sValue, 1);
}
public any Native_SetStyleSetting(Handle handler, int numParams)
{
int style = GetNativeCell(1);
char sKey[256];
GetNativeString(2, sKey, 256);
char sValue[256];
GetNativeString(3, sValue, 256);
bool replace = GetNativeCell(4);
return gSM_StyleKeys[style].SetString(sKey, sValue, replace);
}
public any Native_SetStyleSettingFloat(Handle handler, int numParams)
{
int style = GetNativeCell(1);
char sKey[256];
GetNativeString(2, sKey, 256);
float fValue = GetNativeCell(3);
char sValue[16];
FloatToString(fValue, sValue, 16);
bool replace = GetNativeCell(4);
return gSM_StyleKeys[style].SetString(sKey, sValue, replace);
}
public any Native_SetStyleSettingBool(Handle handler, int numParams)
{
int style = GetNativeCell(1);
char sKey[256];
GetNativeString(2, sKey, 256);
bool value = GetNativeCell(3);
bool replace = GetNativeCell(4);
return gSM_StyleKeys[style].SetString(sKey, value ? "1" : "0", replace);
}
public any Native_SetStyleSettingInt(Handle handler, int numParams)
{
int style = GetNativeCell(1);
char sKey[256];
GetNativeString(2, sKey, 256);
int value = GetNativeCell(3);
char sValue[16];
IntToString(value, sValue, 16);
bool replace = GetNativeCell(4);
return gSM_StyleKeys[style].SetString(sKey, sValue, replace);
}
int GetTimerStatus(int client)
{
if(!gA_Timers[client].bEnabled)
@ -2201,10 +2314,11 @@ void StartTimer(int client, int track)
float fSpeed[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", fSpeed);
float curVel = SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0));
if(!gCV_NoZAxisSpeed.BoolValue ||
GetStyleSettingInt(gA_Timers[client].iStyle, "prespeed") == 1 ||
(fSpeed[2] == 0.0 && (GetStyleSettingInt(gA_Timers[client].iStyle, "prespeed") == 2 || SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0)) <= 290.0)))
(fSpeed[2] == 0.0 && (GetStyleSettingInt(gA_Timers[client].iStyle, "prespeed") == 2 || curVel <= 290.0)))
{
Action result = Plugin_Continue;
Call_StartForward(gH_Forwards_Start);
@ -2243,6 +2357,8 @@ void StartTimer(int client, int track)
gA_Timers[client].fTimeOffset[Zone_End] = 0.0;
gA_Timers[client].fDistanceOffset[Zone_Start] = 0.0;
gA_Timers[client].fDistanceOffset[Zone_End] = 0.0;
gA_Timers[client].fAvgVelocity = curVel;
gA_Timers[client].fMaxVelocity = curVel;
if(gA_Timers[client].fTimescale != -1.0)
{
@ -3317,6 +3433,8 @@ public MRESReturn DHook_ProcessMovementPost(Handle hParams)
snapshot.iTimerTrack = gA_Timers[client].iTrack;
snapshot.fTimeOffset = gA_Timers[client].fTimeOffset;
snapshot.fDistanceOffset = gA_Timers[client].fDistanceOffset;
snapshot.fAvgVelocity = gA_Timers[client].fAvgVelocity;
snapshot.fMaxVelocity = gA_Timers[client].fMaxVelocity;
Call_StartForward(gH_Forwards_OnTimerIncrement);
Call_PushCell(client);
@ -3617,19 +3735,12 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
gA_Timers[client].iSHSWCombination = iCombination;
}
bool bStop = false;
// W/A S/D
if((gA_Timers[client].iSHSWCombination == 0 && iCombination != 0) ||
// W/D S/A
(gA_Timers[client].iSHSWCombination == 1 && iCombination != 1) ||
// no valid combination & no valid input
(gA_Timers[client].iSHSWCombination == -1 && iCombination == -1))
{
bStop = true;
}
if(bStop)
{
vel[0] = 0.0;
vel[1] = 0.0;
@ -3643,7 +3754,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
else
{
if((bForward || bBack) && !(bMoveLeft || bMoveRight))
if(bBack && (bMoveLeft || bMoveRight))
{
vel[0] = 0.0;
@ -3651,7 +3762,15 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
buttons &= ~IN_BACK;
}
if((bMoveLeft || bMoveRight) && !(bForward || bBack))
if(bForward && !(bMoveLeft || bMoveRight))
{
vel[0] = 0.0;
buttons &= ~IN_FORWARD;
buttons &= ~IN_BACK;
}
if((bMoveLeft || bMoveRight) && !bForward)
{
vel[1] = 0.0;
@ -3770,6 +3889,20 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
}
}
if (GetTimerStatus(client) == view_as<int>(Timer_Running) && gA_Timers[client].fTimer != 0.0)
{
float frameCount = gB_Replay
? float(Shavit_GetClientFrameCount(client) - Shavit_GetPlayerTimerFrame(client)) + 1
: (gA_Timers[client].fTimer / GetTickInterval());
float fAbsVelocity[3];
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fAbsVelocity);
float curVel = SquareRoot(Pow(fAbsVelocity[0], 2.0) + Pow(fAbsVelocity[1], 2.0));
float maxVel = gA_Timers[client].fMaxVelocity;
gA_Timers[client].fMaxVelocity = (curVel > maxVel) ? curVel : maxVel;
// STOLEN from Epic/Disrevoid. Thx :)
gA_Timers[client].fAvgVelocity += (curVel - gA_Timers[client].fAvgVelocity) / frameCount;
}
gA_Timers[client].iLastButtons = iPButtons;
gA_Timers[client].fLastAngle = angles[1];
gA_Timers[client].bJumped = false;

View File

@ -59,6 +59,8 @@ enum struct persistent_data_t
int iPreFrames;
int iTimerPreFrames;
bool bPractice;
float fAvgVelocity;
float fMaxVelocity;
}
enum struct savestate_t
@ -91,6 +93,7 @@ bool gB_ClosedKZCP[MAXPLAYERS+1];
ArrayList gA_Checkpoints[MAXPLAYERS+1];
int gI_CurrentCheckpoint[MAXPLAYERS+1];
int gI_TimesTeleported[MAXPLAYERS+1];
int gI_CheckpointsSettings[MAXPLAYERS+1];
ArrayList gA_Targetnames = null;
@ -199,6 +202,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_SaveCheckpoint", Native_SaveCheckpoint);
CreateNative("Shavit_GetCurrentCheckpoint", Native_GetCurrentCheckpoint);
CreateNative("Shavit_SetCurrentCheckpoint", Native_SetCurrentCheckpoint);
CreateNative("Shavit_GetTimesTeleported", Native_GetTimesTeleported);
gB_Late = late;
@ -1212,6 +1216,8 @@ void PersistData(int client)
aData.fGravity = GetEntityGravity(client);
aData.fSpeed = GetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue");
aData.bPractice = Shavit_IsPracticeMode(client);
aData.fAvgVelocity = Shavit_GetAvgVelocity(client);
aData.fMaxVelocity = Shavit_GetMaxVelocity(client);
float fPosition[3];
GetClientAbsOrigin(client, fPosition);
@ -1334,6 +1340,9 @@ public Action Timer_LoadPersistentData(Handle Timer, any data)
Shavit_SetPracticeMode(client, true, false);
}
Shavit_SetAvgVelocity(client, aData.fAvgVelocity);
Shavit_SetMaxVelocity(client, aData.fMaxVelocity);
delete aData.aFrames;
gA_PersistentData.Erase(iIndex);
@ -2407,7 +2416,8 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
cpcache.iSerial = GetClientSerial(target);
cpcache.bPractice = Shavit_IsPracticeMode(target);
cpcache.fAvgVelocity = Shavit_GetAvgVelocity(target);
cpcache.fMaxVelocity = Shavit_GetMaxVelocity(target);
if(overflow)
{
@ -2492,6 +2502,8 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)
return;
}
gI_TimesTeleported[client]++;
if(Shavit_InsideZone(client, Zone_Start, -1))
{
Shavit_StopTimer(client);
@ -2526,6 +2538,9 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)
SetEntPropFloat(client, Prop_Send, "m_flDuckSpeed", cpcache.fDuckSpeed);
}
Shavit_SetAvgVelocity(client, cpcache.fAvgVelocity);
Shavit_SetMaxVelocity(client, cpcache.fMaxVelocity);
float ang[3];
CopyArray(cpcache.fAngles, ang, 3);
@ -2863,6 +2878,8 @@ public Action Command_Specs(int client, int args)
public Action Shavit_OnStart(int client)
{
gI_TimesTeleported[client] = 0;
if(Shavit_GetStyleSettingInt(gI_Style[client], "prespeed") == 0 && GetEntityMoveType(client) == MOVETYPE_NOCLIP)
{
return Plugin_Stop;
@ -3561,6 +3578,11 @@ public any Native_TeleportToCheckpoint(Handle plugin, int numParams)
return 0;
}
public any Native_GetTimesTeleported(Handle plugin, int numParams)
{
return gI_TimesTeleported[GetNativeCell(1)];
}
public any Native_GetTotalCheckpoints(Handle plugin, int numParams)
{
return gA_Checkpoints[GetNativeCell(1)].Length;

View File

@ -130,6 +130,8 @@ bool gB_Late = false;
Handle gH_OnReplayStart = null;
Handle gH_OnReplayEnd = null;
Handle gH_OnReplaysLoaded = null;
Handle gH_ShouldSaveReplayCopy = null;
Handle gH_OnReplaySaved = null;
// server specific
float gF_Tickrate = 0.0;
@ -244,14 +246,15 @@ public void OnPluginStart()
LoadTranslations("shavit-replay.phrases");
// forwards
gH_OnReplayStart = CreateGlobalForward("Shavit_OnReplayStart", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnReplayEnd = CreateGlobalForward("Shavit_OnReplayEnd", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnReplayStart = CreateGlobalForward("Shavit_OnReplayStart", ET_Event, Param_Cell);
gH_OnReplayEnd = CreateGlobalForward("Shavit_OnReplayEnd", ET_Event, Param_Cell);
gH_OnReplaysLoaded = CreateGlobalForward("Shavit_OnReplaysLoaded", ET_Event);
gH_ShouldSaveReplayCopy = CreateGlobalForward("Shavit_ShouldSaveReplayCopy", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnReplaySaved = CreateGlobalForward("Shavit_OnReplaySaved", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_String);
// game specific
gEV_Type = GetEngineVersion();
gF_Tickrate = (1.0 / GetTickInterval());
FindConVar((gEV_Type != Engine_TF2)? "bot_quota":"tf_bot_quota").Flags &= ~FCVAR_NOTIFY;
FindConVar("bot_stop").Flags &= ~FCVAR_CHEAT;
@ -961,6 +964,14 @@ public void OnMapStart()
CreateDirectory(gS_ReplayFolder, 511);
}
char sPath[PLATFORM_MAX_PATH];
FormatEx(sPath, PLATFORM_MAX_PATH, "%s/copy", gS_ReplayFolder);
if(!DirExists(sPath))
{
CreateDirectory(sPath, 511);
}
for(int i = 0; i < gI_Styles; i++)
{
gI_ReplayTick[i] = -1;
@ -972,7 +983,6 @@ public void OnMapStart()
continue;
}
char sPath[PLATFORM_MAX_PATH];
FormatEx(sPath, PLATFORM_MAX_PATH, "%s/%d", gS_ReplayFolder, i);
if(!DirExists(sPath))
@ -1270,21 +1280,8 @@ bool LoadReplay(int style, int track, const char[] path)
return false;
}
bool SaveReplay(int style, int track, float time, int steamid, char[] name, int preframes, ArrayList playerrecording, int timerstartframe)
void WriteReplayHeader(File fFile, int style, int track, float time, int steamid, int preframes, int timerstartframe, int iSize)
{
char sTrack[4];
FormatEx(sTrack, 4, "_%d", track);
char sPath[PLATFORM_MAX_PATH];
FormatEx(sPath, PLATFORM_MAX_PATH, "%s/%d/%s%s.replay", gS_ReplayFolder, style, gS_Map, (track > 0)? sTrack:"");
if(FileExists(sPath))
{
DeleteFile(sPath);
}
File fFile = OpenFile(sPath, "wb");
fFile.WriteLine("%d:" ... REPLAY_FORMAT_FINAL, REPLAY_FORMAT_SUBVERSION);
fFile.WriteString(gS_Map, true);
@ -1292,30 +1289,68 @@ bool SaveReplay(int style, int track, float time, int steamid, char[] name, int
fFile.WriteInt8(track);
fFile.WriteInt32(timerstartframe - preframes);
int iSize = playerrecording.Length;
fFile.WriteInt32(iSize - preframes);
fFile.WriteInt32(view_as<int>(time));
fFile.WriteInt32(steamid);
}
void SaveReplay(int style, int track, float time, int steamid, char[] name, int preframes, ArrayList playerrecording, int timerstartframe, int timestamp, bool saveCopy, bool saveWR, char[] sPath, int sPathLen)
{
char sTrack[4];
FormatEx(sTrack, 4, "_%d", track);
File fWR = null;
File fCopy = null;
if (saveWR)
{
FormatEx(sPath, sPathLen, "%s/%d/%s%s.replay", gS_ReplayFolder, style, gS_Map, (track > 0)? sTrack:"");
DeleteFile(sPath);
fWR = OpenFile(sPath, "wb");
}
if (saveCopy)
{
FormatEx(sPath, sPathLen, "%s/copy/%d_%d_%s.replay", gS_ReplayFolder, timestamp, steamid, gS_Map);
DeleteFile(sPath);
fCopy = OpenFile(sPath, "wb");
}
int iSize = playerrecording.Length;
if (saveWR)
{
WriteReplayHeader(fWR, style, track, time, steamid, preframes, timerstartframe, iSize);
// How did I trigger this?
if(gA_Frames[style][track] == null)
{
gA_Frames[style][track] = new ArrayList(CELLS_PER_FRAME);
}
else
{
gA_Frames[style][track].Clear();
}
}
if (saveCopy)
{
WriteReplayHeader(fCopy, style, track, time, steamid, preframes, timerstartframe, iSize);
}
any aFrameData[CELLS_PER_FRAME];
any aWriteData[CELLS_PER_FRAME * FRAMES_PER_WRITE];
int iFramesWritten = 0;
// How did I trigger this?
if(gA_Frames[style][track] == null)
{
gA_Frames[style][track] = new ArrayList(CELLS_PER_FRAME);
}
else
{
gA_Frames[style][track].Clear();
}
for(int i = preframes; i < iSize; i++)
{
playerrecording.GetArray(i, aFrameData, CELLS_PER_FRAME);
gA_Frames[style][track].PushArray(aFrameData);
if (saveWR)
{
gA_Frames[style][track].PushArray(aFrameData);
}
for(int j = 0; j < CELLS_PER_FRAME; j++)
{
aWriteData[(CELLS_PER_FRAME * iFramesWritten) + j] = aFrameData[j];
@ -1323,21 +1358,33 @@ bool SaveReplay(int style, int track, float time, int steamid, char[] name, int
if(++iFramesWritten == FRAMES_PER_WRITE || i == iSize - 1)
{
fFile.Write(aWriteData, CELLS_PER_FRAME * iFramesWritten, 4);
if (saveWR)
{
fWR.Write(aWriteData, CELLS_PER_FRAME * iFramesWritten, 4);
}
if (saveCopy)
{
fCopy.Write(aWriteData, CELLS_PER_FRAME * iFramesWritten, 4);
}
iFramesWritten = 0;
}
}
delete fFile;
delete fWR;
delete fCopy;
if (!saveWR)
{
return;
}
gA_FrameCache[style][track].iFrameCount = iSize - preframes;
gA_FrameCache[style][track].fTime = time;
gA_FrameCache[style][track].bNewFormat = true;
strcopy(gA_FrameCache[style][track].sReplayName, MAX_NAME_LENGTH, name);
gA_FrameCache[style][track].iPreFrames = timerstartframe - preframes;
return true;
}
bool DeleteReplay(int style, int track, bool unload_replay = false, int accountid = 0, const char[] mapname = gS_Map)
@ -1528,6 +1575,8 @@ void UpdateReplayInfo(int client, int style, float time, int track)
{
return;
}
gF_Tickrate = (1.0 / GetTickInterval());
SetEntProp(client, Prop_Data, "m_CollisionGroup", 2);
SetEntityMoveType(client, MOVETYPE_NOCLIP);
@ -1755,52 +1804,90 @@ public void Shavit_OnLeaveZone(int client, int type, int track, int id, int enti
}
}
public void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track)
public void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp)
{
if(Shavit_IsPracticeMode(client))
{
return;
}
if(!gCV_Enabled.BoolValue || (gCV_TimeLimit.FloatValue > 0.0 && time > gCV_TimeLimit.FloatValue))
if(Shavit_IsPracticeMode(client) || !gCV_Enabled.BoolValue || gI_PlayerFrames[client] == 0)
{
return;
}
bool isTooLong = (gCV_TimeLimit.FloatValue > 0.0 && time > gCV_TimeLimit.FloatValue);
bool isWR = true;
float length = GetReplayLength(style, track);
if(gA_FrameCache[style][track].bNewFormat)
{
if(length > 0.0 && time > length)
{
return;
isWR = false;
}
}
else
{
float wrtime = Shavit_GetWorldRecord(style, track);
if(wrtime != 0.0 && time > wrtime)
{
return;
isWR = false;
}
}
if(gI_PlayerFrames[client] == 0)
Action action = Plugin_Continue;
Call_StartForward(gH_ShouldSaveReplayCopy);
Call_PushCell(client);
Call_PushCell(style);
Call_PushCell(time);
Call_PushCell(jumps);
Call_PushCell(strafes);
Call_PushCell(sync);
Call_PushCell(track);
Call_PushCell(oldtime);
Call_PushCell(perfs);
Call_PushCell(avgvel);
Call_PushCell(maxvel);
Call_PushCell(timestamp);
Call_PushCell(isTooLong);
Call_PushCell(isWR);
Call_Finish(action);
bool makeCopy = (action != Plugin_Continue);
bool makeWR = (isWR && !isTooLong);
if (!makeCopy && !makeWR)
{
return;
}
int iSteamID = GetSteamAccountID(client);
char sName[MAX_NAME_LENGTH];
GetClientName(client, sName, MAX_NAME_LENGTH);
ReplaceString(sName, MAX_NAME_LENGTH, "#", "?");
SaveReplay(style, track, time, iSteamID, sName, gI_PlayerPrerunFrames[client], gA_PlayerFrames[client], gI_PlayerTimerStartFrames[client]);
char sPath[PLATFORM_MAX_PATH];
SaveReplay(style, track, time, iSteamID, sName, gI_PlayerPrerunFrames[client], gA_PlayerFrames[client], gI_PlayerTimerStartFrames[client], timestamp, makeCopy, makeWR, sPath, sizeof(sPath));
if(ReplayEnabled(style))
Call_StartForward(gH_OnReplaySaved);
Call_PushCell(client);
Call_PushCell(style);
Call_PushCell(time);
Call_PushCell(jumps);
Call_PushCell(strafes);
Call_PushCell(sync);
Call_PushCell(track);
Call_PushCell(oldtime);
Call_PushCell(perfs);
Call_PushCell(avgvel);
Call_PushCell(maxvel);
Call_PushCell(timestamp);
Call_PushCell(isTooLong);
Call_PushCell(isWR);
Call_PushCell(makeCopy);
Call_PushString(sPath);
Call_Finish();
if(makeWR && ReplayEnabled(style))
{
if(gCV_CentralBot.BoolValue && gA_CentralCache.iStyle == style && gA_CentralCache.iTrack == track)
{

View File

@ -431,7 +431,7 @@ Action OpenStatsMenu(int client, int steamid)
"JOIN (SELECT COUNT(*) maps FROM (SELECT map FROM %smapzones WHERE track = 0 AND type = 0 GROUP BY map) s) b " ...
"JOIN (SELECT COUNT(*) wrs FROM %splayertimes a JOIN (SELECT MIN(time) time, map FROM %splayertimes WHERE style = 0 AND track = 0 GROUP by map, style, track) b ON a.time = b.time AND a.map = b.map AND track = 0 AND style = 0 WHERE auth = %d) c " ...
"JOIN (SELECT name, ip, lastlogin, FORMAT(points, 2) points FROM %susers WHERE auth = %d) d " ...
"JOIN (SELECT COUNT(*) rank FROM %susers as u1 JOIN (SELECT points FROM %susers WHERE auth = %d) u2 WHERE u1.points >= u2.points) e " ...
"JOIN (SELECT COUNT(*) as 'rank' FROM %susers as u1 JOIN (SELECT points FROM %susers WHERE auth = %d) u2 WHERE u1.points >= u2.points) e " ...
"LIMIT 1;", gS_MySQLPrefix, steamid, gS_MySQLPrefix, gS_MySQLPrefix, gS_MySQLPrefix, steamid, gS_MySQLPrefix, steamid, gS_MySQLPrefix, gS_MySQLPrefix, steamid);
}
@ -648,7 +648,7 @@ void ShowMaps(int client)
if(gI_MapType[client] == MAPSDONE)
{
FormatEx(sQuery, 512,
"SELECT a.map, a.time, a.jumps, a.id, COUNT(b.map) + 1 rank, a.points FROM %splayertimes a LEFT JOIN %splayertimes b ON a.time > b.time AND a.map = b.map AND a.style = b.style AND a.track = b.track WHERE a.auth = %d AND a.style = %d AND a.track = %d GROUP BY a.map, a.time, a.jumps, a.id, a.points ORDER BY a.%s;",
"SELECT a.map, a.time, a.jumps, a.id, COUNT(b.map) + 1 as 'rank', a.points FROM %splayertimes a LEFT JOIN %splayertimes b ON a.time > b.time AND a.map = b.map AND a.style = b.style AND a.track = b.track WHERE a.auth = %d AND a.style = %d AND a.track = %d GROUP BY a.map, a.time, a.jumps, a.id, a.points ORDER BY a.%s;",
gS_MySQLPrefix, gS_MySQLPrefix, gI_TargetSteamID[client], gI_Style[client], gI_Track[client], (gB_Rankings)? "points DESC":"map");
}

View File

@ -133,10 +133,10 @@ public void OnPluginStart()
#endif
// forwards
gH_OnWorldRecord = CreateGlobalForward("Shavit_OnWorldRecord", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnFinish_Post = CreateGlobalForward("Shavit_OnFinish_Post", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnWorldRecord = CreateGlobalForward("Shavit_OnWorldRecord", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnFinish_Post = CreateGlobalForward("Shavit_OnFinish_Post", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnWRDeleted = CreateGlobalForward("Shavit_OnWRDeleted", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_String);
gH_OnWorstRecord = CreateGlobalForward("Shavit_OnWorstRecord", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnWorstRecord = CreateGlobalForward("Shavit_OnWorstRecord", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
gH_OnFinishMessage = CreateGlobalForward("Shavit_OnFinishMessage", ET_Event, Param_Cell, Param_CellByRef, Param_Array, Param_Cell, Param_Cell, Param_String, Param_Cell);
// player commands
@ -1979,7 +1979,7 @@ public void SQL_CreateTable_Callback(Database db, DBResultSet results, const cha
OnMapStart();
}
public void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs)
public void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp)
{
// do not risk overwriting the player's data if their PB isn't loaded to cache yet
if(!gA_WRCache[client].bLoadedCache)
@ -2034,6 +2034,9 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
Call_PushCell(fOldWR);
Call_PushCell(oldtime);
Call_PushCell(perfs);
Call_PushCell(avgvel);
Call_PushCell(maxvel);
Call_PushCell(timestamp);
Call_Finish();
#if defined DEBUG
@ -2055,6 +2058,9 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
Call_PushCell(track);
Call_PushCell(oldtime);
Call_PushCell(perfs);
Call_PushCell(avgvel);
Call_PushCell(maxvel);
Call_PushCell(timestamp);
Call_Finish();
}
@ -2080,21 +2086,21 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
if(iOverwrite == 1) // insert
{
FormatEx(sMessage, 255, "%s[%s]%s %T",
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "FirstCompletion", LANG_SERVER, gS_ChatStrings.sVariable2, client, gS_ChatStrings.sText, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, gS_ChatStrings.sVariable, iRank, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText);
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "FirstCompletion", LANG_SERVER, gS_ChatStrings.sVariable2, client, gS_ChatStrings.sText, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, gS_ChatStrings.sVariable, iRank, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText, gS_ChatStrings.sVariable, avgvel, maxvel, gS_ChatStrings.sText);
FormatEx(sQuery, 512,
"INSERT INTO %splayertimes (auth, map, time, jumps, date, style, strafes, sync, points, track, perfs) VALUES (%d, '%s', %f, %d, %d, %d, %d, %.2f, 0.0, %d, %.2f);",
gS_MySQLPrefix, iSteamID, gS_Map, time, jumps, GetTime(), style, strafes, sync, track, perfs);
gS_MySQLPrefix, iSteamID, gS_Map, time, jumps, timestamp, style, strafes, sync, track, perfs);
}
else // update
{
FormatEx(sMessage, 255, "%s[%s]%s %T",
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "NotFirstCompletion", LANG_SERVER, gS_ChatStrings.sVariable2, client, gS_ChatStrings.sText, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, gS_ChatStrings.sVariable, iRank, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText, gS_ChatStrings.sWarning, sDifference);
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "NotFirstCompletion", LANG_SERVER, gS_ChatStrings.sVariable2, client, gS_ChatStrings.sText, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, gS_ChatStrings.sVariable, iRank, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText, gS_ChatStrings.sVariable, avgvel, maxvel, gS_ChatStrings.sWarning, sDifference);
FormatEx(sQuery, 512,
"UPDATE %splayertimes SET time = %f, jumps = %d, date = %d, strafes = %d, sync = %.02f, points = 0.0, perfs = %.2f WHERE map = '%s' AND auth = %d AND style = %d AND track = %d;",
gS_MySQLPrefix, time, jumps, GetTime(), strafes, sync, perfs, gS_Map, iSteamID, style, track);
gS_MySQLPrefix, time, jumps, timestamp, strafes, sync, perfs, gS_Map, iSteamID, style, track);
}
gH_SQL.Query(SQL_OnFinish_Callback, sQuery, GetClientSerial(client), DBPrio_High);
@ -2111,6 +2117,9 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
Call_PushCell(track);
Call_PushCell(oldtime);
Call_PushCell(perfs);
Call_PushCell(avgvel);
Call_PushCell(maxvel);
Call_PushCell(timestamp);
Call_Finish();
}
@ -2128,14 +2137,14 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
if(iOverwrite == 0 && !Shavit_GetStyleSettingInt(style, "unranked"))
{
FormatEx(sMessage, 255, "%s[%s]%s %T",
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "WorseTime", client, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText, sDifference);
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "WorseTime", client, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText, gS_ChatStrings.sVariable, avgvel, maxvel, gS_ChatStrings.sText, sDifference);
}
}
else
{
FormatEx(sMessage, 255, "%s[%s]%s %T",
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "UnrankedTime", client, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText);
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "UnrankedTime", client, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText, gS_ChatStrings.sVariable, avgvel, maxvel, gS_ChatStrings.sText);
}
timer_snapshot_t aSnapshot;

View File

@ -28,23 +28,23 @@
// ---------- Completion Messages ---------- //
"FirstCompletion"
{
"#format" "{1:s},{2:N},{3:s},{4:s},{5:s},{6:s},{7:s},{8:s},{9:s},{10:s},{11:d},{12:s},{13:d},{14:d},{15:s},{16:s}"
"en" "{1}{2}{3} finished ({4}{5}{6}) in {7}{8}{9} ({10}#{11}{12}) with {13} jumps, {14} strafes{15}{16}."
"#format" "{1:s},{2:N},{3:s},{4:s},{5:s},{6:s},{7:s},{8:s},{9:s},{10:s},{11:d},{12:s},{13:d},{14:d},{15:s},{16:s},{17:s},{18:.2f},{19:.2f},{20:s}"
"en" "{1}{2}{3} finished ({4}{5}{6}) in {7}{8}{9} ({10}#{11}{12}) with {13} jumps, {14} strafes{15}{16}, Avg/Max Spd {17}{18}/{19}{20}."
}
"NotFirstCompletion"
{
"#format" "{1:s},{2:N},{3:s},{4:s},{5:s},{6:s},{7:s},{8:s},{9:s},{10:s},{11:d},{12:s},{13:d},{14:d},{15:s},{16:s},{17:s},{18:s}"
"en" "{1}{2}{3} finished ({4}{5}{6}) in {7}{8}{9} ({10}#{11}{12}) with {13} jumps, {14} strafes{15}{16}. {17}(-{18})"
"#format" "{1:s},{2:N},{3:s},{4:s},{5:s},{6:s},{7:s},{8:s},{9:s},{10:s},{11:d},{12:s},{13:d},{14:d},{15:s},{16:s},{17:s},{18:.2f},{19:.2f},{20:s},{21:s}"
"en" "{1}{2}{3} finished ({4}{5}{6}) in {7}{8}{9} ({10}#{11}{12}) with {13} jumps, {14} strafes{15}{16}, Avg/Max Spd {17}{18}/{19} {20}(-{21})"
}
"WorseTime"
{
"#format" "{1:s},{2:s},{3:s},{4:s},{5:s},{6:s},{7:d},{8:d},{9:s},{10:s},{11:s}"
"en" "You have finished ({1}{2}{3}) in {4}{5}{6} with {7} jumps, {8} strafes{9}{10}. (+{11})"
"#format" "{1:s},{2:s},{3:s},{4:s},{5:s},{6:s},{7:d},{8:d},{9:s},{10:s},{11:s},{12:.2f},{13:.2f},{14:s},{15:s}"
"en" "You have finished ({1}{2}{3}) in {4}{5}{6} with {7} jumps, {8} strafes{9}{10}, Avg/Max Spd {11}{12}/{13}{14} (+{15})"
}
"UnrankedTime"
{
"#format" "{1:s},{2:s},{3:s},{4:s},{5:s},{6:s},{7:d},{8:d},{9:s},{10:s}"
"en" "You have finished ({1}{2}{3}) in {4}{5}{6} with {7} jumps, {8} strafes{9}{10}."
"#format" "{1:s},{2:s},{3:s},{4:s},{5:s},{6:s},{7:d},{8:d},{9:s},{10:s},{11:s},{12:.2f},{13:.2f},{14:s}"
"en" "You have finished ({1}{2}{3}) in {4}{5}{6} with {7} jumps, {8} strafes{9}{10}, Avg/Max Spd {11}{12}/{13}{14}."
}
// ---------- Deletion Menus ---------- //
"DeleteAllRecords"