daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdkhooks>
  5. #include <sdktools>
  6. #include <emitsoundany>
  7. #include <kento_rankme/rankme>
  8. #include <colors_csgo>
  9.  
  10. //Here edit point need for ranks
  11. #define SI              100
  12. #define SII             300
  13. #define SIII            400
  14. #define SIV             500
  15. #define SE              600
  16. #define SEM             700
  17. #define GNI             800
  18. #define GNII            900
  19. #define GNIII           1000
  20. #define GNM             1100
  21. #define MGI             1200
  22. #define MGII            1300
  23. #define MGE             1400
  24. #define DMG             1550
  25. #define LE              1700
  26. #define LEM             1850
  27. #define SMC             2000
  28. #define GE              2200
  29.  
  30. int g_offCompRank = -1, rank[MAXPLAYERS + 1], old_rank[MAXPLAYERS + 1], g_fLastButtons[MAXPLAYERS + 1];
  31.  
  32. stock bool IsValidClient(int client, bool alive = false)
  33. {
  34.     if(0 < client && client <= MaxClients && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)))
  35.         return true;
  36.     return false;
  37. }
  38.  
  39. public Plugin myinfo =
  40. {
  41.     name = "Ranking",
  42.     author = "The [G]amerX",
  43.     description = "Giving MM rank by RankMe points",
  44.     url = "http://steamcommunity.com/id/gamerxcz/"
  45. };
  46.  
  47. public void OnMapStart()
  48. {
  49.     PrecacheSoundAny("ui/xp_levelup.wav", true);
  50.     PrecacheSoundAny("ui/xp_rankdown_02.wav", true);
  51.     SDKHook(FindEntityByClassname(MaxClients + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
  52. }
  53. public void OnMapEnd()
  54. {
  55.     SDKUnhook(FindEntityByClassname(MaxClients + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
  56. }
  57. public void OnPluginStart()
  58. {
  59.     HookEvent("announce_phase_end", EventAnnouncePhaseEnd);
  60.     HookEvent("player_death", EventPlayerDeath);
  61.     g_offCompRank = FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking");
  62. }
  63. public void OnClientAuthorized(int client, const char[] auth)
  64. {
  65.     GiveRank(client, 1);
  66. }
  67. public Action EventPlayerDeath(Event event, char[] name, bool dontBroadcast)
  68. {
  69.     int Victim = GetClientOfUserId(event.GetInt("userid"));
  70.     int Attacker = GetClientOfUserId(event.GetInt("attacker"));
  71.     if(IsValidClient(Victim)) GiveRank(Victim, 0);
  72.     if(IsValidClient(Attacker)) GiveRank(Attacker, 0);
  73.     return Plugin_Continue;
  74. }
  75. public void Hook_OnThinkPost(int iEnt)
  76. {
  77.     SetEntDataArray(iEnt, g_offCompRank, rank, MaxClients + 1);
  78. }
  79. public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
  80. {
  81.     if(buttons & IN_SCORE && !(g_fLastButtons[client] & IN_SCORE))
  82.         if(StartMessageOne("ServerRankRevealAll", client) != INVALID_HANDLE) EndMessage();
  83.     g_fLastButtons[client] = buttons;
  84.     return Plugin_Continue;
  85. }
  86. public Action EventAnnouncePhaseEnd(Handle event, const char[] name, bool dontBroadcast)
  87. {
  88.     if(StartMessageAll("ServerRankRevealAll") != INVALID_HANDLE) EndMessage();
  89.     return Plugin_Continue;
  90. }
  91. public void GiveRank(int client, int first)
  92. {
  93.     int points = RankMe_GetPoints(client);
  94.     if(points >= SI && points < SII) rank[client] = 1;
  95.     else if(points >= SII && points < SIII) rank[client] = 2;
  96.     else if(points >= SIII && points < SIV) rank[client] = 3;
  97.     else if(points >= SIV && points < SE) rank[client] = 4;
  98.     else if(points >= SE && points < SEM) rank[client] = 5;
  99.     else if(points >= SEM && points < GNI) rank[client] = 6;
  100.     else if(points >= GNI && points < GNII) rank[client] = 7;
  101.     else if(points >= GNII && points < GNIII) rank[client] = 8;
  102.     else if(points >= GNIII && points < GNM) rank[client] = 9;
  103.     else if(points >= GNM && points < MGI) rank[client] = 10;
  104.     else if(points >= MGI && points < MGII) rank[client] = 11;
  105.     else if(points >= MGII && points < MGE) rank[client] = 12;
  106.     else if(points >= MGE && points < DMG) rank[client] = 13;
  107.     else if(points >= DMG && points < LE) rank[client] = 14;
  108.     else if(points >= LE && points < LEM) rank[client] = 15;
  109.     else if(points >= LEM && points < SMC) rank[client] = 16;
  110.     else if(points >= SMC && points < GE) rank[client] = 17;
  111.     else if(points >= GE) rank[client] = 18;
  112.     else rank[client] = 0;
  113.     if(first == 1)
  114.     {
  115.         old_rank[client] = rank[client];
  116.     }
  117.     else if(first == 0)
  118.     {
  119.         if(old_rank[client] < rank[client])
  120.         {
  121.             CPrintToChat(client, "You are get Rank UP");
  122.             EmitSoundToClientAny(client, "ui/xp_levelup.wav", SOUND_FROM_PLAYER, SNDCHAN_STATIC, 50);
  123.         }
  124.         else if(old_rank[client] > rank[client])
  125.         {
  126.             CPrintToChat(client, "You are get Rank DOWN");
  127.             EmitSoundToClientAny(client, "ui/xp_rankdown_02.wav", SOUND_FROM_PLAYER, SNDCHAN_STATIC, 50);
  128.         }
  129.         old_rank[client] = rank[client];
  130.     }
  131. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top