HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #pragma semicolon 1
  2.  
  3. #define DEBUG
  4.  
  5. #define PLUGIN_AUTHOR "boomix"
  6. #define PLUGIN_VERSION "1.1"
  7.  
  8. #include <sourcemod>
  9. #include <SteamWorks>
  10. #include <smlib>
  11. #include <autoexecconfig>
  12.  
  13. #define LoopAllPlayers(%1) for(int %1=1;%1<=MaxClients;++%1)\
  14. if(IsClientInGame(%1) && !IsFakeClient(%1))
  15.  
  16. bool b_InGroup[MAXPLAYERS + 1];
  17.  
  18. Handle GroupID;
  19. Handle MoneyPerKill;
  20.  
  21. int iGroupID;
  22. int iMoneyPerKill;
  23.  
  24. public Plugin myinfo =
  25. {
  26. name = "Group players",
  27. author = PLUGIN_AUTHOR,
  28. description = "Gives more money for players that are in steam group",
  29. version = PLUGIN_VERSION,
  30. url = "http://google.lv"
  31. };
  32.  
  33. public void OnPluginStart()
  34. {
  35. AutoExecConfig_SetFile("groupplayers");
  36.  
  37. HookConVarChange(GroupID = AutoExecConfig_CreateConVar("sm_groupid", "xxxxxxxxxxxxxxxxxx", "Group ID 64"), OnCvarChanged);
  38. HookConVarChange(MoneyPerKill = AutoExecConfig_CreateConVar("sm_moneyperkill", "50", "How much more money per kill, if player is in group"), OnCvarChanged);
  39.  
  40. AutoExecConfig_ExecuteFile();
  41. AutoExecConfig_CleanFile();
  42.  
  43. HookEvent("player_death", Event_PlayerDeath);
  44.  
  45. UpdateConvars();
  46.  
  47. }
  48.  
  49. public void OnCvarChanged(Handle hConvar, const char[] chOldValue, const char[] chNewValue)
  50. {
  51. UpdateConvars();
  52. }
  53.  
  54. public void UpdateConvars()
  55. {
  56. iGroupID = GetConVarInt(GroupID);
  57. iMoneyPerKill = GetConVarInt(MoneyPerKill);
  58. }
  59.  
  60. public Action Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
  61. {
  62. int client = GetClientOfUserId(GetEventInt(event, "attacker"));
  63.  
  64. if(IsClientInGame(client) && b_InGroup[client])
  65. {
  66. int money = Client_GetMoney(client);
  67. Client_SetMoney(client, money + iMoneyPerKill);
  68. }
  69.  
  70. }
  71.  
  72. public void OnClientPutInServer(int client)
  73. {
  74. b_InGroup[client] = false;
  75. SteamWorks_GetUserGroupStatus(client, iGroupID);
  76. }
  77.  
  78. public int SteamWorks_OnClientGroupStatus(int authid, int groupid, bool isMember, bool isOfficer)
  79. {
  80.  
  81. int client = GetUserFromAuthID(authid);
  82.  
  83. if(isMember)
  84. {
  85. b_InGroup[client] = true;
  86. }
  87.  
  88. }
  89.  
  90. int GetUserFromAuthID(int authid)
  91. {
  92.  
  93. LoopAllPlayers(i)
  94. {
  95. char authstring[50];
  96. GetClientAuthId(i, AuthId_Steam3, authstring, sizeof(authstring));
  97.  
  98. char authstring2[50];
  99. IntToString(authid, authstring2, sizeof(authstring2));
  100.  
  101. if(StrContains(authstring, authstring2) != -1)
  102. {
  103. return i;
  104. }
  105. }
  106.  
  107. return -1;
  108.  
  109. }