Skip to content

Instantly share code, notes, and snippets.

@kiprasmel
Last active April 20, 2020 22:24
Show Gist options
  • Save kiprasmel/b4777b9e06f9bb802d99a62fe8815de8 to your computer and use it in GitHub Desktop.
Save kiprasmel/b4777b9e06f9bb802d99a62fe8815de8 to your computer and use it in GitHub Desktop.
#include <sourcemod>
public Plugin myinfo = {
name = "Get IP",
author = "Kipras Melnikovas (https://kipras.org) <[email protected]>",
description = "Get an IP address of a target",
version = "0.1.0",
url = "https://kipras.org"
};
public void OnPluginStart() {
RegAdminCmd("sm_getip", Command_GetIp, ADMFLAG_CHANGEMAP);
}
public Action Command_GetIp(int client, int args) {
char targetName[32];
if (!GetCmdArg(1, targetName, sizeof(targetName))) {
ReplyToCommand(client, "[SM] Usage: sm_getip <name|#userid>");
return Plugin_Handled;
}
int target = FindTarget(client, targetName);
if (target == -1) {
ReplyToCommand(client, "[SM] Target not found");
return Plugin_Handled; /** oof no ip for u */
}
const int maxiplen = 3 * 3 + 3 + 1; /** 0-255 * 3 + 3 dots + NULL terminator */
char ip[maxiplen];
GetClientIP(target, ip, maxiplen);
ReplyToCommand(client, "[SM] IP of %N: \n\n%s\n", target, ip);
return Plugin_Handled;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment