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

sm_last


Post New Thread Reply   
 
Thread Tools Display Modes
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 09-13-2017 , 11:32   Re: sm_last
Reply With Quote #11

PHP Code:
#include <sourcemod>

#define MAX_PLAYERS 15
#define LAST_PLAYERS "Last disconected players"
#define LIST_PLAYERS "Currently playing"

ArrayList g_hList;

public 
Plugin myinfo =   
{  
    
name "Mashiro",  
    
author "Instinct",  
    
description "Test",  
    
version "1.0",  
    
url "..."  
};  

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_last"Command_Last"Shows disconnected list"); 
    
RegConsoleCmd("sm_list"Command_List"Shows player list"); 
}

public 
void OnClientDisconnect(int iClient)
{
    if(
g_hList == null)
    {
        
g_hList = new ArrayList();
    }
    
    if(
g_hList.Length >= MAX_PLAYERS)
    {
        
delete view_as<StringMap>(g_hList.Get(0));
        
g_hList.Erase(0);
    }
    
    
char name[MAX_NAME_LENGTH];
    
GetClientName(iClientnamesizeof(name));

    
char ip[32];
    
GetClientIP(iClientipsizeof(ip));
    
    
char steamid[32];
    
GetClientAuthId(iClientAuthId_Steam2steamidsizeof(steamid));

    
StringMap map CreateStringMap(namesteamidip);
    
g_hList.Push(map);
}

public 
Action Command_Last(int iClientint iArgs
{
    if(
g_hList == null)
    {
        return 
Plugin_Handled;
    }

    
char name[MAX_NAME_LENGTH];
    
char ip[32];
    
char steamid[32];

    if (
g_hList.Length == 0)
    {
        
PrintToConsole(iClient"+----------------------- %s -----------------------+"LAST_PLAYERS);
        
PrintToConsole(iClient"[iPlay.bg] There are no disconnected players yet!");
        
PrintToConsole(iClient"+------------------------------------------------------------------------+");
    }
    else
    {
        
PrintToConsole(iClient"+----------------------- %s -----------------------+"LAST_PLAYERS);
        for(
int ig_hList.Lengthi++)    
        {    
            
StringMap map g_hList.Get(i);
        
            
map.GetString("name"namesizeof(name));
            
map.GetString("ip"ipsizeof(ip));
            
map.GetString("steamid"steamidsizeof(steamid));
                        
            if (
IsPlayerGenericAdmin(iClient))
            {     
                
PrintToConsole(iClient"Name: %s | SteamID: %s | IP: %s"namesteamidip);  
            }
            else
            {
                
PrintToConsole(iClient"Name: %s | SteamID: %s | IP: ADMINS ONLY"namesteamid); 
            }    
        }
        
PrintToConsole(iClient"+------------------------------------------------------------------------+");
    }

    return 
Plugin_Handled
}

public 
Action Command_List(int iClientint iArgs
{
    
decl String:name[64], String:ip[24], String:steamid[24];

    
Format(namesizeof(name), "Nick");
    
Format(ipsizeof(ip), "IP");
    
Format(steamidsizeof(steamid), "SteamID");
    
    
PrintToConsole(iClient"+----------------------- %s -----------------------+"LIST_PLAYERS);
    for (new 
1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        {
            
GetClientName(inamesizeof(name));
            
GetClientIP(iipsizeof(ip));
            
GetClientAuthId(iAuthId_Steam2steamidsizeof(steamid));
        
            if (
IsPlayerGenericAdmin(iClient))
            {     
                
PrintToConsole(iClient"ID: %s | Name: %s | SteamID: %s | IP: %s"GetClientUserId(i), namesteamidip);  
            }
            else
            {
                
PrintToConsole(iClient"ID: %s | Name: %s | SteamID: %s | IP: ADMINS ONLY"GetClientUserId(i), namesteamid); 
            }
        }
    }
    
PrintToConsole(iClient"+------------------------------------------------------------------------+");
}

StringMap CreateStringMap(const char[] playerName, const char[] steamid, const char[] ip)
{
    
StringMap map = new StringMap();
    
map.SetString("name"playerName);
    
map.SetString("steamid"steamid);
    
map.SetString("ip"ip);
    return 
map;
}  

bool:IsPlayerGenericAdmin(iClient

    return 
CheckCommandAccess(iClient"generic_admin"ADMFLAG_GENERICfalse); 

PHP Code:
RegConsoleCmd("sm_list"Command_List"Shows player list"); 
sm_listt is not working properly.
__________________

Last edited by PinHeaDi; 09-13-2017 at 12:50.
PinHeaDi is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-13-2017 , 13:27   Re: sm_last
Reply With Quote #12

Spoiler



1. Include how it should be working and whats not working properly.
2. Is it compiling clean?
3. Have you checked your error logs?

Last edited by Halt; 09-13-2017 at 13:28.
Halt is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 09-13-2017 , 13:33   Re: sm_last
Reply With Quote #13

Spoiler


So this is the final edit, the sm_list (list ingame players) works so far, but a strange thing happens when the map is changed - at new map when you type sm_last (see last disconnected players) it shows a list of the players in the server like if I used sm_list, but when I unload and load the plugin again the problem is gone.

PHP Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// last.sp
//
// C:\Users\SSadistic\Desktop\SMCompile\last.sp(21) : warning 217: loose indentation
// C:\Users\SSadistic\Desktop\SMCompile\last.sp(64) : warning 217: loose indentation
// C:\Users\SSadistic\Desktop\SMCompile\last.sp(65) : warning 217: loose indentation
// C:\Users\SSadistic\Desktop\SMCompile\last.sp(74) : warning 217: loose indentation
// Code size:             5504 bytes
// Data size:             3204 bytes
// Stack/heap size:      16384 bytes
// Total requirements:   25092 bytes
//
// 4 Warnings.
//
// Compilation Time: 0,23 sec
// ----------------------------------------

Press enter to exit ... 
PHP Code:
L 09/13/2017 15:50:54SourceMod error session started
L 09
/13/2017 15:50:54Info (map "de_dust2") (file "errors_20170913.log")
L 09/13/2017 15:50:54: [SMException reportedClient 17 is not connected
L 09
/13/2017 15:50:54: [SMBlaminglast.smx
L 09
/13/2017 15:50:54: [SMCall stack trace:
L 09/13/2017 15:50:54: [SM]   [0GetClientName
L 09
/13/2017 15:50:54: [SM]   [1Line 106C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 15:51:13: [SMException reportedClient 18 is not connected
L 09
/13/2017 15:51:13: [SMBlaminglast.smx
L 09
/13/2017 15:51:13: [SMCall stack trace:
L 09/13/2017 15:51:13: [SM]   [0GetClientName
L 09
/13/2017 15:51:13: [SM]   [1Line 106C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 15:51:13: [SMException reportedClient 18 is not connected
L 09
/13/2017 15:51:13: [SMBlaminglast.smx
L 09
/13/2017 15:51:13: [SMCall stack trace:
L 09/13/2017 15:51:13: [SM]   [0GetClientName
L 09
/13/2017 15:51:13: [SM]   [1Line 106C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 15:52:01: [SMException reportedClient 18 is not connected
L 09
/13/2017 15:52:01: [SMBlaminglast.smx
L 09
/13/2017 15:52:01: [SMCall stack trace:
L 09/13/2017 15:52:01: [SM]   [0GetClientName
L 09
/13/2017 15:52:01: [SM]   [1Line 106C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 15:52:55: [SMException reportedClient 18 is not connected
L 09
/13/2017 15:52:55: [SMBlaminglast.smx
L 09
/13/2017 15:52:55: [SMCall stack trace:
L 09/13/2017 15:52:55: [SM]   [0GetClientName
L 09
/13/2017 15:52:55: [SM]   [1Line 105C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 15:53:06: [SMException reportedClient 18 is not connected
L 09
/13/2017 15:53:06: [SMBlaminglast.smx
L 09
/13/2017 15:53:06: [SMCall stack trace:
L 09/13/2017 15:53:06: [SM]   [0GetClientName
L 09
/13/2017 15:53:06: [SM]   [1Line 105C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 15:53:18: [SMException reportedClient 17 is not connected
L 09
/13/2017 15:53:18: [SMBlaminglast.smx
L 09
/13/2017 15:53:18: [SMCall stack trace:
L 09/13/2017 15:53:18: [SM]   [0GetClientName
L 09
/13/2017 15:53:18: [SM]   [1Line 105C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 16:03:04: [SMException reportedClient 5 is not connected
L 09
/13/2017 16:03:04: [SMBlaminglast.smx
L 09
/13/2017 16:03:04: [SMCall stack trace:
L 09/13/2017 16:03:04: [SM]   [0GetClientName
L 09
/13/2017 16:03:04: [SM]   [1Line 105C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 16:03:10: [SMException reportedClient 5 is not connected
L 09
/13/2017 16:03:10: [SMBlaminglast.smx
L 09
/13/2017 16:03:10: [SMCall stack trace:
L 09/13/2017 16:03:10: [SM]   [0GetClientName
L 09
/13/2017 16:03:10: [SM]   [1Line 105C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 16:07:59Error log file session closed.
L 09/13/2017 16:10:24SourceMod error session started
L 09
/13/2017 16:10:24Info (map "de_dust2") (file "errors_20170913.log")
L 09/13/2017 16:10:24: [SMException reportedClient 2 is not connected
L 09
/13/2017 16:10:24: [SMBlaminglast.smx
L 09
/13/2017 16:10:24: [SMCall stack trace:
L 09/13/2017 16:10:24: [SM]   [0GetClientName
L 09
/13/2017 16:10:24: [SM]   [1Line 107C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 16:10:41: [SMException reportedClient 2 is not connected
L 09
/13/2017 16:10:41: [SMBlaminglast.smx
L 09
/13/2017 16:10:41: [SMCall stack trace:
L 09/13/2017 16:10:41: [SM]   [0GetClientName
L 09
/13/2017 16:10:41: [SM]   [1Line 107C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 16:11:36: [SMException reportedClient 2 is not connected
L 09
/13/2017 16:11:36: [SMBlaminglast.smx
L 09
/13/2017 16:11:36: [SMCall stack trace:
L 09/13/2017 16:11:36: [SM]   [0GetClientName
L 09
/13/2017 16:11:36: [SM]   [1Line 107C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 16:42:30Error log file session closed.
L 09/13/2017 18:28:59SourceMod error session started
L 09
/13/2017 18:28:59Info (map "de_dust2") (file "errors_20170913.log")
L 09/13/2017 18:28:59: [SMException reportedClient 4 is not connected
L 09
/13/2017 18:28:59: [SMBlaminglast.smx
L 09
/13/2017 18:28:59: [SMCall stack trace:
L 09/13/2017 18:28:59: [SM]   [0GetClientName
L 09
/13/2017 18:28:59: [SM]   [1Line 101C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 18:30:19: [SMException reportedClient 5 is not connected
L 09
/13/2017 18:30:19: [SMBlaminglast.smx
L 09
/13/2017 18:30:19: [SMCall stack trace:
L 09/13/2017 18:30:19: [SM]   [0GetClientName
L 09
/13/2017 18:30:19: [SM]   [1Line 101C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 18:33:56: [SMException reportedClient 9 is not connected
L 09
/13/2017 18:33:56: [SMBlaminglast.smx
L 09
/13/2017 18:33:56: [SMCall stack trace:
L 09/13/2017 18:33:56: [SM]   [0GetClientName
L 09
/13/2017 18:33:56: [SM]   [1Line 101C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 19:02:08Error log file session closed.
L 09/13/2017 19:38:26SourceMod error session started
L 09
/13/2017 19:38:26Info (map "de_dust2") (file "errors_20170913.log")
L 09/13/2017 19:38:26: [SMException reportedClient 4 is not connected
L 09
/13/2017 19:38:26: [SMBlaminglast.smx
L 09
/13/2017 19:38:26: [SMCall stack trace:
L 09/13/2017 19:38:26: [SM]   [0GetClientName
L 09
/13/2017 19:38:26: [SM]   [1Line 103C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 19:38:40: [SMException reportedClient 8 is not connected
L 09
/13/2017 19:38:40: [SMBlaminglast.smx
L 09
/13/2017 19:38:40: [SMCall stack trace:
L 09/13/2017 19:38:40: [SM]   [0GetClientName
L 09
/13/2017 19:38:40: [SM]   [1Line 103C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 19:39:01: [SMException reportedClient 4 is not connected
L 09
/13/2017 19:39:01: [SMBlaminglast.smx
L 09
/13/2017 19:39:01: [SMCall stack trace:
L 09/13/2017 19:39:01: [SM]   [0GetClientName
L 09
/13/2017 19:39:01: [SM]   [1Line 103C:\Users\SSadistic\Desktop\SMCompile\last.sp::Command_List
L 09
/13/2017 19:47:37Error log file session closed
This log is after the final edit, I don't see any error now, but still that all the errors from the plugin.
__________________

Last edited by PinHeaDi; 09-13-2017 at 13:38.
PinHeaDi is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-13-2017 , 13:43   Re: sm_last
Reply With Quote #14

Loose indentations don't bug you?

Perhaps it is because all players were disconnected to change maps? Not sure how map changes work (if it reconnects all clients or not) but if you're plugin is returning a list of all players on the server who were there before the map change its likely to be the issue.

Tell me this after a map change don't reload the plugin, just have a single player disconnect and see if it returns that players info.
Halt is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 09-13-2017 , 14:47   Re: sm_last
Reply With Quote #15

So the map changed and:

PHP Code:
sm_last
+----------------------- Last disconected players -----------------------+
NameDanibg231 SteamIDSTEAM_1:0:202568530 IPXX.XXX.XXX.XX
Name
MARTOproBG SteamIDSTEAM_1:0:171740010 IPXX.XXX.XXX.XX
Name
Minecraftbg_04 SteamIDSTEAM_1:0:117780779 IPXX.XXX.XXX.XX
Name
FrotZT SteamIDSTEAM_1:0:194443285 IPXX.XXX.XXX.XX
Name
DANNYTO&#65083;デ╦───═ | SteamID: STEAM_1:0:125811940 | IP: XX.XXX.XXX.XX
NameMuTaKa_MJlaTu hellcase.com SteamIDSTEAM_1:0:47030519 IPXX.XXX.XXX.XX
Name
Ko3a MocTpa SteamIDSTEAM_1:0:62219772 IPXX.XXX.XXX.XX
Name
nasko.maslarski SteamIDSTEAM_1:1:197966119 IPXX.XXX.XXX.XX
Name
: &#11783;ᴴᴱ HUИTΞƦ | SteamID: STEAM_1:1:43707767 | IP: XX.XXX.XXX.XX
Name: &#10026; ИСУС | SteamID: STEAM_1:0:99405206 | IP: XX.XXX.XXX.XX
Name: .I. | SteamIDSTEAM_1:0:210188181 IPXX.XXX.XXX.XX
Name
duk jesus SteamIDSTEAM_1:0:199120936 IPXX.XXX.XXX.XX
Name
jokera SteamIDSTEAM_1:0:202128605 IPXX.XXX.XXX.XX
Name
zAlessio pvpro.com SteamIDSTEAM_1:0:146060805 IPXX.XXX.XXX.XX
Name
B00M  LIFE IS BITCH SteamIDSTEAM_1:1:82659633 IPXX.XXX.XXX.XX
+------------------------------------------------------------------------+
sm_list
+------------------------- Currently playing -------------------------+
 
1094 Namevan1sher |me Makaveli| | SteamIDSTEAM_1:1:79999106 IPXX.XXX.XXX.XX 
 1095 
Nametedchook SteamIDSTEAM_1:0:59867026 IPXX.XXX.XXX.XX
 1072 
NameDanibg231 SteamIDSTEAM_1:0:202568530 IPXX.XXX.XXX.XX
 1079 
NameMARTOproBG SteamIDSTEAM_1:0:171740010 IPXX.XXX.XXX.XX
 1096 
NameMinecraftbg_04 SteamIDSTEAM_1:0:117780779 IPXX.XXX.XXX.XX
 1066 
NameDANNYTO&#65083;デ╦───═ | SteamID: STEAM_1:0:125811940 | IP: XX.XXX.XXX.XX
 
1059 NameMuTaKa_MJlaTu hellcase.com SteamIDSTEAM_1:0:47030519 IPXX.XXX.XXX.XX
 1087 
NameKo3a MocTpa SteamIDSTEAM_1:0:62219772 IPXX.XXX.XXX.XX
 1088 
Namenasko.maslarski SteamIDSTEAM_1:1:197966119 IPXX.XXX.XXX.XX
 1098 
Name: &#11783;ᴴᴱ HUИTΞƦ | SteamID: STEAM_1:1:43707767 | IP: XX.XXX.XXX.XX
 
1092 Name: &#10026; ИСУС | SteamID: STEAM_1:0:99405206 | IP: XX.XXX.XXX.XX
 
1046 Nameduk jesus SteamIDSTEAM_1:0:199120936 IPXX.XXX.XXX.XX
 1100 
NamezAlessio pvpro.com SteamIDSTEAM_1:0:146060805 IPXX.XXX.XXX.XX
 1049 
NameB00M  LIFE IS BITCH SteamIDSTEAM_1:1:82659633 IPXX.XXX.XXX.XX
+------------------------------------------------------------------------+ 
When someone disconnects it's been added to the list as it should be, but still on the beginning on the map the last disconnected list is full without anyone disconnecting. No error logs.

Maybe if I add:

PHP Code:
public void OnMapEnd() 
{
    
g_hList null;

It won't store the list on map change. Or even OnMapStart, since it still can bug I can, if someone leaves just on map ending.
__________________

Last edited by PinHeaDi; 09-13-2017 at 15:05.
PinHeaDi 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 06:23.


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