Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <clientprefs>
  5. #include <sdkhooks>
  6. #include <sdktools>
  7. #include <lvl_ranks>
  8.  
  9. #define PLUGIN_NAME "Levels Ranks"
  10. #define PLUGIN_AUTHOR "RoadSide Romeo"
  11.  
  12. int g_iFRType,
  13. g_iFRButton[MAXPLAYERS+1],
  14. g_iRankPlayers[MAXPLAYERS+1],
  15. g_iRankPlayersType[MAXPLAYERS+1],
  16. g_iRankOffset,
  17. g_iRankOffsetType;
  18. Handle g_hFakeRank = null;
  19.  
  20. public Plugin myinfo = {name = "[LR] Module - FakeRank", author = PLUGIN_AUTHOR, version = PLUGIN_VERSION}
  21. public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
  22. {
  23. switch(GetEngineVersion())
  24. {
  25. case Engine_CSGO: LogMessage("[" ... PLUGIN_NAME ... " Fake Rank] Successfully launched");
  26. default: SetFailState("[" ... PLUGIN_NAME ... " Fake Rank] Plug-in works only on CS:GO");
  27. }
  28. }
  29.  
  30. public void OnPluginStart()
  31. {
  32. HookEvent("player_spawn", PlayerSpawn);
  33. g_hFakeRank = RegClientCookie("LR_FakeRank", "LR_FakeRank", CookieAccess_Private);
  34. LoadTranslations("levels_ranks_fakerank.phrases");
  35.  
  36. for(int iClient = 1; iClient <= MaxClients; iClient++)
  37. {
  38. if(IsClientInGame(iClient))
  39. {
  40. if(AreClientCookiesCached(iClient))
  41. {
  42. OnClientCookiesCached(iClient);
  43. }
  44. }
  45. }
  46. }
  47.  
  48. public void OnMapStart()
  49. {
  50. char sPath[PLATFORM_MAX_PATH];
  51. BuildPath(Path_SM, sPath, sizeof(sPath), "configs/levels_ranks/fakerank.ini");
  52. KeyValues hLR_FR = new KeyValues("LR_FakeRank");
  53.  
  54. if(!hLR_FR.ImportFromFile(sPath) || !hLR_FR.GotoFirstSubKey())
  55. {
  56. SetFailState("[" ... PLUGIN_NAME ... " Fake Rank] file is not found (%s)", sPath);
  57. }
  58.  
  59. hLR_FR.Rewind();
  60.  
  61. if(hLR_FR.JumpToKey("Settings"))
  62. {
  63. g_iFRType = hLR_FR.GetNum("type", 0);
  64. }
  65. else SetFailState("[" ... PLUGIN_NAME ... " Fake Rank] section Settings is not found (%s)", sPath);
  66. delete hLR_FR;
  67.  
  68. g_iRankOffset = FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking");
  69. g_iRankOffsetType = FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRankType");
  70. SDKHook(FindEntityByClassname(MaxClients + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
  71. }
  72.  
  73. public void OnMapEnd()
  74. {
  75. SDKUnhook(FindEntityByClassname(MaxClients + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
  76. }
  77.  
  78. public Action OnPlayerRunCmd(int iClient, int& buttons, int& impulse, float fVel[3], float fAngles[3], int& iWeapon)
  79. {
  80. if(StartMessageOne("ServerRankRevealAll", iClient) != INVALID_HANDLE)
  81. {
  82. EndMessage();
  83. }
  84. }
  85.  
  86. public void Hook_OnThinkPost(int iEnt)
  87. {
  88. SetEntDataArray(iEnt, g_iRankOffset, g_iRankPlayers, MAXPLAYERS+1);
  89. SetEntDataArray(iEnt, g_iRankOffsetType, g_iRankPlayersType, MAXPLAYERS+1, 1);
  90. }
  91.  
  92. public void LR_OnLevelChanged(int iClient, int iNewLevel, bool bUp)
  93. {
  94. if (CheckCommandAccess(iClient, "vip", ADMFLAG_CUSTOM1))
  95. {
  96. g_iRankPlayers[iClient] = iNewLevel;
  97. CheckRankType(iClient);
  98. }
  99. }
  100.  
  101. public void PlayerSpawn(Handle hEvent, char[] sEvName, bool bDontBroadcast)
  102. {
  103. if (CheckCommandAccess(iClient, "vip", ADMFLAG_CUSTOM1))
  104. {
  105. int iClient = GetClientOfUserId(GetEventInt(hEvent, "userid"));
  106. g_iRankPlayers[iClient] = LR_GetClientInfo(iClient, ST_RANK);
  107. CheckRankType(iClient);
  108. }
  109. }
  110.  
  111. public void LR_OnMenuCreated(int iClient, int iRank, Menu& hMenu)
  112. {
  113. if(iRank == 0 && g_iFRType == 2)
  114. {
  115. char sText[64];
  116. SetGlobalTransTarget(iClient);
  117. switch(g_iFRButton[iClient])
  118. {
  119. case 0: FormatEx(sText, sizeof(sText), "%t", "FR_Menu_Normal");
  120. case 1: FormatEx(sText, sizeof(sText), "%t", "FR_Menu_Wingman");
  121. }
  122. hMenu.AddItem("FakeRank", sText);
  123. }
  124. }
  125.  
  126. public void LR_OnMenuItemSelected(int iClient, int iRank, const char[] sInfo)
  127. {
  128. if(iRank == 0 && strcmp(sInfo, "FakeRank") == 0)
  129. {
  130. switch(g_iFRButton[iClient])
  131. {
  132. case 0: g_iFRButton[iClient] = 1;
  133. case 1: g_iFRButton[iClient] = 0;
  134. }
  135.  
  136. CheckRankType(iClient);
  137. LR_MenuInventory(iClient);
  138. }
  139. }
  140.  
  141. void CheckRankType(int iClient)
  142. {
  143. switch(g_iFRType)
  144. {
  145. case 1: g_iRankPlayersType[iClient] = 7;
  146. case 2:
  147. {
  148. switch(g_iFRButton[iClient])
  149. {
  150. case 0: g_iRankPlayersType[iClient] = 0;
  151. case 1: g_iRankPlayersType[iClient] = 7;
  152. }
  153. }
  154. }
  155. }
  156.  
  157. public void OnClientCookiesCached(int iClient)
  158. {
  159. char sCookie[8];
  160. GetClientCookie(iClient, g_hFakeRank, sCookie, sizeof(sCookie));
  161. g_iFRButton[iClient] = StringToInt(sCookie);
  162. }
  163.  
  164. public void OnClientDisconnect(int iClient)
  165. {
  166. if(AreClientCookiesCached(iClient))
  167. {
  168. char sBuffer[8];
  169. FormatEx(sBuffer, sizeof(sBuffer), "%i", g_iFRButton[iClient]);
  170. SetClientCookie(iClient, g_hFakeRank, sBuffer);
  171. }
  172. }
  173.  
  174. public void OnPluginEnd()
  175. {
  176. for(int iClient = 1; iClient <= MaxClients; iClient++)
  177. {
  178. if(IsClientInGame(iClient))
  179. {
  180. OnClientDisconnect(iClient);
  181. }
  182. }
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement