AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [Any] Get IP (https://forums.alliedmods.net/showthread.php?t=297168)

Firewolf24 05-07-2017 07:15

[Any] Get IP
 
1 Attachment(s)
[Any] Get IP

Description:
This is my first plugin that i'm uploading here on Alliedmods.
A very simple plugin that can get IP's from players.
I couldn't find a get ip plugin here yet, so i decided to upload it, plus its compatible with all multiplayer games.

Commands:
  • sm_getip <#userid|name> - gets ip.

Again, very simple plugin, i'm still learning, but it works! :wink:

Changes:

May 7th 2017 - 0.2
  • Changed PrintToChat to ReplyToCommand (Thanks fakuivan!)

May 8th 2017 - 0.3
  • Updated syntaxes and added a [GET-IP] tag before the command outputs
  • Changed flag for sm_getip to CHEATS (you can always change it by adding it to admin_overrides.cfg)

March 25th 2018 - 0.4
  • Changed plugin prefix to [IP]
  • Now also prints locations!

fakuivan 05-07-2017 08:28

Re: [Any] Get IP
 
You can type "status" from the server console or "sm_rcon status" to get IP addresses. Just a side note.

fakuivan 05-07-2017 08:33

Re: [Any] Get IP
 
Use ReplyToCommand instead of PrintToChat/Console so you reply to the source, otherwise your user will write the command from console and get the reply from chat (or the other way around).

Firewolf24 05-07-2017 09:38

Re: [Any] Get IP
 
I was also going to do something with geoip to and/or print the location of the player, might take a look into that soon.

but thanks fakuivan!

xfusionlockx 05-08-2017 02:14

Re: [Any] Get IP
 
Simple, lightweight. I like it.

B3none 05-08-2017 04:50

Re: [Any] Get IP
 
Updated to newest syntax and added a Tag before each command, don't have to use it just a thought :3

PHP Code:

#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

#define TAG_MESSAGE "[\x04IPQuery\x01]"

public Plugin myinfo 
{
    
name "IP Query",
    
author "Firewolf",
    
description "Simple Plugin for viewing IP's of players.",
    
version "0.3",
    
url ""
};

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_getip"Command_GetIpADMFLAG_GENERIC"sm_getip <#userid|name> (Gets the IP of the selected target)"); // ADMFLAG_GENERIC? Don't want to be giving up too much information to everyone :P
}

public 
Action Command_GetIp(int clientint args)
{
    if(
args 1)
    {
        
ReplyToCommand(client"%s Missing Parameters. Usage: sm_getip <target>"TAG_MESSAGE);
    }

    
char arg1[32];     
    
GetCmdArg(1arg1sizeof(arg1));
    
int target FindTarget(clientarg1);
    
char ClientIP[32];
    
char TargetName[32];
    
    
GetClientName(targetTargetNamesizeof(TargetName));
    
GetClientIP(targetClientIPsizeof(ClientIP));
    
    
ReplyToCommand(client"%s IP of client %s: %s"TAG_MESSAGETargetNameClientIP);
    return 
Plugin_Handled;



Firewolf24 05-08-2017 08:23

Re: [Any] Get IP
 
I learned some stuff from that, thanks!
And in the original code i had ADMFLAG_ROOT, but i was still unsure what flag to choose from. i might put it to cheats or root, but you can of course always change it in the overrides config file ;)

KissLick 05-08-2017 09:08

Re: [Any] Get IP
 
Guys, %N is also a thing ;-)

Firewolf24 05-08-2017 13:23

Re: [Any] Get IP
 
Wiki: "N: Requires a client index; expands to a string containing the player's name."

so when i put that in place of the S where the targets name is supposed to be i dont need to convert it to a string?

Papero 05-08-2017 13:49

Re: [Any] Get IP
 
Quote:

Originally Posted by Firewolf24 (Post 2519168)
Wiki: "N: Requires a client index; expands to a string containing the player's name."

so when i put that in place of the S where the targets name is supposed to be i dont need to convert it to a string?

Yes, doing
PHP Code:

int client;
PrintToChat(client"%N"client); 

or
PHP Code:

int client;
char sName[32];
GetClientName(client sNamesizeof(sName));
PrintToChat(client,"%s"sName); 

will result in the same output

(client is supposed to be a Valid Client.)


All times are GMT -4. The time now is 19:20.

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