Advertisement
Guest User

Game Ui Fix

a guest
Apr 5th, 2015
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools_entoutput>
  3. #include <sdktools_entinput>
  4. #include <sdktools_engine>
  5.  
  6. #pragma semicolon 1
  7.  
  8. new const String:PLUGIN_NAME[] = "Fix game_ui entity";
  9. new const String:PLUGIN_VERSION[] = "1.0";
  10.  
  11. public Plugin:myinfo =
  12. {
  13. name = PLUGIN_NAME,
  14. author = "hlstriker",
  15. description = "Fixes the game_ui entity bug.",
  16. version = PLUGIN_VERSION,
  17. url = "www.swoobles.com"
  18. }
  19.  
  20. new g_iAttachedGameUI[MAXPLAYERS+1];
  21.  
  22.  
  23. public OnPluginStart()
  24. {
  25. CreateConVar("fix_gameui_entity_ver", PLUGIN_VERSION, PLUGIN_NAME, FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_PRINTABLEONLY);
  26.  
  27. HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
  28.  
  29. HookEntityOutput("game_ui", "PlayerOn", GameUI_PlayerOn);
  30. HookEntityOutput("game_ui", "PlayerOff", GameUI_PlayerOff);
  31. }
  32.  
  33. public Action:Event_PlayerDeath(Handle:hEvent, const String:szName[], bool:bDontBroadcast)
  34. {
  35. new iClient = GetClientOfUserId(GetEventInt(hEvent, "userid"));
  36. RemoveFromGameUI(iClient);
  37. SetClientViewEntity(iClient, iClient);
  38.  
  39. new iFlags = GetEntityFlags(iClient);
  40. iFlags &= ~FL_ONTRAIN;
  41. iFlags &= ~FL_FROZEN;
  42. iFlags &= ~FL_ATCONTROLS;
  43. SetEntityFlags(iClient, iFlags);
  44. }
  45.  
  46. public OnClientDisconnect(iClient)
  47. {
  48. RemoveFromGameUI(iClient);
  49. }
  50.  
  51. public GameUI_PlayerOn(const String:szOutput[], iCaller, iActivator, Float:fDelay)
  52. {
  53. if(!(1 <= iActivator <= MaxClients))
  54. return;
  55.  
  56. g_iAttachedGameUI[iActivator] = EntIndexToEntRef(iCaller);
  57. }
  58.  
  59. public GameUI_PlayerOff(const String:szOutput[], iCaller, iActivator, Float:fDelay)
  60. {
  61. if(!(1 <= iActivator <= MaxClients))
  62. return;
  63.  
  64. g_iAttachedGameUI[iActivator] = 0;
  65. }
  66.  
  67. RemoveFromGameUI(iClient)
  68. {
  69. if(!g_iAttachedGameUI[iClient])
  70. return;
  71.  
  72. new iEnt = EntRefToEntIndex(g_iAttachedGameUI[iClient]);
  73. if(iEnt == INVALID_ENT_REFERENCE)
  74. return;
  75.  
  76. AcceptEntityInput(iEnt, "Deactivate");
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement