Raised This Month: $51 Target: $400
 12% 

Top 3 Reward


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
usla
Senior Member
Join Date: Jul 2009
Old 06-03-2017 , 13:37   Top 3 Reward
Reply With Quote #1

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <rankme>

public void OnPluginStart()
{
if (GetEngineVersion() != Engine_CSGO)
SetFailState("This plugin is only for CS:GO !");

HookEvent("player_spawn", OnPlayerSpawn);
}

public void OnPlayerSpawn(Handle event, const char[] name, bool dontBroadcast)
{
int userID = GetEventInt(event, "userid");
int client = GetClientOfUserId(userID);

if(!IsValidClient(client))
return;

RankMe_GetRank(client, RankME_GetRank, userID);
}

public int RankME_GetRank(int client, int rank, any data) 
{ 
if(rank > 3)	
CreateTimer(0.5, TMR_GiveVest, data);
}

public Action TMR_GiveVest(Handle tmr, any userID)
{
int client = GetClientOfUserId(userID);

if(IsValidClient(client))
{
GivePlayerItem(client, "item_kevlar");
}
}

stock bool IsValidClient(iClient, bool bReplay = true)
{
if (iClient <= 0 || iClient > MaxClients)
return false;
if (!IsClientInGame(iClient))
return false;
if (bReplay && (IsClientSourceTV(iClient) || IsClientReplay(iClient)))
return false;

return true;
}
Trying to figure out a way to reward the top 3 players in scoreboard, for both teams in csgo with free armor on spawn

Last edited by usla; 06-03-2017 at 13:37.
usla is offline
Divin12
Senior Member
Join Date: Nov 2011
Old 06-04-2017 , 08:35   Re: Top 3 Reward
Reply With Quote #2

Top3 in scoreboard? For example first 3 players at ct and first 3 players at t? Or first 3 players from you rank plugin?
__________________
Divin12 is offline
usla
Senior Member
Join Date: Jul 2009
Old 06-04-2017 , 10:52   Re: Top 3 Reward
Reply With Quote #3

Quote:
Originally Posted by Divin12 View Post
Top3 in scoreboard? For example first 3 players at ct and first 3 players at t? Or first 3 players from you rank plugin?
top 3 in scoreboard for each team , should be quite simple no sql data or anything

Last edited by usla; 06-04-2017 at 10:53.
usla is offline
Divin12
Senior Member
Join Date: Nov 2011
Old 06-04-2017 , 16:01   Re: Top 3 Reward
Reply With Quote #4

PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>

public void OnPluginStart()
{
    if (
GetEngineVersion() != Engine_CSGO)
    
SetFailState("This plugin is only for CS:GO !");

    
HookEvent("round_start"OnPlayerSpawn);
}

public 
void OnPlayerSpawn(Handle event, const char[] namebool dontBroadcast)
{
    new 
firstct[MaxClients 1], firstt[MaxClients 1];
    new 
ij;
    for(
1MaxClientsi++) 
    {
        if(
IsClientInGame(i) && !IsFakeClient(i)) 
        {
            new 
iTeam GetClientTeam(i);
            if(
iTeam == CS_TEAM_T)
                
firstt[i] = CS_GetClientContributionScore(i);
            else if(
iTeam == CS_TEAM_CT)
                
firstct[i] = CS_GetClientContributionScore(i);
        }
    }
    for(
1MaxClientsi++) 
    {
        for(
i+1MaxClientsj++)
        {
            if(
firstt[i] >= firstt[j])
            {
                
firstt[j] = 0;
            }
            if(
firstct[i] >= firstct[j])
            {
                
firstct[j] = 0;
            }
        }
    }
    for(
1MaxClientsi++) 
    {
        if(
firstt[i] > 0)
        {
            
GivePlayerItem(i"item_kevlar");
        }
        if(
firstct[i] > 0)
        {
            
GivePlayerItem(i"item_kevlar");
        }
        
    }

This is for first from ct and first from t, not tested, test it and check if it works.
__________________
Divin12 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode