HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <sourcemod>
  2.  
  3. #define VERSION "1.1"
  4.  
  5. public Plugin:myinfo =
  6. {
  7. name = "Terms Agreement",
  8. author = "MaTTe",
  9. description = "A jatekosnak el kell fogadni a szabalyzatot, kulonben ki lesz rugva!",
  10. version = VERSION,
  11. url = "http://www.sourcemod.net/"
  12. };
  13.  
  14. new bool:gClientSpawned[33];
  15. new bool:gClientAgreed[33];
  16.  
  17. public OnPluginStart()
  18. {
  19. CreateConVar("termsagreement_version", VERSION, "Terms And Agreement Plugin Verzioja", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  20. HookEvent("player_spawn", HookClientSpawn, EventHookMode_Post);
  21. }
  22.  
  23. public OnClientDisconnect(client)
  24. {
  25. gClientSpawned[client] = false;
  26. gClientAgreed[client] = false;
  27. }
  28.  
  29. public onClientPutInServer(client)
  30. {
  31. gClientSpawned[client] = false;
  32. }
  33.  
  34. public HookClientSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  35. {
  36. new iUserId = GetEventInt(event, "userid");
  37. new client = GetClientOfUserId(iUserId);
  38.  
  39. if(gClientSpawned[client] == false && gClientAgreed[client] == false)
  40. {
  41. Menu_Build(client);
  42. gClientSpawned[client] = true;
  43. }
  44. }
  45.  
  46. public Menu_Build(client)
  47. {
  48. new String:szTermsFile[256];
  49. BuildPath(Path_SM, szTermsFile, sizeof(szTermsFile), "configs/szabalyzat.txt");
  50. new Handle:hFile = OpenFile(szTermsFile, "rt");
  51.  
  52. if(hFile == INVALID_HANDLE)
  53. {
  54. return;
  55. }
  56.  
  57. new String:szTerms[512];
  58. new String:szReadData[128];
  59.  
  60. new Handle:hMenu = CreatePanel();
  61.  
  62. while(!IsEndOfFile(hFile) && ReadFileLine(hFile, szReadData, sizeof(szReadData)))
  63. {
  64. DrawPanelText(hMenu, szReadData);
  65. }
  66.  
  67. SetPanelTitle(hMenu, "Szerver Szabalyok:");
  68.  
  69. DrawPanelItem(hMenu, "Elfogadom");
  70. DrawPanelItem(hMenu, "Nem fogadom el");
  71.  
  72. SendPanelToClient(hMenu, client, Menu_Handler, 60);
  73.  
  74. CloseHandle(hMenu);
  75.  
  76. CloseHandle(hFile);
  77. }
  78.  
  79. public Menu_Handler(Handle:hMenu, MenuAction:action, param1, param2)
  80. {
  81. if(action == MenuAction_Select)
  82. {
  83. if(param2 == 1)
  84. {
  85. PrintToChat(param1, "\x04Elfogadtad a szabalyzatot, jatszhatsz a szerveren. Jo jatekot kivanunk.");
  86. gClientAgreed[param1] = true;
  87. }
  88. else if(param2 == 2)
  89. {
  90. KickClient(param1, "Nem fogadtad el a szabalyzatot!");
  91. }
  92. }
  93. }