diff --git a/addons/sourcemod/gamedata/gokz-core.games.txt b/addons/sourcemod/gamedata/gokz-core.games.txt index a42f7547..517b2b9b 100644 --- a/addons/sourcemod/gamedata/gokz-core.games.txt +++ b/addons/sourcemod/gamedata/gokz-core.games.txt @@ -36,15 +36,15 @@ // applies to trigger_vphysics_motion and trigger_wind "CBaseVPhysicsTrigger::PassesTriggerFilters" { - "windows" "199" - "linux" "200" + "windows" "200" + "linux" "201" } // applies to all other triggers "CBaseTrigger::PassesTriggerFilters" { - "windows" "209" - "linux" "210" + "windows" "210" + "linux" "211" } "IServerGameEnts::MarkEntitiesAsTouching" diff --git a/addons/sourcemod/gamedata/gokz-momsurffix.games.txt b/addons/sourcemod/gamedata/gokz-momsurffix.games.txt index 43f797c4..2d1c968f 100644 --- a/addons/sourcemod/gamedata/gokz-momsurffix.games.txt +++ b/addons/sourcemod/gamedata/gokz-momsurffix.games.txt @@ -35,9 +35,6 @@ "CGameTrace::surface" "60" "CGameTrace::hitgroup" "68" "CGameTrace::physicsbone" "72" - "CGameTrace::m_pEnt" "74" - "CGameTrace::hitbox" "80" - "CGameTrace::size" "84" //CTraceFilterSimple "CTraceFilterSimple::vptr" "0" @@ -80,6 +77,11 @@ //... "CMoveData::m_vecAbsOrigin" "152" + //CGameTrace + "CGameTrace::m_pEnt" "74" + "CGameTrace::hitbox" "80" + "CGameTrace::size" "84" + //CBaseHandle "CBaseHandle::m_Index" "0" @@ -124,12 +126,12 @@ "windows" { "signature" "CGameMovement::TracePlayerBBox" - "read" "83" + "read" "82" } "linux" { "signature" "CGameMovement::TracePlayerBBox" - "read" "579" + "read" "598" } } @@ -285,6 +287,11 @@ //... "CMoveData::m_vecAbsOrigin" "172" + //CGameTrace + "CGameTrace::m_pEnt" "76" + "CGameTrace::hitbox" "82" + "CGameTrace::size" "86" + //CBasePlayer //Offset is relative to m_ubEFNoInterpParity netprop and will be substracted from it "CBasePlayer::m_surfaceFriction" "8" @@ -313,7 +320,7 @@ "linux" { "signature" "g_pMemAllocFunc" - "read" "142" + "read" "191" } "read" "0" @@ -329,7 +336,7 @@ "linux" { "signature" "CGameMovement::TryPlayerMove" - "read" "596" + "read" "483" } "read" "0" @@ -342,21 +349,23 @@ { "library" "server" "windows" "\x55\x8B\xEC\x83\xE4\xF0\x83\xEC\x5C" - "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x8C\x00\x00\x00\x8B\x5D\x08\x8B\x7D\x10" + // Look for string CGameMovement::TracePlayerBBox + "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x7C\x8B\x5D\x08\x8B\x7D\x10" } "CGameMovement::TryPlayerMove" { "library" "server" "windows" "\x55\x8B\xEC\x83\xE4\xF8\x81\xEC\x38\x01\x00\x00\xF3\x0F\x10\x35\x2A\x2A\x2A\x2A" - "linux" "\x55\x89\xE5\x57\x56\x31\xF6\x53\x81\xEC\x2A\x2A\x2A\x2A\xC7\x85\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\xC7\x85" + // Look for vtable with CGameMovement__TracePlayerBBox and count 29 entries down. Look for a very long function if that doesn't work + "linux" "\x55\x66\x0F\xEF\xDB\x89\xE5\x57\x56\x53\x81\xEC\x2A\x2A\x2A\x2A\x8B\x7D\x08" } "g_pMemAllocFunc" { "library" "server" "windows" "\x55\x8B\xEC\x56\x8B\xF1\x83\x4E\x30\x04" - "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x6C\x03\x00\x00\x8B\x55\x08" + "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x3C\x01\x00\x00\x8B\x45\x08\x65\x8B\x0D\x14\x00\x00\x00\x89\x4D\xE4\x31\xC9\x89\xC1" } } diff --git a/addons/sourcemod/gamedata/gokz-replays.games.txt b/addons/sourcemod/gamedata/gokz-replays.games.txt index ed559119..7465f702 100644 --- a/addons/sourcemod/gamedata/gokz-replays.games.txt +++ b/addons/sourcemod/gamedata/gokz-replays.games.txt @@ -24,7 +24,7 @@ "CCSGameRules::TeamFull" { "windows" "\x55\x8B\xEC\x56\x8B\xF1\xE8\x2A\x2A\x2A\x2A\x8B\x45\x08\x83\xE8\x01" - "linux" "\x55\x89\xE5\x83\xEC\x18\x89\x5D\xF8\x8B\x5D\x08\x89\x75\xFC\x8B\x75\x0C\x89\x1C\x24\xE8\x2A\x2A\x2A\x2A\x83\xFE\x02" + "linux" "\x55\x89\xE5\x56\x53\x8B\x5D\x08\x8B\x75\x0C\x80\xBB\xAD\x0E\x00\x00\x00" } } } diff --git a/addons/sourcemod/scripting/gokz-core/commands.sp b/addons/sourcemod/scripting/gokz-core/commands.sp index 882040e5..6aba82cd 100644 --- a/addons/sourcemod/scripting/gokz-core/commands.sp +++ b/addons/sourcemod/scripting/gokz-core/commands.sp @@ -219,7 +219,7 @@ public Action CommandSetStartPos(int client, int args) GOKZ_PrintToChat(client, true, "%t", "Set Custom Start Position"); if (GOKZ_GetCoreOption(client, Option_CheckpointSounds) == CheckpointSounds_Enabled) { - EmitSoundToClient(client, GOKZ_SOUND_CHECKPOINT); + GOKZ_EmitSoundToClient(client, GOKZ_SOUND_CHECKPOINT, _, "Set Start Position"); } return Plugin_Handled; diff --git a/addons/sourcemod/scripting/gokz-core/forwards.sp b/addons/sourcemod/scripting/gokz-core/forwards.sp index 1a000d50..efb064fb 100644 --- a/addons/sourcemod/scripting/gokz-core/forwards.sp +++ b/addons/sourcemod/scripting/gokz-core/forwards.sp @@ -38,7 +38,7 @@ static GlobalForward H_OnOptionsMenuCreated; static GlobalForward H_OnOptionsMenuReady; static GlobalForward H_OnCourseRegistered; static GlobalForward H_OnRunInvalidated; - +static GlobalForward H_OnEmitSoundToClient; void CreateGlobalForwards() { @@ -82,6 +82,7 @@ void CreateGlobalForwards() H_OnOptionsMenuReady = new GlobalForward("GOKZ_OnOptionsMenuReady", ET_Ignore, Param_Cell); H_OnCourseRegistered = new GlobalForward("GOKZ_OnCourseRegistered", ET_Ignore, Param_Cell); H_OnRunInvalidated = new GlobalForward("GOKZ_OnRunInvalidated", ET_Ignore, Param_Cell); + H_OnEmitSoundToClient = new GlobalForward("GOKZ_OnEmitSoundToClient", ET_Hook, Param_Cell, Param_String, Param_FloatByRef, Param_String); } void Call_GOKZ_OnOptionsLoaded(int client) @@ -387,4 +388,14 @@ void Call_GOKZ_OnRunInvalidated(int client) Call_StartForward(H_OnRunInvalidated); Call_PushCell(client); Call_Finish(); +} + +void Call_GOKZ_OnEmitSoundToClient(int client, const char[] sample, float &volume, const char[] description, Action &result) +{ + Call_StartForward(H_OnEmitSoundToClient); + Call_PushCell(client); + Call_PushString(sample); + Call_PushFloatRef(volume); + Call_PushString(description); + Call_Finish(result); } \ No newline at end of file diff --git a/addons/sourcemod/scripting/gokz-core/misc.sp b/addons/sourcemod/scripting/gokz-core/misc.sp index 7e88edad..47e68c0f 100644 --- a/addons/sourcemod/scripting/gokz-core/misc.sp +++ b/addons/sourcemod/scripting/gokz-core/misc.sp @@ -243,7 +243,7 @@ void PlayErrorSound(int client) { if (GOKZ_GetCoreOption(client, Option_ErrorSounds) == ErrorSounds_Enabled) { - EmitSoundToClient(client, SOUND_ERROR); + GOKZ_EmitSoundToClient(client, SOUND_ERROR, _, "Error"); } } diff --git a/addons/sourcemod/scripting/gokz-core/natives.sp b/addons/sourcemod/scripting/gokz-core/natives.sp index 19c2cefe..319810c6 100644 --- a/addons/sourcemod/scripting/gokz-core/natives.sp +++ b/addons/sourcemod/scripting/gokz-core/natives.sp @@ -72,6 +72,8 @@ void CreateNatives() CreateNative("GOKZ_SetTakeoffSpeed", Native_SetTakeoffSpeed); CreateNative("GOKZ_GetValidJump", Native_GetValidJump); CreateNative("GOKZ_JoinTeam", Native_JoinTeam); + + CreateNative("GOKZ_EmitSoundToClient", Native_EmitSoundToClient); } public int Native_GetModeLoaded(Handle plugin, int numParams) @@ -599,7 +601,34 @@ public int Native_JoinTeam(Handle plugin, int numParams) return 0; } +public int Native_EmitSoundToClient(Handle plugin, int numParams) +{ + int client = GetNativeCell(1); + + char sample[PLATFORM_MAX_PATH]; + GetNativeString(2, sample, sizeof(sample)); + + float volume = GetNativeCell(3); + float newVolume = volume; + + char description[64]; + GetNativeString(4, description, sizeof(description)); + Action result; + + Call_GOKZ_OnEmitSoundToClient(client, sample, newVolume, description, result); + if (result == Plugin_Stop) + { + return 0; + } + if (result == Plugin_Changed) + { + EmitSoundToClient(client, sample, _, _, _, _, newVolume); + return 0; + } + EmitSoundToClient(client, sample, _, _, _, _, volume); + return 0; +} // =====[ PRIVATE ]===== diff --git a/addons/sourcemod/scripting/gokz-core/teleports.sp b/addons/sourcemod/scripting/gokz-core/teleports.sp index d8c07b57..36b3479d 100644 --- a/addons/sourcemod/scripting/gokz-core/teleports.sp +++ b/addons/sourcemod/scripting/gokz-core/teleports.sp @@ -108,7 +108,7 @@ void MakeCheckpoint(int client) if (GOKZ_GetCoreOption(client, Option_CheckpointSounds) == CheckpointSounds_Enabled) { - EmitSoundToClient(client, GOKZ_SOUND_CHECKPOINT); + GOKZ_EmitSoundToClient(client, GOKZ_SOUND_CHECKPOINT, _, "Checkpoint"); } if (GOKZ_GetCoreOption(client, Option_CheckpointMessages) == CheckpointMessages_Enabled) { @@ -879,7 +879,7 @@ static void TeleportDo(int client, const float destOrigin[3], const float destAn undoTeleportData[client].Update(); if (GOKZ_GetCoreOption(client, Option_TeleportSounds) == TeleportSounds_Enabled) { - EmitSoundToClient(client, GOKZ_SOUND_TELEPORT); + GOKZ_EmitSoundToClient(client, GOKZ_SOUND_TELEPORT, _, "Teleport"); } // Call Post Foward diff --git a/addons/sourcemod/scripting/gokz-core/timer/timer.sp b/addons/sourcemod/scripting/gokz-core/timer/timer.sp index 0427258b..f6696ac6 100644 --- a/addons/sourcemod/scripting/gokz-core/timer/timer.sp +++ b/addons/sourcemod/scripting/gokz-core/timer/timer.sp @@ -179,8 +179,8 @@ void PlayTimerStartSound(int client) { if (GetGameTime() - lastStartSoundTime[client] > GOKZ_TIMER_SOUND_COOLDOWN) { - EmitSoundToClient(client, gC_ModeStartSounds[GOKZ_GetCoreOption(client, Option_Mode)]); - EmitSoundToClientSpectators(client, gC_ModeStartSounds[GOKZ_GetCoreOption(client, Option_Mode)]); + GOKZ_EmitSoundToClient(client, gC_ModeStartSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer Start"); + GOKZ_EmitSoundToClientSpectators(client, gC_ModeStartSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer Start"); lastStartSoundTime[client] = GetGameTime(); } } @@ -301,8 +301,8 @@ static bool JustEndedTimer(int client) static void PlayTimerEndSound(int client) { - EmitSoundToClient(client, gC_ModeEndSounds[GOKZ_GetCoreOption(client, Option_Mode)]); - EmitSoundToClientSpectators(client, gC_ModeEndSounds[GOKZ_GetCoreOption(client, Option_Mode)]); + GOKZ_EmitSoundToClient(client, gC_ModeEndSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer End"); + GOKZ_EmitSoundToClientSpectators(client, gC_ModeEndSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer End"); } static void PlayTimerFalseEndSound(int client) @@ -310,15 +310,15 @@ static void PlayTimerFalseEndSound(int client) if (!JustEndedTimer(client) && (GetGameTime() - lastFalseEndTime[client]) > GOKZ_TIMER_SOUND_COOLDOWN) { - EmitSoundToClient(client, gC_ModeFalseEndSounds[GOKZ_GetCoreOption(client, Option_Mode)]); - EmitSoundToClientSpectators(client, gC_ModeFalseEndSounds[GOKZ_GetCoreOption(client, Option_Mode)]); + GOKZ_EmitSoundToClient(client, gC_ModeFalseEndSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer False End"); + GOKZ_EmitSoundToClientSpectators(client, gC_ModeFalseEndSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer False End"); } } static void PlayTimerStopSound(int client) { - EmitSoundToClient(client, GOKZ_SOUND_TIMER_STOP); - EmitSoundToClientSpectators(client, GOKZ_SOUND_TIMER_STOP); + GOKZ_EmitSoundToClient(client, GOKZ_SOUND_TIMER_STOP, _, "Timer Stop"); + GOKZ_EmitSoundToClientSpectators(client, GOKZ_SOUND_TIMER_STOP, _, "Timer Stop"); } static void PrintEndTimeString(int client) diff --git a/addons/sourcemod/scripting/gokz-global.sp b/addons/sourcemod/scripting/gokz-global.sp index 0c18840b..79f8b6ab 100644 --- a/addons/sourcemod/scripting/gokz-global.sp +++ b/addons/sourcemod/scripting/gokz-global.sp @@ -206,7 +206,7 @@ public void FPSCheck(QueryCookie cookie, int client, ConVarQueryResult result, c } else { - EmitSoundToClient(client, GOKZ_SOUND_TIMER_STOP); + GOKZ_EmitSoundToClient(client, GOKZ_SOUND_TIMER_STOP, _, "Timer Stop"); } } } @@ -524,7 +524,7 @@ void AnnounceNewTopTime(int client, int course, int mode, int timeType, int rank void PlayBeatRecordSound() { - EmitSoundToAll(GL_SOUND_NEW_RECORD); + GOKZ_EmitSoundToAll(GL_SOUND_NEW_RECORD, _, "World Record"); } diff --git a/addons/sourcemod/scripting/gokz-hud/racing_text.sp b/addons/sourcemod/scripting/gokz-hud/racing_text.sp index e6f7477b..ac6ea3d3 100644 --- a/addons/sourcemod/scripting/gokz-hud/racing_text.sp +++ b/addons/sourcemod/scripting/gokz-hud/racing_text.sp @@ -123,7 +123,7 @@ static void ShowCountdownText(KZPlayer player, KZPlayer targetPlayer) int colour[4]; GetCountdownColour(timeToStart, colour); - SetHudTextParams(-1.0, 0.3, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); + SetHudTextParams(-1.0, 0.3, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); ShowSyncHudText(player.ID, racingHudSynchronizer, "%t\n\n%d", "Get Ready", IntMax(RoundToCeil(timeToStart), 1)); } @@ -162,6 +162,6 @@ static void ShowStartedText(KZPlayer player, KZPlayer targetPlayer) return; } - SetHudTextParams(-1.0, 0.3, 1.0, 0, 255, 0, 255, 0, 1.0, 0.0, 0.0); + SetHudTextParams(-1.0, 0.3, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), 0, 255, 0, 255, 0, 1.0, 0.0, 0.0); ShowSyncHudText(player.ID, racingHudSynchronizer, "%t", "Go!"); } \ No newline at end of file diff --git a/addons/sourcemod/scripting/gokz-hud/speed_text.sp b/addons/sourcemod/scripting/gokz-hud/speed_text.sp index e4b30ccf..3f83949b 100644 --- a/addons/sourcemod/scripting/gokz-hud/speed_text.sp +++ b/addons/sourcemod/scripting/gokz-hud/speed_text.sp @@ -98,11 +98,11 @@ static void ShowSpeedText(KZPlayer player, HUDInfo info) // Set params based on the available screen space at max scaling HUD if (!IsDrawingInfoPanel(player.ID)) { - SetHudTextParams(-1.0, 0.75, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); + SetHudTextParams(-1.0, 0.75, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); } else { - SetHudTextParams(-1.0, 0.65, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); + SetHudTextParams(-1.0, 0.65, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); } } } diff --git a/addons/sourcemod/scripting/gokz-hud/timer_text.sp b/addons/sourcemod/scripting/gokz-hud/timer_text.sp index 292b6bec..a59901ad 100644 --- a/addons/sourcemod/scripting/gokz-hud/timer_text.sp +++ b/addons/sourcemod/scripting/gokz-hud/timer_text.sp @@ -154,11 +154,11 @@ static void ShowTimerText(KZPlayer player, HUDInfo info) { case TimerText_Top: { - SetHudTextParams(-1.0, 0.07, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); + SetHudTextParams(-1.0, 0.07, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); } case TimerText_Bottom: { - SetHudTextParams(-1.0, 0.9, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); + SetHudTextParams(-1.0, 0.9, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0); } } diff --git a/addons/sourcemod/scripting/gokz-jumpstats/jump_reporting.sp b/addons/sourcemod/scripting/gokz-jumpstats/jump_reporting.sp index 4e1c5282..31a1bb2f 100644 --- a/addons/sourcemod/scripting/gokz-jumpstats/jump_reporting.sp +++ b/addons/sourcemod/scripting/gokz-jumpstats/jump_reporting.sp @@ -16,7 +16,7 @@ void PlayJumpstatSound(int client, int tier) return; } - EmitSoundToClient(client, sounds[tier]); + GOKZ_EmitSoundToClient(client, sounds[tier], _, "Jumpstats"); } diff --git a/addons/sourcemod/scripting/gokz-localranks/misc.sp b/addons/sourcemod/scripting/gokz-localranks/misc.sp index 19826f74..0c6d96cc 100644 --- a/addons/sourcemod/scripting/gokz-localranks/misc.sp +++ b/addons/sourcemod/scripting/gokz-localranks/misc.sp @@ -55,7 +55,7 @@ static bool LoadSounds() static void PlayBeatRecordSound() { - EmitSoundToAll(gC_BeatRecordSound); + GOKZ_EmitSoundToAll(gC_BeatRecordSound, _, "Server Record"); } void AnnounceNewTime( @@ -315,5 +315,5 @@ void DoPBMissedReport(int client, float pbTime, int recordType) case RecordType_Pro:GOKZ_PrintToChat(client, true, "%t", "Missed PB (PRO)", GOKZ_FormatTime(pbTime)); case RecordType_NubAndPro:GOKZ_PrintToChat(client, true, "%t", "Missed PB (NUB and PRO)", GOKZ_FormatTime(pbTime)); } - EmitSoundToClient(client, MISSED_PB_SOUND); + GOKZ_EmitSoundToClient(client, MISSED_PB_SOUND, _, "Missed PB"); } \ No newline at end of file diff --git a/addons/sourcemod/scripting/gokz-replays/playback.sp b/addons/sourcemod/scripting/gokz-replays/playback.sp index b0b9c203..16ed9d05 100644 --- a/addons/sourcemod/scripting/gokz-replays/playback.sp +++ b/addons/sourcemod/scripting/gokz-replays/playback.sp @@ -730,7 +730,7 @@ static void PlaybackVersion1(int client, int bot, int &buttons) breatherStartTime[bot] = GetEngineTime(); if (playbackTick[bot] == (size - 1)) { - EmitSoundToClientSpectators(client, gC_ModeEndSounds[GOKZ_GetCoreOption(client, Option_Mode)]); + GOKZ_EmitSoundToClientSpectators(client, gC_ModeEndSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer End"); } } else if (GetEngineTime() > breatherStartTime[bot] + RP_PLAYBACK_BREATHER_TIME) @@ -740,7 +740,7 @@ static void PlaybackVersion1(int client, int bot, int &buttons) botPlaybackPaused[bot] = false; if (playbackTick[bot] == 0) { - EmitSoundToClientSpectators(client, gC_ModeStartSounds[GOKZ_GetCoreOption(client, Option_Mode)]); + GOKZ_EmitSoundToClientSpectators(client, gC_ModeStartSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer Start"); } // Start the bot if first tick. Clear bot if last tick. playbackTick[bot]++; @@ -953,12 +953,12 @@ void PlaybackVersion2(int client, int bot, int &buttons) // Play timer start/end sound, if necessary. Reset teleports if (playbackTick[bot] == preAndPostRunTickCount && botReplayType[bot] == ReplayType_Run) { - EmitSoundToClientSpectators(client, gC_ModeStartSounds[GOKZ_GetCoreOption(client, Option_Mode)]); + GOKZ_EmitSoundToClientSpectators(client, gC_ModeStartSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer Start"); botCurrentTeleport[bot] = 0; } if (playbackTick[bot] == botTimeTicks[bot] + preAndPostRunTickCount && botReplayType[bot] == ReplayType_Run) { - EmitSoundToClientSpectators(client, gC_ModeEndSounds[GOKZ_GetCoreOption(client, Option_Mode)]); + GOKZ_EmitSoundToClientSpectators(client, gC_ModeEndSounds[GOKZ_GetCoreOption(client, Option_Mode)], _, "Timer End"); } // Set velocity to travel from current origin to recorded origin diff --git a/addons/sourcemod/scripting/include/gokz.inc b/addons/sourcemod/scripting/include/gokz.inc index dbd6d9c8..96e85c18 100644 --- a/addons/sourcemod/scripting/include/gokz.inc +++ b/addons/sourcemod/scripting/include/gokz.inc @@ -1019,3 +1019,19 @@ stock int GOKZGetClientFromGameMovementAddress(Address addr, int offsetCGameMove Address playerAddr = view_as
(LoadFromAddress(view_as
(view_as(addr) + offsetCGameMovement_player), NumberType_Int32)); return GOKZGetEntityFromAddress(playerAddr); } + +/** + * Gets the ideal amount of time the text should be held for HUD messages. + * + * The message buffer is only 16 slots long, and it is shared between 6 channels maximum. + * Assuming a message is sent every game frame, each channel used should be only taking around 2.5 slots on average. + * This also assumes all channels are used equally (so no other plugin taking all the channel buffer for itself). + * We want to use as much of the message buffer as possible to take into account latency variances. + * + * @param interval HUD message update interval, in tick intervals. + * @return How long the text should be held for. + */ +stock float GetTextHoldTime(int interval) +{ + return 3 * interval * GetTickInterval(); +} \ No newline at end of file diff --git a/addons/sourcemod/scripting/include/gokz/core.inc b/addons/sourcemod/scripting/include/gokz/core.inc index 6010cca6..c21678c6 100644 --- a/addons/sourcemod/scripting/include/gokz/core.inc +++ b/addons/sourcemod/scripting/include/gokz/core.inc @@ -869,6 +869,18 @@ forward void GOKZ_OnCourseRegistered(int course); */ forward void GOKZ_OnRunInvalidated(int client); +/** + * Called when a sound is emitted to the client via GOKZ Core. + * + * @param client Client index. + * @param sample Sound file name relative to the "sound" folder. + * @param volume Sound volume. + * @param description Optional description. + * @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it, + * Plugin_Changed when any parameter has been modified. + */ +forward Action GOKZ_OnEmitSoundToClient(int client, const char[] sample, float &volume, const char[] description); + // =====[ NATIVES ]===== @@ -1481,6 +1493,16 @@ native bool GOKZ_GetValidJump(int client); */ native void GOKZ_JoinTeam(int client, int team, bool restorePos = true, bool forceBroadcast = false); +/** + * Emit a sound to a player via GOKZ Core. + * Sounds emitted by this native will call GOKZ_OnEmitSoundToClient forward. + * + * @param client Client index. + * @param sample Sound file name relative to the "sound" folder. + * @param volume Sound volume. + * @param description Optional description. + */ +native void GOKZ_EmitSoundToClient(int client, const char[] sample, float volume = SNDVOL_NORMAL, const char[] description = ""); // =====[ STOCKS ]===== @@ -1752,7 +1774,44 @@ stock int GOKZ_MatchIntFromEntityName(int entity, Regex re, int substringID) return num; } +/** + * Emits a sound to other players that are spectating the client. + * Sounds emitted by this function will call GOKZ_OnEmitSoundToClient forward. + * + * @param sample Sound file name relative to the "sound" folder. + * @param volume Sound volume. + * @param description Optional description. + */ +stock void GOKZ_EmitSoundToAll(const char[] sample, float volume = SNDVOL_NORMAL, const char[] description = "") +{ + for (int client = 1; client <= MaxClients; client++) + { + if (IsClientInGame(client)) + { + GOKZ_EmitSoundToClient(client, sample, volume, description); + } + } +} +/** + * Emits a sound to other players that are spectating the client. + * Sounds emitted by this function will call GOKZ_OnEmitSoundToClient forward. + * + * @param client Client being spectated. + * @param sample Sound file name relative to the "sound" folder. + * @param volume Sound volume. + * @param description Optional description. + */ +stock void GOKZ_EmitSoundToClientSpectators(int client, const char[] sample, float volume = SNDVOL_NORMAL, const char[] description = "") +{ + for (int i = 1; i <= MaxClients; i++) + { + if (IsValidClient(i) && GetObserverTarget(i) == client) + { + GOKZ_EmitSoundToClient(i, sample, volume); + } + } +} // =====[ DEPENDENCY ]===== @@ -1838,5 +1897,6 @@ public void __pl_gokz_core_SetNTVOptional() MarkNativeAsOptional("GOKZ_SetTakeoffSpeed"); MarkNativeAsOptional("GOKZ_GetValidJump"); MarkNativeAsOptional("GOKZ_JoinTeam"); + MarkNativeAsOptional("GOKZ_EmitSoundToClient"); } #endif \ No newline at end of file