Raised This Month: $32 Target: $400
 8% 

sm_ip update


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jeezybox
Junior Member
Join Date: Dec 2019
Old 12-11-2019 , 17:33   sm_ip update
Reply With Quote #1

Hello,

I need to find where is this command stored in the sourcemod files, I order the list of IP.

For example, we are having a lot of players, when I type sm_ip, I want to order the list by IP.

Best Regards
jeezybox is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-12-2019 , 06:37   Re: sm_ip update
Reply With Quote #2

You are using a custom plugin. Maybe tell us which one? There's no sm_ip command in the default sourcemod plugins.
__________________
Ilusion9 is offline
jeezybox
Junior Member
Join Date: Dec 2019
Old 12-12-2019 , 14:04   Re: sm_ip update
Reply With Quote #3

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public OnPluginStart()
{
	CreateConVar("Sm IP", "1.0", "Window");
	RegConsoleCmd("sm_ip", CmdIp);
}
public Action:CmdIp(client, args)
{
	if(!IsClientInGame(client))
		return Plugin_Continue;

	new ilee = 0;
	PrintToConsole(client, "IP graczy grajacych na serwerze:");
	for(new i = 1, max = GetMaxClients(); i <= max; ++ i)
	{
		if(IsClientInGame(i))
		{
			new String:nazwa_gracza[65];
			new String:ip_gracza[65];
			GetClientName(i, nazwa_gracza[i], 64);
			GetClientIP(i, ip_gracza[i], 64);

			PrintToConsole(client, "%d) %s - %s.", i, nazwa_gracza[i], ip_gracza[i]);
			ilee = i;
		}
	}

	PrintToConsole(client, "Wszystkich graczy: %d.", ilee);
	return Plugin_Continue;
}
Okay, this is the code, how can I order the IPs, I want to order the IPs so I can detect people with same IP playing in opposite teams. This will be much easier if console outputs ordered IP.
jeezybox is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-12-2019 , 15:25   Re: sm_ip update
Reply With Quote #4

You can use some "Sort" functions from Sourcemod

https://sm.alliedmods.net/new-api/sorting/SortStrings

Functions
SortADTArray
SortADTArrayCustom
SortCustom1D
SortCustom2D
SortFloats
SortIntegers
SortStrings
__________________
Marttt is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-13-2019 , 06:59   Re: sm_ip update
Reply With Quote #5

try this:

PHP Code:

#include <sourcemod>
#include <sdktools>
#include <cstrike>

enum struct PlayerInfo
{
    
char name[MAX_NAME_LENGTH];
    
char ip[65];
}

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_ip"Command_IP);
}

public 
Action Command_IP(int clientint args)
{
    
ArrayList listPlayers = new ArrayList(sizeof(PlayerInfo));
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            
PlayerInfo info;
            
GetClientName(iinfo.namesizeof(PlayerInfo::name));
            
GetClientIP(iinfo.ipsizeof(PlayerInfo::ip));
            
listPlayers.PushArray(info);
        }
    }
    
    
listPlayers.SortCustom(sortPlayers);
    
    
PrintToConsole(client"IP graczy grajacych na serwerze:");
    for (
int i 0listPlayers.Lengthi++)
    {
        
PlayerInfo info;
        
listPlayers.GetArray(iinfo);
        
PrintToConsole(client"%d) %s - %s."1info.nameinfo.ip);
    }

    
PrintToConsole(client"Wszystkich graczy: %d."listPlayers.Length);
    
delete listPlayers;
    
    return 
Plugin_Handled;
}


public 
int sortPlayers(int index1int index2Handle array, Handle hndl)
{
    
PlayerInfo info1info2;
    
view_as<ArrayList>(array).GetArray(index1info1);
    
view_as<ArrayList>(array).GetArray(index2info2);
    
    return 
strcmp(info1.ipinfo2.ip);

__________________
Ilusion9 is offline
Reply


Thread Tools
Display Modes

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 13:59.


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