• How to fix the bug in the "game_ui" entity?
    3 replies, posted
So I recently posted in the mapping section about this, but I feel that a fix may belong in the developer section. Anyways, there's a bug in the [I]game_ui[/I] hammer entity. When the player is killed, it doesn't remove the player from controlling the[I] game_ui[/I] and doesn't allow the player to properly spectate and let others use the [I]game_ui[/I]. Courtesy of the mapping question megathread I've gotten around this by using a trigger volume to check if the player controlling it is still there and alive, and if not, it deactivates the [I]game_ui[/I]. That's all working well, but then again it's a workaround, not a fix. However, when the player is killed while using the [I]game_ui[/I], it still doesn't allow the player to properly spectate. The spectate camera is stuck in one place and a red error begins spamming uncontrollably in the console: "[B]mod_studio: MOVETYPE_FOLLOW with no model.[/B]" I did manage to find a sourcemod plugin that fixes the [I]game_ui[/I] entity here: [url]https://forums.alliedmods.net/showthread.php?p=2089129[/url] Is there any way to convert what the plugin does into Lua to fix the [I]game_ui[/I] in my map? I'm afraid I'm too inexperienced to create such an extensive Lua script myself, but it would be doing the community a huge favor to have the [I]game_ui[/I] fixed, perhaps even through a [I]lua_run[/I] entity that could be added into the map and executed on map spawn. Here is the source of the plugin: [CODE]#include <sourcemod>#include <sdktools_entoutput> #include <sdktools_entinput> #include <sdktools_engine> #pragma semicolon 1 new const String:PLUGIN_NAME[] = "Fix game_ui entity"; new const String:PLUGIN_VERSION[] = "1.0"; public Plugin:myinfo = { name = PLUGIN_NAME, author = "hlstriker", description = "Fixes the game_ui entity bug.", version = PLUGIN_VERSION, url = "www.swoobles.com" } new g_iAttachedGameUI[MAXPLAYERS+1]; public OnPluginStart() { CreateConVar("fix_gameui_entity_ver", PLUGIN_VERSION, PLUGIN_NAME, FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_PRINTABLEONLY); HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post); HookEntityOutput("game_ui", "PlayerOn", GameUI_PlayerOn); HookEntityOutput("game_ui", "PlayerOff", GameUI_PlayerOff); } public Action:Event_PlayerDeath(Handle:hEvent, const String:szName[], bool:bDontBroadcast) { new iClient = GetClientOfUserId(GetEventInt(hEvent, "userid")); RemoveFromGameUI(iClient); SetClientViewEntity(iClient, iClient); new iFlags = GetEntityFlags(iClient); iFlags &= ~FL_ONTRAIN; iFlags &= ~FL_FROZEN; iFlags &= ~FL_ATCONTROLS; SetEntityFlags(iClient, iFlags); } public OnClientDisconnect(iClient) { RemoveFromGameUI(iClient); } public GameUI_PlayerOn(const String:szOutput[], iCaller, iActivator, Float:fDelay) { if(!(1 <= iActivator <= MaxClients)) return; g_iAttachedGameUI[iActivator] = EntIndexToEntRef(iCaller); } public GameUI_PlayerOff(const String:szOutput[], iCaller, iActivator, Float:fDelay) { if(!(1 <= iActivator <= MaxClients)) return; g_iAttachedGameUI[iActivator] = 0; } RemoveFromGameUI(iClient) { if(!g_iAttachedGameUI[iClient]) return; new iEnt = EntRefToEntIndex(g_iAttachedGameUI[iClient]); if(iEnt == INVALID_ENT_REFERENCE) return; AcceptEntityInput(iEnt, "Deactivate", iClient, iEnt); }[/CODE]
Maybe you should report it @ [url]https://github.com/Facepunch/garrysmod-issues[/url] ?
[QUOTE=Robotboy655;44749445]Maybe you should report it @ [URL]https://github.com/Facepunch/garrysmod-issues[/URL] ?[/QUOTE] Thanks, I just filed a report. Regardless, does anyone here know a proper workaround to fix this issue? I can't say I know how long it takes for a reported issue to be fixed, or to even be fixed at all.
Bumping this with a solution; As soon as the player takes control, change it's targetname to controller1 or something similar. Add a func_brush called "game_playerdie" which does an OnUse (which is triggered when a player dies) towards a filter_activator_name with filtername controller1 and have it perform a TestActivator. If the TestActivator passes, that means the player that triggered it (by dying) is in fact the controller of the game_ui. On pass, deactivate the game_ui and related entities to properly clean it up. (More on func_brush and game_playerdie as they are hidden entities: [url]http://forums.tf2maps.net/showthread.php?t=10155[/url])
Sorry, you need to Log In to post a reply to this thread.