#pragma semicolon 1
#include <sourcemod>
#include <socket>
#include <csgo_colors>
public Plugin:myinfo =
{
name = "Join Info",
author = "wS",
version = "1.1-CSGO",
};
new String:g_IP[MAXPLAYERS+1][16];
public OnClientPutInServer(client)
{
if (IsFakeClient(client) || !GetClientIP(client, g_IP[client], 16)) return;
new Handle:socket = SocketCreate(SOCKET_TCP, OnSocketError);
SocketSetArg(socket, GetClientUserId(client));
SocketConnect(socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, "www.ipaddresslocation.org", 80);
}
public OnSocketConnected(Handle:socket, any:id)
{
new client = GetClientOfUserId(id);
if (client)
{
decl String:info[150];
FormatEx(info, 150, "GET /ip-address-locator.php?lookup=%s HTTP/1.0\r\nHost: www.ipaddresslocation.org\r\nConnection: close\r\n\r\n", g_IP[client]);
SocketSend(socket, info);
}
}
public OnSocketReceive(Handle:socket, String:receiveData[], const dataSize, any:id)
{
new position = StrContains(receiveData, "IP Location: ", false);
if (position <1) return;
decl String:info[2][65];
if (ExplodeString(receiveData[position + 13], " ", info, 2, 65) > 1)
{
CloseHandle(socket);
decl client;
if ((client = GetClientOfUserId(id)))
{
decl String:steamid[30];
if (!GetClientAuthId(client, AuthId_Steam2, steamid, 30)) steamid = "steamid: -";
TrimString(info[1]); TrimString(info[0]);
if (info[0]) CGOPrintToChatAll("{OLIVE}Подключается игрок: {RED}%N {OLIVE}из города {RED}%s", client, info[0]);
else CGOPrintToChatAll("{OLIVE}Подключается игрок: {RED}%N ", client);
}
}
}
public OnSocketDisconnected(Handle:socket, any:id) CloseHandle(socket);
public OnSocketError(Handle:socket, const errorType, const errorNum, any:id)
{
CloseHandle(socket);
LogError("socket error %d (errno %d)", errorType, errorNum);
}