HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /** Description::
  2. * Forces the player into a random team as soon as he connects.
  3. * (Client will miss the motd windowso the first screen he will see is the
  4. * "Choose model" menu.
  5. */
  6. /* Console Variables::
  7. sm_autojoin_enabled (Default 1) Turn on/off plugin.
  8. sm_autojoin_adminsimmune (Default 0) Turn on/off Admin immunity (Admins can choose team)
  9. ------------ Waiting to be added ------------
  10. */
  11. /* Todo::
  12. */
  13.  
  14. #include <sourcemod>
  15. #define PLUGIN_VERSION "1.1.0.0"
  16. new Handle:enabled = INVALID_HANDLE;
  17. new Handle:admin_immun = INVALID_HANDLE;
  18.  
  19. public Plugin:myinfo =
  20. {
  21. name = "Autojoin",
  22. author = "Lindgren",
  23. description = "Force player into a team as soon as they connect.",
  24. version = PLUGIN_VERSION,
  25. url = "http://www.swestrike.com"
  26. }
  27.  
  28. public OnPluginStart()
  29. {
  30. CreateConVar("sm_autojoin_version", PLUGIN_VERSION, "Current Version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  31. enabled = CreateConVar("sm_autojoin_enabled", "1", "Enable/Disable plugin");
  32. admin_immun = CreateConVar("sm_autojoin_adminsimmune", "0", "Admin immunity On/Off", 0, true, 0.0, true, 1.0);
  33. }
  34.  
  35. public OnClientPutInServer(client)
  36. {
  37. // if (GetUserAdmin (i) != INVALID_ADMIN_ID)
  38. if (GetConVarInt(admin_immun) == 1)
  39. {
  40. if ((GetConVarInt(enabled) == 1) && (!IsFakeClient(client) && (GetUserAdmin(client) == INVALID_ADMIN_ID)))
  41. CreateTimer(0.1, Timer_1, any:client)
  42. }
  43. else
  44. {
  45. if ((GetConVarInt(enabled) == 1) && (!IsFakeClient(client)))
  46. CreateTimer(0.1, Timer_1, any:client)
  47. }
  48. }
  49.  
  50. public Action:Timer_1(Handle:timer, any:client)
  51. {
  52. FakeClientCommand(client,"joingame");
  53. CreateTimer(1.0, Timer_2, any:client)
  54. }
  55.  
  56. public Action:Timer_2(Handle:timer, any:client)
  57. {
  58. ChangeClientTeam(client, 1) // Moves player back to spectator to skip the double-choice-bug
  59. }