Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "nhnkl159"
#define PLUGIN_VERSION "1.0"
#include <sourcemod>
#include <sdktools>
#include <geoip>
#include <cstrike>
ConVar gS_Enabled;
public Plugin myinfo =
{
name = "[CS:GO] Scoreboard Country",
author = PLUGIN_AUTHOR,
description = "Add [Country] tag to the player near his name.",
version = PLUGIN_VERSION,
url = "keepomod.com"
};
public void OnPluginStart()
{
// === ConVars === //
gS_Enabled = CreateConVar("sm_scoreboardcountry_enable", "1", "Sets whether or not to set player tags");
// === Events && Shit === //
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
}
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
if (gS_Enabled.BoolValue)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (IsValidClient(client))
{
CreateTimer(1.5, SetTag_Timer, client, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
public Action SetTag_Timer(Handle Timer, any client)
{
char gS_IP[14], gS_Country[3], gS_Shit[32];
GetClientIP(client, gS_IP, 14);
if (GeoipCode2(gS_IP, gS_Country))
{
FormatEx(gS_Shit, 32, "[%s]", gS_Country);
}
else
{
FormatEx(gS_Shit, 32, "[--]");
}
CS_SetClientClanTag(client, gS_Shit);
}
stock bool IsValidClient(int client, bool alive = false, bool bots = false)
{
if (client > 0 && client <= MaxClients && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)) && (bots == false && !IsFakeClient(client)))
{
return true;
}
return false;
}
__________________