Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #include <sourcemod>
- #include <sdkhooks>
- #include <sdktools>
- #include <emitsoundany>
- #include <kento_rankme/rankme>
- #include <colors_csgo>
- //Here edit point need for ranks
- #define SI 100
- #define SII 300
- #define SIII 400
- #define SIV 500
- #define SE 600
- #define SEM 700
- #define GNI 800
- #define GNII 900
- #define GNIII 1000
- #define GNM 1100
- #define MGI 1200
- #define MGII 1300
- #define MGE 1400
- #define DMG 1550
- #define LE 1700
- #define LEM 1850
- #define SMC 2000
- #define GE 2200
- int g_offCompRank = -1, rank[MAXPLAYERS + 1], old_rank[MAXPLAYERS + 1], g_fLastButtons[MAXPLAYERS + 1];
- stock bool IsValidClient(int client, bool alive = false)
- {
- if(0 < client && client <= MaxClients && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)))
- return true;
- return false;
- }
- public Plugin myinfo =
- {
- name = "Ranking",
- author = "The [G]amerX",
- description = "Giving MM rank by RankMe points",
- url = "http://steamcommunity.com/id/gamerxcz/"
- };
- public void OnMapStart()
- {
- PrecacheSoundAny("ui/xp_levelup.wav", true);
- PrecacheSoundAny("ui/xp_rankdown_02.wav", true);
- SDKHook(FindEntityByClassname(MaxClients + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
- }
- public void OnMapEnd()
- {
- SDKUnhook(FindEntityByClassname(MaxClients + 1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
- }
- public void OnPluginStart()
- {
- HookEvent("announce_phase_end", EventAnnouncePhaseEnd);
- HookEvent("player_death", EventPlayerDeath);
- g_offCompRank = FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking");
- }
- public void OnClientAuthorized(int client, const char[] auth)
- {
- GiveRank(client, 1);
- }
- public Action EventPlayerDeath(Event event, char[] name, bool dontBroadcast)
- {
- int Victim = GetClientOfUserId(event.GetInt("userid"));
- int Attacker = GetClientOfUserId(event.GetInt("attacker"));
- if(IsValidClient(Victim)) GiveRank(Victim, 0);
- if(IsValidClient(Attacker)) GiveRank(Attacker, 0);
- return Plugin_Continue;
- }
- public void Hook_OnThinkPost(int iEnt)
- {
- SetEntDataArray(iEnt, g_offCompRank, rank, MaxClients + 1);
- }
- 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])
- {
- if(buttons & IN_SCORE && !(g_fLastButtons[client] & IN_SCORE))
- if(StartMessageOne("ServerRankRevealAll", client) != INVALID_HANDLE) EndMessage();
- g_fLastButtons[client] = buttons;
- return Plugin_Continue;
- }
- public Action EventAnnouncePhaseEnd(Handle event, const char[] name, bool dontBroadcast)
- {
- if(StartMessageAll("ServerRankRevealAll") != INVALID_HANDLE) EndMessage();
- return Plugin_Continue;
- }
- public void GiveRank(int client, int first)
- {
- int points = RankMe_GetPoints(client);
- if(points >= SI && points < SII) rank[client] = 1;
- else if(points >= SII && points < SIII) rank[client] = 2;
- else if(points >= SIII && points < SIV) rank[client] = 3;
- else if(points >= SIV && points < SE) rank[client] = 4;
- else if(points >= SE && points < SEM) rank[client] = 5;
- else if(points >= SEM && points < GNI) rank[client] = 6;
- else if(points >= GNI && points < GNII) rank[client] = 7;
- else if(points >= GNII && points < GNIII) rank[client] = 8;
- else if(points >= GNIII && points < GNM) rank[client] = 9;
- else if(points >= GNM && points < MGI) rank[client] = 10;
- else if(points >= MGI && points < MGII) rank[client] = 11;
- else if(points >= MGII && points < MGE) rank[client] = 12;
- else if(points >= MGE && points < DMG) rank[client] = 13;
- else if(points >= DMG && points < LE) rank[client] = 14;
- else if(points >= LE && points < LEM) rank[client] = 15;
- else if(points >= LEM && points < SMC) rank[client] = 16;
- else if(points >= SMC && points < GE) rank[client] = 17;
- else if(points >= GE) rank[client] = 18;
- else rank[client] = 0;
- if(first == 1)
- {
- old_rank[client] = rank[client];
- }
- else if(first == 0)
- {
- if(old_rank[client] < rank[client])
- {
- CPrintToChat(client, "You are get Rank UP");
- EmitSoundToClientAny(client, "ui/xp_levelup.wav", SOUND_FROM_PLAYER, SNDCHAN_STATIC, 50);
- }
- else if(old_rank[client] > rank[client])
- {
- CPrintToChat(client, "You are get Rank DOWN");
- EmitSoundToClientAny(client, "ui/xp_rankdown_02.wav", SOUND_FROM_PLAYER, SNDCHAN_STATIC, 50);
- }
- old_rank[client] = rank[client];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement