Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 3f2dce231f
Fetching contributors…

Cannot retrieve contributors at this time

executable file 123 lines (111 sloc) 3.323 kB
// =============================================================================
// [TF2] Player Stats (C) 2011-2012 Peter "SaberUK" Powell <petpow@saberuk.com>
// =============================================================================
//
// This program is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License, version 3.0, as published by the
// Free Software Foundation.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
//
// =============================================================================
#include <csteamid>
#include <sdktools>
#include <sourcemod>
#pragma semicolon 1
public Plugin:myinfo =
{
name = "[TF2] Player Stats",
description = "Allows players to view stats via TF2Stats.",
author = "Peter \"SaberUK\" Powell",
url = "http://www.saberuk.com/",
version = "1.2"
}
public OnPluginStart()
{
new String:gameFolder[5];
GetGameFolderName(gameFolder, sizeof(gameFolder));
if (!StrEqual(gameFolder, "tf"))
{
SetFailState("This plugin does not support your game.");
}
LoadTranslations("common.phrases");
RegConsoleCmd("sm_backpack", Command_SmBackpack);
RegConsoleCmd("sm_bp", Command_SmBackpack);
RegConsoleCmd("sm_mystats", Command_SmMyStats);
RegConsoleCmd("sm_stats", Command_SmStats);
}
public Action:Command_SmBackpack(client, args)
{
if (client > 0 && IsClientInGame(client))
{
new target = 0;
if (args > 0)
{
decl String:arg1[128];
GetCmdArgString(arg1, sizeof(arg1));
target = FindTarget(client, arg1, true, false);
}
else
{
target = GetClientAimTarget(client, true);
if (target < 0)
{
ReplyToCommand(client, "[SM] Usage: sm_backpack [#userid|name]");
return Plugin_Handled;
}
}
if (target > 0)
{
ShowStats(client, target, "itemscroller");
}
}
return Plugin_Handled;
}
public Action:Command_SmMyStats(client, args)
{
ShowStats(client, client, NULL_STRING);
return Plugin_Handled;
}
public Action:Command_SmStats(client, args)
{
if (client > 0 && IsClientInGame(client))
{
new target = 0;
if (args > 0)
{
decl String:arg1[128];
GetCmdArgString(arg1, sizeof(arg1));
target = FindTarget(client, arg1, true, false);
}
else
{
target = GetClientAimTarget(client, true);
if (target < 0)
{
ReplyToCommand(client, "[SM] Usage: sm_stats <#userid|name>");
}
}
if (target > 0)
{
ShowStats(client, target, NULL_STRING);
}
}
return Plugin_Handled;
}
ShowStats(client, target, const String:id[])
{
if (client > 0 && IsClientInGame(client) && target > 0 && IsClientInGame(target))
{
new String:auth[64], String:uri[128];
GetClientCSteamID(target, auth, sizeof(auth));
Format(uri, sizeof(uri), "http://tf2stats.net/player/%s#%s", auth, id);
ShowMOTDPanel(client, "TF2Stats", uri, MOTDPANEL_TYPE_URL);
}
}
Jump to Line
Something went wrong with that request. Please try again.