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

[ANY] Play Time Rankings v0.5 (Updated 8/24/12)


Post New Thread Reply   
 
Thread Tools Display Modes
Mitchell
~lick~
Join Date: Mar 2010
Old 01-21-2014 , 18:29   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #31

Update: if you would like to monitor the changes to this plugin i have setup a github at: https://github.com/MitchDizzle/Play-Time-Rankings/
or specifically if you're looking for current changes they would be here:
https://github.com/MitchDizzle/Play-...gs/tree/PTR-01

Edit:
Added to the change log, the commits of the unstested branch.
Still yet to test it, if it works then i would recommend to update to it.

If you would like to help me test it please let me know.

Last edited by Mitchell; 01-22-2014 at 11:22.
Mitchell is offline
The Flying Apple
Junior Member
Join Date: Mar 2013
Old 03-10-2014 , 14:41   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #32

How do i change some Steam-IDīs so that they are in higher rang????

For an example i wanīt to be the highest rank as an owner...
The Flying Apple is offline
wherE1997
Member
Join Date: Dec 2013
Old 03-24-2014 , 11:21   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #33

when the new update will come out?
__________________
Sorry for my bad English!
wherE1997 is offline
ben_yaa
Member
Join Date: Feb 2011
Old 04-07-2014 , 06:34   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #34

If anyone wants,
there's my working SQL version(with additional commands).
The additional commands:
sm_rank = Shows your approximate time in the server in minutes and your exact time in seconds.
sm_rankme = (root only) Modify your rank. I did it so only the one who use the command can use it on himself only. That way regular admins cannot abuse this command through rcon.
sm_rsrank = (root only) Reset all ranks.
additional CVAR:
sm_maxrank = The maximum rank(in seconds) that anyone can reach(default: 1000000).
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <clientprefs>
#include <scp>
#define VERSION "0.5"

new TotalTime[MAXPLAYERS+1];
new 
iTeam[MAXPLAYERS+1];

new 
bool:bCountSpec;
new 
bool:bCountCT;
new 
bool:bCountT;
static 
Handle:Conrank;

#define MAXTAGS 40
enum Tags
{
    
String:Tag[32],
    
String:Color[10],
    
PlayTimeNeeded
}
new 
TagHandler[MAXTAGS+1][Tags];
new 
TagCount;

new 
Handle:CountSpecs INVALID_HANDLE;
new 
Handle:AllowCT INVALID_HANDLE;
new 
Handle:AllowT INVALID_HANDLE;
new 
Handle:db INVALID_HANDLE;

public 
Plugin:myinfo =
{
    
name "Play Time Ranking",
    
author "Mitch. Edited by Ben-Yaa yey :D",
    
description "Play Tag Ranks",
    
version VERSION,
    
url "http://snbx.info/"
}

public 
OnPluginStart()
{
    
CreateTimer(1.0CheckTime_TIMER_REPEAT);
    
CreateTimer(60.0UpdateTime_TIMER_REPEAT);
    
LoadConfig();
    
CountSpecs CreateConVar("sm_playtime_countspec""0""Addtime if the players are in spec?");
    
AllowT CreateConVar("sm_playtime_count2""1""Addtime if the players are in Terrorist/Red?");
    
AllowCT CreateConVar("sm_playtime_count3""1""Addtime if the players are in Counter-Terrorist/blue?");
    
RegConsoleCmd("sm_rank"MYRANK);
    
AutoExecConfig(true"playtime");
    
bCountSpec GetConVarBool(CountSpecs);
    
bCountT GetConVarBool(AllowT);
    
bCountCT GetConVarBool(AllowCT);
    
HookConVarChange(CountSpecs,    CvarUpdated);
    
HookConVarChange(AllowT,        CvarUpdated);
    
HookConVarChange(AllowCT,        CvarUpdated);
    
RegAdminCmd("sm_rankme"Command_RANKMEADMFLAG_ROOT);
     
RegAdminCmd("sm_rsrank"Command_RESETRANKADMFLAG_ROOT);
    
HookEvent("player_team"Event_Team);
    
HookEvent("player_connect"Event_Connect);
    
Conrank CreateConVar"sm_maxrank""1000000""Maximum rank(in seconds)");
    
    
CreateConVar("playtime_version"VERSION"Tag Ranking Version"FCVAR_DONTRECORD|FCVAR_NOTIFY|FCVAR_CHEAT);    
new 
String:sqlError[64];
            
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
    if (
db == INVALID_HANDLE)
    {
        
LogError("[ PlayTime ] couldn't connect to the Database!! Error: %s"sqlError);
        return 
Plugin_Handled;        

    }
        new 
String:query[200];
Format(querysizeof(query), "CREATE TABLE IF NOT EXISTS `RANKS`(`STEAM_ID` VARCHAR(30) NOT NULL PRIMARY KEY, `PLAY_TIME` VARCHAR(50) NOT NULL)");
        
SQL_FastQuery(dbquery);
    for(new 
client 1client <= MaxClientsclient++)
    {

        if(
IsClientInGame(client))
        {
            
        
iTeam[client] = GetClientTeam(client);
        new 
String:steamid[64];
        
GetClientAuthString(clientsteamidsizeof(steamid));
        
Format(querysizeof(query), "SELECT `PLAY_TIME` FROM `RANKS` WHERE `STEAM_ID` = '%s'"steamid);
        
SQL_TQuery(dbNewPlayerTimequeryclient);
        
        }
        else
        {
            
iTeam[client] = 0;
        }
    }
    return 
Plugin_Handled;
}

public 
Action:Event_Connect(Handle:event, const String:name[], bool:dontBroadcast)
{
        new 
String:sqlError[64];
            
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        new 
String:steamid[64];
        
GetClientAuthString(clientsteamidsizeof(steamid));
        new 
String:query[200];
        
Format(querysizeof(query), "SELECT `PLAY_TIME` FROM `RANKS` WHERE `STEAM_ID` = '%s'"steamid);
        
SQL_TQuery(dbNewPlayerTimequeryclient);
}

public 
NewPlayerTime(Handle:ownerHandle:hndl, const String:error[], any:client)
{
new 
String:steamid[64];
GetClientAuthString(clientsteamidsizeof(steamid));
if (!
SQL_FetchRow(hndl))
    {
        new 
String:query[200];
        
Format(querysizeof(query), "INSERT INTO `RANKS` VALUES('%s', 0)"steamid);
        
SQL_FastQuery(dbquery);
        
TotalTime[client] = 0;
    }
else
{
new 
String:sha2[64];
SQL_FetchString(hndl0sha2sizeof(sha2));
TotalTime[client] = StringToInt(sha2);
}
}

public 
Action:Command_RANKME(clientargs)
{
    new 
String:Arg[128];
    
GetCmdArg(1Argsizeof(Arg));
    
TotalTime[client] = StringToInt(Arg);

}


public 
Action:MYRANK(clientargs)
{
    
PrintToChat(client"\x03Your time(in seconds): \x05%d"TotalTime[client]);
    
PrintToChat(client"\x03Your approximate time(in minutes): \x05%d"TotalTime[client]/60);
}


public 
Action:Command_RESETRANK(clientargs)
{
        new 
String:sqlError[64];
            
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
    if (
db == INVALID_HANDLE)
    {
        
LogError("[ PlayTime ] couldn't connect to the Database!! Error: %s"sqlError);
        return;        

    }
else
{
new 
String:query[200];
        
Format(querysizeof(query), "UPDATE `RANKS` SET `PLAY_TIME` = 0");
SQL_FastQuery(dbquery);
for(new 
1<= MaxClientsi++)
    {


        new 
String:steamid[64];
        
GetClientAuthString(isteamidsizeof(steamid));
        
TotalTime[i] = 0;

    }
}
}

public 
Action:CheckTime(Handle:timer)
{
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client))
        {
            if(((
iTeam[client] > 2) && bCountSpec) || ((iTeam[client] == 2) && bCountT) || ((iTeam[client] == 3) && bCountCT))
            {
                if(
TotalTime[client] < GetConVarInt(Conrank))
                
TotalTime[client]++;
                new 
String:steamid[64];
                
GetClientAuthString(clientsteamidsizeof(steamid));
                new 
String:query[200];
                
Format(querysizeof(query), "SELECT `PLAY_TIME` FROM `RANKS` WHERE `STEAM_ID` = '%s'"steamid);
                
SQL_TQuery(dbSetPlayerTimequeryclient);
            }
        }
    }
    return 
Plugin_Continue;
}

public 
Action:UpdateTime(Handle:timer)
{
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client))
        {
                new 
String:sqlError[64];
                
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
                new 
String:steamid[64];
                new 
String:query[200];
                
GetClientAuthString(clientsteamidsizeof(steamid));
                
Format(querysizeof(query), "SELECT `PLAY_TIME` FROM `RANKS` WHERE `STEAM_ID` = '%s'"steamid);
                
SQL_TQuery(dbUpdatePlayerTimequeryclient);
        }
    }
    return 
Plugin_Continue;
}

public 
UpdatePlayerTime(Handle:ownerHandle:hndl, const String:error[], any:client)
{
new 
String:steamid[64];
GetClientAuthString(clientsteamidsizeof(steamid));
new 
String:query[200];
if (!
SQL_FetchRow(hndl))
    {
        
Format(querysizeof(query), "INSERT INTO `RANKS` VALUES('%s', 0)"steamid);
        
SQL_FastQuery(dbquery);
        
TotalTime[client] = 0;
    }
else
{
Format(querysizeof(query), "UPDATE `RANKS` SET `PLAY_TIME` = '%s' WHERE `STEAM_ID` = '%s'"TotalTime[client], steamid);
        
SQL_FastQuery(dbquery);
}
}


public 
SetPlayerTime(Handle:ownerHandle:hndl, const String:error[], any:client)
{
new 
String:steamid[64];
GetClientAuthString(clientsteamidsizeof(steamid));
new 
String:query[200];
if (!
SQL_FetchRow(hndl))
    {
        
Format(querysizeof(query), "INSERT INTO `RANKS` VALUES('%s', 0)"steamid);
        
SQL_FastQuery(dbquery);
        
TotalTime[client] = 0;
    }
}

public 
OnClientDisconnect(client)
{
new 
String:steamid[64];
GetClientAuthString(clientsteamidsizeof(steamid));
new 
String:query[200];
    new 
String:sqlError[64];
    
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
    
Format(querysizeof(query), "UPDATE `RANKS` SET `PLAY_TIME` = '%i' WHERE `STEAM_ID` = '%s'"TotalTime[client], steamid);
                
SQL_FastQuery(dbquery);
}

public 
Action:OnChatMessage(&authorHandle:recipientsString:name[], String:message[]) {
    new 
TagNum = -1;
    if(
TagCount 0)
    {
        for(new 
0TagCountX++)
        {
            if(((
TagHandler[X][PlayTimeNeeded])*60) <= TotalTime[author])
            {
                
TagNum X;
                break;
            }
        }
    }
    if(
TagNum == -1)
    {
        return 
Plugin_Continue;
    }
    
//This is pretty much Dr.McKay's Customchat color code, just replaced variables.
    
if(strlen(TagHandler[TagNum][Tag]) > 0)
    {
        if(
StrEqual(TagHandler[TagNum][Color], "T"false))
        {
            
Format(nameMAXLENGTH_NAME"\x03%s %s"TagHandler[TagNum][Tag], name);
        }
        else if(
StrEqual(TagHandler[TagNum][Color], "G"false))
        {
            
Format(nameMAXLENGTH_NAME"\x04%s \x03%s"TagHandler[TagNum][Tag], name);
        }
        else if(
StrEqual(TagHandler[TagNum][Color], "O"false))
        {
            
Format(nameMAXLENGTH_NAME"\x05%s \x03%s"TagHandler[TagNum][Tag], name);
        }
        else if(
strlen(TagHandler[TagNum][Color]) == 6)
        {
            
Format(nameMAXLENGTH_NAME"\x07%s%s \x03%s"TagHandler[TagNum][Color], TagHandler[TagNum][Tag], name);
        }
        else if(
strlen(TagHandler[TagNum][Color]) == 8
        {
            
Format(nameMAXLENGTH_NAME"\x08%s%s \x03%s"TagHandler[TagNum][Color], TagHandler[TagNum][Tag], name);
        }
        else
        {
            
Format(nameMAXLENGTH_NAME"\x01%s \x03%s"TagHandler[TagNum][Tag], name);
        }
    }
    return 
Plugin_Changed;
}

public 
OnPluginEnd()
{
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client))
        {
            
OnClientDisconnect(client);
        }
    }
}

public 
Action:Event_Team(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
iTeam[client] = GetEventInt(event"team"); //GetClientTeam(client);
}

public 
CvarUpdated(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if(
convar == CountSpecs)
    {
        
bCountSpec GetConVarBool(CountSpecs);
    }
    else if(
convar == AllowT)
    {
        
bCountT GetConVarBool(AllowT);
    }
    else if(
convar == AllowCT)
    {
        
bCountCT GetConVarBool(AllowCT);
    }
}

LoadConfig() {
    
    for(new 
0MAXTAGSX++)
    {
        
strcopy(TagHandler[X][Tag], 32"");
        
strcopy(TagHandler[X][Color], 10"");
        
TagHandler[X][PlayTimeNeeded] = 0;
    }
    new 
Handle:kvs CreateKeyValues("TagConfig");
    
decl String:sPaths[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMsPathssizeof(sPaths),"configs/ranktime.cfg");
    if(
FileToKeyValues(kvssPaths))
    {
        if (
KvGotoFirstSubKey(kvs))
        {
            
TagCount 0;
            do
            {
                
KvGetSectionName(kvsTagHandler[TagCount][Tag], 32);
                
KvGetString(kvs"color"TagHandler[TagCount][Color], 10);
                
TagHandler[TagCount][PlayTimeNeeded] = KvGetNum(kvs"playtime"0);
                
ReplaceString(TagHandler[TagCount][Color], 32"#""");
                
//PrintToServer("Tag: %s\n  Color: %s\n  Time: %i", TagHandler[TagCount][Tag], TagHandler[TagCount][Color], TagHandler[TagCount][PlayTimeNeeded]);
                
TagCount++;
            } while (
KvGotoNextKey(kvs));
        }
    }
    
CloseHandle(kvs);

You need to add to your addons/sourcemod/configs/databases.cfg:
Code:
    	"playtime"
    	{
      	 	"driver"              "mysql"
     	  	"host"                "localhost"
     	  	"database"            "<place database name here>"
      	  	"user"                "<place user here>"
     	  	"pass"                "<place password here>"
       		"port"                "3306" //Usually 3306
   	 }
ben_yaa is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-07-2014 , 09:51   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #35

I will compare your working version to my sql version, and add the features in my self. So far I see a lot of bad coding conventions in yours that I would have to fix.
Plus if you use the version you have it will be in a different database, as i did not name my tables after yours and will screw up other people.
Also doing an update through mysql on every client every second is bad. ill test my version soon and add onto, possibly natives too.

Last edited by Mitchell; 04-07-2014 at 09:54.
Mitchell is offline
HvG Community
AlliedModders Donor
Join Date: Sep 2012
Old 04-11-2014 , 20:59   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #36

Hey i just need someone to add few stuff to this plugin, i will pay for it.
I want after each level up in rank, player to get rewarded with !sm_givecredits
and ranks should have flags assigned to them
HvG Community is offline
ben_yaa
Member
Join Date: Feb 2011
Old 04-12-2014 , 05:54   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #37

here's a better one:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <clientprefs>
#include <scp>
#define VERSION "0.5"

new TotalTime[MAXPLAYERS+1];
new 
iTeam[MAXPLAYERS+1];

new 
bool:bCountSpec;
new 
bool:bCountCT;
new 
bool:bCountT;
static 
Handle:Conrank;

#define MAXTAGS 40
enum Tags
{
    
String:Tag[32],
    
String:Color[10],
    
PlayTimeNeeded
}
new 
TagHandler[MAXTAGS+1][Tags];
new 
TagCount;

new 
Handle:CountSpecs INVALID_HANDLE;
new 
Handle:AllowCT INVALID_HANDLE;
new 
Handle:AllowT INVALID_HANDLE;
new 
Handle:db INVALID_HANDLE;

public 
Plugin:myinfo =
{
    
name "Play Time Ranking",
    
author "Mitch.",
    
description "Play Tag Ranks",
    
version VERSION,
    
url "http://snbx.info/"
}

public 
OnPluginStart()
{
    
CreateTimer(1.0CheckTime_TIMER_REPEAT);
    
CreateTimer(60.0UpdateTime_TIMER_REPEAT);
    
LoadConfig();
    
CountSpecs CreateConVar("sm_playtime_countspec""0""Addtime if the players are in spec?");
    
AllowT CreateConVar("sm_playtime_count2""1""Addtime if the players are in Terrorist/Red?");
    
AllowCT CreateConVar("sm_playtime_count3""1""Addtime if the players are in Counter-Terrorist/blue?");
    
RegConsoleCmd("sm_rank"MYRANK);
    
AutoExecConfig(true"playtime");
    
bCountSpec GetConVarBool(CountSpecs);
    
bCountT GetConVarBool(AllowT);
    
bCountCT GetConVarBool(AllowCT);
    
HookConVarChange(CountSpecs,    CvarUpdated);
    
HookConVarChange(AllowT,        CvarUpdated);
    
HookConVarChange(AllowCT,        CvarUpdated);
    
RegAdminCmd("sm_rankme"Command_RANKMEADMFLAG_ROOT);
     
RegAdminCmd("sm_rsrank"Command_RESETRANKADMFLAG_ROOT);
    
HookEvent("player_team"Event_Team);
    
HookEvent("player_connect"Event_Connect);
    
Conrank CreateConVar"sm_maxrank""1000000""Maximum rank(in seconds)");
    
    
CreateConVar("playtime_version"VERSION"Tag Ranking Version"FCVAR_DONTRECORD|FCVAR_NOTIFY|FCVAR_CHEAT);    
new 
String:sqlError[64];
            
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
    if (
db == INVALID_HANDLE)
    {
        
LogError("[ PlayTime ] couldn't connect to the Database!! Error: %s"sqlError);
        return 
Plugin_Handled;        

    }
        new 
String:query[200];
Format(querysizeof(query), "CREATE TABLE IF NOT EXISTS `RANKS`(`STEAM_ID` VARCHAR(30) NOT NULL PRIMARY KEY, `PLAY_TIME` VARCHAR(50) NOT NULL)");
        
SQL_FastQuery(dbquery);
    for(new 
client 1client <= MaxClientsclient++)
    {

        if(
IsClientInGame(client))
        {
        
iTeam[client] = GetClientTeam(client);
        new 
String:steamid[64];
        
GetClientAuthString(clientsteamidsizeof(steamid));
        
Format(querysizeof(query), "SELECT `PLAY_TIME` FROM `RANKS` WHERE `STEAM_ID` = '%s'"steamid);
        
SQL_TQuery(dbNewPlayerTimequeryclient);
        }
        else
        {
            
iTeam[client] = 0;
        }
    }
    return 
Plugin_Handled;
}

public 
Action:Event_Connect(Handle:event, const String:name[], bool:dontBroadcast)
{
        new 
String:sqlError[64];
            
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        new 
String:steamid[64];
        
GetClientAuthString(clientsteamidsizeof(steamid));
        new 
String:query[200];
        
Format(querysizeof(query), "SELECT `PLAY_TIME` FROM `RANKS` WHERE `STEAM_ID` = '%s'"steamid);
        
SQL_TQuery(dbNewPlayerTimequeryclient);
}

public 
NewPlayerTime(Handle:ownerHandle:hndl, const String:error[], any:client)
{
new 
String:steamid[64];
new 
String:sqlError[64];
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
    if (
db == INVALID_HANDLE)
    {
        
LogError("[ PlayTime ] couldn't connect to the Database!! Error: %s"sqlError);
        return;        

    }
GetClientAuthString(clientsteamidsizeof(steamid));
if (!
SQL_FetchRow(hndl))
    {
        new 
String:query[200];
        
Format(querysizeof(query), "INSERT INTO `RANKS` VALUES('%s', 0)"steamid);
        
SQL_FastQuery(dbquery);
        
TotalTime[client] = 0;
    }
else
{
new 
String:sha2[64];
SQL_FetchString(hndl0sha2sizeof(sha2));
TotalTime[client] = StringToInt(sha2);
}
}

public 
Action:Command_RANKME(clientargs)
{
    new 
String:Arg[128];
    
GetCmdArg(1Argsizeof(Arg));
    
TotalTime[client] = StringToInt(Arg);

}


public 
Action:MYRANK(clientargs)
{
    
PrintToChat(client"\x03Your time(in seconds): \x05%d"TotalTime[client]);
    
PrintToChat(client"\x03Your approximate time(in minutes): \x05%d"TotalTime[client]/60);
}


public 
Action:Command_RESETRANK(clientargs)
{
        new 
String:sqlError[64];
            
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
    if (
db == INVALID_HANDLE)
    {
        
LogError("[ PlayTime ] couldn't connect to the Database!! Error: %s"sqlError);
        return;        

    }
else
{
new 
String:query[200];
        
Format(querysizeof(query), "UPDATE `RANKS` SET `PLAY_TIME` = 0");
SQL_FastQuery(dbquery);
for(new 
1<= MaxClientsi++)
    {


        new 
String:steamid[64];
        
GetClientAuthString(isteamidsizeof(steamid));
        
TotalTime[i] = 0;

    }
}
}

public 
Action:CheckTime(Handle:timer)
{
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client))
        {
            if(((
iTeam[client] > 2) && bCountSpec) || ((iTeam[client] == 2) && bCountT) || ((iTeam[client] == 3) && bCountCT))
            {
                if(
TotalTime[client] < GetConVarInt(Conrank))
                
TotalTime[client]++;
            }
        }
    }
    return 
Plugin_Continue;
}

public 
Action:UpdateTime(Handle:timer)
{
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client))
        {
                new 
String:sqlError[64];
                
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
                new 
String:steamid[64];
                new 
String:query[200];
                
GetClientAuthString(clientsteamidsizeof(steamid));
                
Format(querysizeof(query), "SELECT `PLAY_TIME` FROM `RANKS` WHERE `STEAM_ID` = '%s'"steamid);
                
SQL_TQuery(dbUpdatePlayerTimequeryclient);
        }
    }
    return 
Plugin_Continue;
}

public 
UpdatePlayerTime(Handle:ownerHandle:hndl, const String:error[], any:client)
{
new 
String:steamid[64];
GetClientAuthString(clientsteamidsizeof(steamid));
new 
String:query[200];
if (
SQL_FetchRow(hndl))
    {

    
Format(querysizeof(query), "UPDATE `RANKS` SET `PLAY_TIME` = '%s' WHERE `STEAM_ID` = '%s'"TotalTime[client], steamid);
    
SQL_FastQuery(dbquery);

    }
}

public 
OnClientDisconnect(client)
{
new 
String:steamid[64];
GetClientAuthString(clientsteamidsizeof(steamid));
new 
String:query[200];
    new 
String:sqlError[64];
    
db SQL_Connect("playtime"truesqlErrorsizeof(sqlError));
    
Format(querysizeof(query), "UPDATE `RANKS` SET `PLAY_TIME` = '%i' WHERE `STEAM_ID` = '%s'"TotalTime[client], steamid);
                
SQL_FastQuery(dbquery);
}

public 
Action:OnChatMessage(&authorHandle:recipientsString:name[], String:message[]) {
    new 
TagNum = -1;
    if(
TagCount 0)
    {
        for(new 
0TagCountX++)
        {
            if(((
TagHandler[X][PlayTimeNeeded])*60) <= TotalTime[author])
            {
                
TagNum X;
                break;
            }
        }
    }
    if(
TagNum == -1)
    {
        return 
Plugin_Continue;
    }
    
//This is pretty much Dr.McKay's Customchat color code, just replaced variables.
    
if(strlen(TagHandler[TagNum][Tag]) > 0)
    {
        if(
StrEqual(TagHandler[TagNum][Color], "T"false))
        {
            
Format(nameMAXLENGTH_NAME"\x03%s %s"TagHandler[TagNum][Tag], name);
        }
        else if(
StrEqual(TagHandler[TagNum][Color], "G"false))
        {
            
Format(nameMAXLENGTH_NAME"\x04%s \x03%s"TagHandler[TagNum][Tag], name);
        }
        else if(
StrEqual(TagHandler[TagNum][Color], "O"false))
        {
            
Format(nameMAXLENGTH_NAME"\x05%s \x03%s"TagHandler[TagNum][Tag], name);
        }
        else if(
strlen(TagHandler[TagNum][Color]) == 6)
        {
            
Format(nameMAXLENGTH_NAME"\x07%s%s \x03%s"TagHandler[TagNum][Color], TagHandler[TagNum][Tag], name);
        }
        else if(
strlen(TagHandler[TagNum][Color]) == 8
        {
            
Format(nameMAXLENGTH_NAME"\x08%s%s \x03%s"TagHandler[TagNum][Color], TagHandler[TagNum][Tag], name);
        }
        else
        {
            
Format(nameMAXLENGTH_NAME"\x01%s \x03%s"TagHandler[TagNum][Tag], name);
        }
    }
    return 
Plugin_Changed;
}

public 
OnPluginEnd()
{
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client))
        {
            
OnClientDisconnect(client);
        }
    }
}

public 
Action:Event_Team(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
iTeam[client] = GetEventInt(event"team"); //GetClientTeam(client);
}

public 
CvarUpdated(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if(
convar == CountSpecs)
    {
        
bCountSpec GetConVarBool(CountSpecs);
    }
    else if(
convar == AllowT)
    {
        
bCountT GetConVarBool(AllowT);
    }
    else if(
convar == AllowCT)
    {
        
bCountCT GetConVarBool(AllowCT);
    }
}

LoadConfig() {
    
    for(new 
0MAXTAGSX++)
    {
        
strcopy(TagHandler[X][Tag], 32"");
        
strcopy(TagHandler[X][Color], 10"");
        
TagHandler[X][PlayTimeNeeded] = 0;
    }
    new 
Handle:kvs CreateKeyValues("TagConfig");
    
decl String:sPaths[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMsPathssizeof(sPaths),"configs/ranktime.cfg");
    if(
FileToKeyValues(kvssPaths))
    {
        if (
KvGotoFirstSubKey(kvs))
        {
            
TagCount 0;
            do
            {
                
KvGetSectionName(kvsTagHandler[TagCount][Tag], 32);
                
KvGetString(kvs"color"TagHandler[TagCount][Color], 10);
                
TagHandler[TagCount][PlayTimeNeeded] = KvGetNum(kvs"playtime"0);
                
ReplaceString(TagHandler[TagCount][Color], 32"#""");
                
//PrintToServer("Tag: %s\n  Color: %s\n  Time: %i", TagHandler[TagCount][Tag], TagHandler[TagCount][Color], TagHandler[TagCount][PlayTimeNeeded]);
                
TagCount++;
            } while (
KvGotoNextKey(kvs));
        }
    }
    
CloseHandle(kvs);

ben_yaa is offline
HvG Community
AlliedModders Donor
Join Date: Sep 2012
Old 04-12-2014 , 10:02   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #38

That one doesnt have what i asked tho
HvG Community is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-12-2014 , 22:34   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #39

I do not recommend using ben_ya's code, as it is very messy.
Mitchell is offline
Delfy
Member
Join Date: Jul 2013
Old 08-07-2014 , 19:54   Re: [ANY] Play Time Rankings v0.5 (Updated 8/24/12)
Reply With Quote #40

mate, i can add you in steam to talk? I have little quastion and request.
Delfy 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 12:56.


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