mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Add Timer_GetStatus() and move things around
This commit is contained in:
parent
2b24012652
commit
6daa5953ca
@ -117,17 +117,11 @@ int gI_Offset_m_afButtonDisabled = 0;
|
||||
int gI_Offset_m_afButtonForced = 0;
|
||||
|
||||
// vscript!!! you're going to break all my checkpoints!!!
|
||||
#if 0
|
||||
VScriptExecute gH_VScript_OnStart;
|
||||
VScriptExecute gH_VScript_OnEnd;
|
||||
#endif
|
||||
VScriptExecute gH_VScript_Timer_OnCheckpointSave;
|
||||
VScriptExecute gH_VScript_Timer_OnCheckpointLoadPre;
|
||||
VScriptExecute gH_VScript_Timer_OnCheckpointLoadPost;
|
||||
VScriptFunction gH_VScript_Timer_SetCheckpointCustomData;
|
||||
VScriptFunction gH_VScript_Timer_GetCheckpointCustomData;
|
||||
VScriptFunction gH_VScript_Timer_GetTime;
|
||||
|
||||
enum VScript_Checkpoint_State
|
||||
{
|
||||
VCS_NO_TOUCH = 0,
|
||||
@ -137,6 +131,7 @@ enum VScript_Checkpoint_State
|
||||
VScript_Checkpoint_State gI_VScript_Checkpointing[MAXPLAYERS+1];
|
||||
StringMap gH_VScript_Checkpoint_CustomData[MAXPLAYERS+1];
|
||||
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "[shavit] Checkpoints",
|
||||
@ -2289,19 +2284,6 @@ public any Native_SaveCheckpointCache(Handle plugin, int numParams)
|
||||
|
||||
public void VScript_OnScriptVMInitialized()
|
||||
{
|
||||
#if 0
|
||||
// ::Timer_OnStart <- function(player)
|
||||
if (VScript_GetGlobalFunction("Timer_OnStart"))
|
||||
gH_VScript_OnStart = new VScriptExecute(HSCRIPT_RootTable.GetValue("Timer_OnStart"));
|
||||
else
|
||||
gH_VScript_OnStart = view_as<VScriptExecute>(Address_Null);
|
||||
// ::Timer_OnEnd <- function(player)
|
||||
if (VScript_GetGlobalFunction("Timer_OnEnd"))
|
||||
gH_VScript_OnEnd = new VScriptExecute(HSCRIPT_RootTable.GetValue("Timer_OnEnd"));
|
||||
else
|
||||
gH_VScript_OnEnd = view_as<VScriptExecute>(Address_Null);
|
||||
#endif
|
||||
|
||||
// ::Timer_OnCheckpointSave <- function(player)
|
||||
if (VScript_GetGlobalFunction("Timer_OnCheckpointSave"))
|
||||
gH_VScript_Timer_OnCheckpointSave = new VScriptExecute(HSCRIPT_RootTable.GetValue("Timer_OnCheckpointSave"));
|
||||
@ -2340,15 +2322,6 @@ public void VScript_OnScriptVMInitialized()
|
||||
gH_VScript_Timer_GetCheckpointCustomData.SetFunctionEmpty();
|
||||
gH_VScript_Timer_GetCheckpointCustomData.Register();
|
||||
gH_VScript_Timer_GetCheckpointCustomData.CreateDetour().Enable(Hook_Pre, Detour_Timer_GetCheckpointCustomData);
|
||||
|
||||
// function Timer_GetTime(player) // returns a float
|
||||
gH_VScript_Timer_GetTime = VScript_CreateFunction();
|
||||
gH_VScript_Timer_GetTime.SetScriptName("Timer_GetTime");
|
||||
gH_VScript_Timer_GetTime.Return = FIELD_FLOAT;
|
||||
gH_VScript_Timer_GetTime.SetParam(1, FIELD_HSCRIPT);
|
||||
gH_VScript_Timer_GetTime.SetFunctionEmpty();
|
||||
gH_VScript_Timer_GetTime.Register();
|
||||
gH_VScript_Timer_GetTime.CreateDetour().Enable(Hook_Pre, Detour_Timer_GetTime);
|
||||
}
|
||||
|
||||
MRESReturn Detour_Timer_SetCheckpointCustomData(DHookParam params)
|
||||
@ -2420,18 +2393,3 @@ void Do_Timer_OnCheckpointLoadPost(int client, StringMap customdata)
|
||||
gI_VScript_Checkpointing[client] = VCS_NO_TOUCH;
|
||||
}
|
||||
}
|
||||
|
||||
MRESReturn Detour_Timer_GetTime(DHookReturn hret, DHookParam params)
|
||||
{
|
||||
int client = VScript_HScriptToEntity(params.Get(1));
|
||||
|
||||
if (client < 1 || client > MaxClients || !IsClientInGame(client))
|
||||
{
|
||||
// Log error or something...
|
||||
return MRES_Supercede;
|
||||
}
|
||||
|
||||
hret.Value = Shavit_GetClientTime(client);
|
||||
|
||||
return MRES_Supercede;
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include <shavit/wr>
|
||||
#include <shavit/zones>
|
||||
#include <eventqueuefix>
|
||||
#include <vscript>
|
||||
|
||||
#include <shavit/chat-colors>
|
||||
#include <shavit/anti-sv_cheats.sp>
|
||||
@ -60,6 +61,15 @@ DynamicHook gH_AcceptInput; // used for hooking player_speedmod's AcceptInput
|
||||
DynamicHook gH_TeleportDhook = null;
|
||||
Address gI_TF2PreventBunnyJumpingAddr = Address_Null;
|
||||
|
||||
// vscript (non-checkpoint natives)
|
||||
#if 0
|
||||
VScriptExecute gH_VScript_OnStart;
|
||||
VScriptExecute gH_VScript_OnEnd;
|
||||
#endif
|
||||
VScriptFunction gH_VScript_Timer_GetTime;
|
||||
VScriptFunction gH_VScript_Timer_GetStatus;
|
||||
|
||||
|
||||
// database handle
|
||||
Database gH_SQL = null;
|
||||
int gI_Driver = Driver_unknown;
|
||||
@ -3882,3 +3892,67 @@ void UpdateStyleSettings(int client)
|
||||
UpdateAiraccelerate(client, GetStyleSettingFloat(gA_Timers[client].bsStyle, "airaccelerate"));
|
||||
}
|
||||
}
|
||||
|
||||
public void VScript_OnScriptVMInitialized()
|
||||
{
|
||||
#if 0
|
||||
// ::Timer_OnStart <- function(player)
|
||||
if (VScript_GetGlobalFunction("Timer_OnStart"))
|
||||
gH_VScript_OnStart = new VScriptExecute(HSCRIPT_RootTable.GetValue("Timer_OnStart"));
|
||||
else
|
||||
gH_VScript_OnStart = view_as<VScriptExecute>(Address_Null);
|
||||
// ::Timer_OnEnd <- function(player)
|
||||
if (VScript_GetGlobalFunction("Timer_OnEnd"))
|
||||
gH_VScript_OnEnd = new VScriptExecute(HSCRIPT_RootTable.GetValue("Timer_OnEnd"));
|
||||
else
|
||||
gH_VScript_OnEnd = view_as<VScriptExecute>(Address_Null);
|
||||
#endif
|
||||
|
||||
// function Timer_GetTime(player) // returns a float
|
||||
gH_VScript_Timer_GetTime = VScript_CreateFunction();
|
||||
gH_VScript_Timer_GetTime.SetScriptName("Timer_GetTime");
|
||||
gH_VScript_Timer_GetTime.Return = FIELD_FLOAT;
|
||||
gH_VScript_Timer_GetTime.SetParam(1, FIELD_HSCRIPT);
|
||||
gH_VScript_Timer_GetTime.SetFunctionEmpty();
|
||||
gH_VScript_Timer_GetTime.Register();
|
||||
gH_VScript_Timer_GetTime.CreateDetour().Enable(Hook_Pre, Detour_Timer_GetTime);
|
||||
|
||||
// function gH_VScript_Timer_GetStatus(player) // returns a int -- 0=stopped, 1=running, 2=paused
|
||||
gH_VScript_Timer_GetStatus = VScript_CreateFunction();
|
||||
gH_VScript_Timer_GetStatus.SetScriptName("Timer_GetStatus");
|
||||
gH_VScript_Timer_GetStatus.Return = FIELD_INTEGER;
|
||||
gH_VScript_Timer_GetStatus.SetParam(1, FIELD_HSCRIPT);
|
||||
gH_VScript_Timer_GetStatus.SetFunctionEmpty();
|
||||
gH_VScript_Timer_GetStatus.Register();
|
||||
gH_VScript_Timer_GetStatus.CreateDetour().Enable(Hook_Pre, Detour_Timer_GetStatus);
|
||||
}
|
||||
|
||||
MRESReturn Detour_Timer_GetTime(DHookReturn hret, DHookParam params)
|
||||
{
|
||||
int client = VScript_HScriptToEntity(params.Get(1));
|
||||
|
||||
if (client < 1 || client > MaxClients || !IsClientInGame(client))
|
||||
{
|
||||
// Log error or something...
|
||||
return MRES_Supercede;
|
||||
}
|
||||
|
||||
hret.Value = Shavit_GetClientTime(client);
|
||||
|
||||
return MRES_Supercede;
|
||||
}
|
||||
|
||||
MRESReturn Detour_Timer_GetStatus(DHookReturn hret, DHookParam params)
|
||||
{
|
||||
int client = VScript_HScriptToEntity(params.Get(1));
|
||||
|
||||
if (client < 1 || client > MaxClients || !IsClientInGame(client))
|
||||
{
|
||||
// Log error or something...
|
||||
return MRES_Supercede;
|
||||
}
|
||||
|
||||
hret.Value = view_as<int>(GetTimerStatus(client));
|
||||
|
||||
return MRES_Supercede;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user