Raised This Month: $51 Target: $400
 12% 

Admin Gets Player's IP?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 09-14-2015 , 11:31   Admin Gets Player's IP?
Reply With Quote #1

Hey Guys,,
I just started learning some of sourcemod scripting and i wonder if you help a noob with dat
I'm asking if you can show me how could I get a player IP Address With a Command Like sm_ip #UserID ?
My noob Problem is how could i Define that the First GetCmdArg is a UserID?!
Or if it's Posible complete my noob code xD
Code:
public Action:GetIP(client, args)
{
    if(args < 0)
    {
        PrintToConsole("[SM] Usage : sm_ip #UserID")
        return Plugin_Handled;
    }
    new String:name[32];
    new String:UserIP[32], intarg;
    GetCmdArg(1, name, sizeof(name));
    GetClientIP(client, UserIP, sizeof(UserIP));
    intarg = StringToInt(UserIP);
    PrintToChat(client, "%s IP Address Is : %d", name, intarg);
    return Plugin_Handled;
}
I Don't Know if it's even True or false ;D
can anyone help me ?!
ambn is offline
keyboard1333
Senior Member
Join Date: Aug 2013
Old 09-14-2015 , 11:55   Re: Admin Gets Player's IP?
Reply With Quote #2

Try this? ^_^

PHP Code:
public OnPluginStart() {
    
LoadTranslations("common.phrases");
    
RegAdminCmd("sm_ip"Command_GetIpADMFLAG_BAN"sm_ip <name or #userid>");
}

public 
Action:Command_GetIp(clientargs) {
    if(
args 1) {
        
ReplyToCommand(client"[SM] Usage : sm_ip <name or #userid>");
        return 
Plugin_Handled;    
    }
    
    
char arg[32];
    
GetCmdArg(1argsizeof(arg));
    
    
int target FindTarget(clientarg);
    if(
target == -1) {
        return 
Plugin_Handled;
    }
    
    
char ip[17], name[32];
    
GetClientIP(targetipsizeof(ip));
    
GetClientName(targetnamesizeof(name));
    
ReplyToCommand(client"[SM] %s IP Address Is : %s"nameip);
    return 
Plugin_Handled;


Last edited by keyboard1333; 09-14-2015 at 11:55.
keyboard1333 is offline
bally
Senior Member
Join Date: Aug 2015
Old 09-14-2015 , 11:55   Re: Admin Gets Player's IP?
Reply With Quote #3

Code:
//assign variables
new String:_targ[32]; 
decl String:szID[21], String:szIP[32]

//Get commands args
GetCmdArg(1, _targ, sizeof(_targ));

// Find Target
new target = FindTarget(client, _targ, false, false);

//Find IP
GetClientAuthString(target, szID, sizeof(szID));
GetClientIP(client, target, sizeof(UserIP));

Last edited by bally; 09-14-2015 at 11:59.
bally is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 09-14-2015 , 13:57   Re: Admin Gets Player's IP?
Reply With Quote #4

Quote:
Originally Posted by keyboard1333 View Post
Try this? ^_^

PHP Code:
public OnPluginStart() {
    
LoadTranslations("common.phrases");
    
RegAdminCmd("sm_ip"Command_GetIpADMFLAG_BAN"sm_ip <name or #userid>");
}

public 
Action:Command_GetIp(clientargs) {
    if(
args 1) {
        
ReplyToCommand(client"[SM] Usage : sm_ip <name or #userid>");
        return 
Plugin_Handled;    
    }
    
    
char arg[32];
    
GetCmdArg(1argsizeof(arg));
    
    
int target FindTarget(clientarg);
    if(
target == -1) {
        return 
Plugin_Handled;
    }
    
    
char ip[17], name[32];
    
GetClientIP(targetipsizeof(ip));
    
GetClientName(targetnamesizeof(name));
    
ReplyToCommand(client"[SM] %s IP Address Is : %s"nameip);
    return 
Plugin_Handled;

Sadly When i Use This one I get this in compile :
Code:
/groups/sourcemod/upload_tmp/textXuvaAL.sp(23) : error 035: argument type mismatch (argument 1)
and When I use This :

Quote:
Originally Posted by bally View Post
Code:
//assign variables
new String:_targ[32]; 
decl String:szID[21], String:szIP[32]

//Get commands args
GetCmdArg(1, _targ, sizeof(_targ));

// Find Target
new target = FindTarget(client, _targ, false, false);

//Find IP
GetClientAuthString(target, szID, sizeof(szID));
GetClientIP(client, target, sizeof(UserIP));
I get This Error :

Code:
/groups/sourcemod/upload_tmp/textUQVAbP.sp(23) : error 035: argument type mismatch (argument 1) /groups/sourcemod/upload_tmp/textUQVAbP.sp(30) : warning 234: symbol "GetClientAuthString" is marked as deprecated: Use GetClientAuthId  /groups/sourcemod/upload_tmp/textUQVAbP.sp(31) : error 035: argument type mismatch (argument 2) /groups/sourcemod/upload_tmp/textUQVAbP.sp(31) : error 035: argument type mismatch (argument 2) /groups/sourcemod/upload_tmp/textUQVAbP.sp(58) : warning 234: symbol "GetClientAuthString" is marked as deprecated: Use GetClientAuthId
What Should i Do?!
ambn is offline
keyboard1333
Senior Member
Join Date: Aug 2013
Old 09-14-2015 , 14:54   Re: Admin Gets Player's IP?
Reply With Quote #5

Quote:
Originally Posted by ambn View Post
Sadly When i Use This one I get this in compile :
Code:
/groups/sourcemod/upload_tmp/textXuvaAL.sp(23) : error 035: argument type mismatch (argument 1)
Works fine for me when I compile it.
- Did you make any changes to it?
- What version of Sourcemod are you running?
keyboard1333 is offline
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-14-2015 , 15:53   Re: Admin Gets Player's IP?
Reply With Quote #6

Quote:
Originally Posted by keyboard1333 View Post
Works fine for me when I compile it.
- Did you make any changes to it?
- What version of Sourcemod are you running?
Since it says GetClientAuthString is deprecated, hes probably running 1.6
__________________
SourcePawn Coding Level: Novice
DJ Data is offline
keyboard1333
Senior Member
Join Date: Aug 2013
Old 09-14-2015 , 16:24   Re: Admin Gets Player's IP?
Reply With Quote #7

You might have to compile on >=1.7 for it to work. (otherwise I got no clue)

Last edited by keyboard1333; 09-14-2015 at 18:54.
keyboard1333 is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 09-14-2015 , 18:08   Re: Admin Gets Player's IP?
Reply With Quote #8

https://spider.limetech.org/

Last edited by Potato Uno; 09-14-2015 at 18:09.
Potato Uno is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-14-2015 , 18:41   Re: Admin Gets Player's IP?
Reply With Quote #9

Quote:
Originally Posted by DJ Data View Post
Since it says GetClientAuthString is deprecated, hes probably running 1.6
GetClientAuthString isn't suddenly going to be undeprecated in 1.7 or newer. If anything, it'd be removed outright.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 09-14-2015 , 19:00   Re: Admin Gets Player's IP?
Reply With Quote #10

Not sure why bally's code is getting the target's SteamId 32 in the first place...But, if you are looking for their SteamId 32 use GetClientAuthId(clientIndex, AuthId_Steam2, buffer, sizeof(buffer));
Darkness_ is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:22.


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