Fix some bugs

This commit is contained in:
Jackz 2023-12-20 18:09:39 -06:00
parent efaf49bd29
commit fe92123a5b
No known key found for this signature in database
GPG key ID: E0BBD94CF657F603
2 changed files with 12 additions and 16 deletions

Binary file not shown.

View file

@ -12,6 +12,7 @@
//#include <sdkhooks>
#include <profiler>
#include <json>
#include <left4dhooks>
#include <jutils>
#include <entitylump>
@ -52,8 +53,6 @@ public void OnPluginStart() {
RegAdminCmd("sm_rcycle", Command_CycleRandom, ADMFLAG_CHEATS);
RegAdminCmd("sm_expent", Command_ExportEnt, ADMFLAG_GENERIC);
HookEvent("round_start", Event_RoundStart);
cvarEnabled = CreateConVar("sm_randomizer_enabled", "0");
g_MapData.activeScenes = new ArrayList(sizeof(ActiveSceneData));
@ -67,6 +66,11 @@ public void OnMapStart() {
GetCurrentMap(currentMap, sizeof(currentMap));
}
public void OnMapEnd() {
Cleanup();
}
bool hasRan;
public void OnMapInit(const char[] map) {
if(cvarEnabled.BoolValue) {
if(LoadMapData(currentMap, FLAG_NONE) && g_MapData.lumpEdits.Length > 0) {
@ -78,25 +82,17 @@ public void OnMapInit(const char[] map) {
}
}
}
hasRan = false;
}
void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) {
if(cvarEnabled.BoolValue) {
CreateTimer(10.0, Timer_LoadMap);
public void OnClientPutInServer(int client) {
if(!hasRan) {
hasRan = true;
if(cvarEnabled.BoolValue)
RunMap(currentMap, FLAG_NONE);
}
}
Action Timer_LoadMap(Handle h) {
if(cvarEnabled.BoolValue) {
RunMap(currentMap, FLAG_NONE);
}
return Plugin_Handled;
}
public void OnMapEnd() {
Cleanup();
}
stock int GetLookingEntity(int client, TraceEntityFilter filter) {
float pos[3], ang[3];
GetClientEyePosition(client, pos);