Senior Member
Join Date: Jul 2013
Location: Bulgaria
09-13-2017
, 13:33
Re: sm_last
#13
Spoiler
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 ( iClient , name , sizeof ( name )); char ip [ 32 ]; GetClientIP ( iClient , ip , sizeof ( ip )); char steamid [ 32 ]; GetClientAuthId ( iClient , AuthId_Steam2 , steamid , sizeof ( steamid )); StringMap map = CreateStringMap ( name , steamid , ip ); g_hList . Push ( map ); } public Action Command_Last ( int iClient , int 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 i ; i < g_hList . Length ; i ++) { StringMap map = g_hList . Get ( i ); map . GetString ( "name" , name , sizeof ( name )); map . GetString ( "ip" , ip , sizeof ( ip )); map . GetString ( "steamid" , steamid , sizeof ( steamid )); if ( IsPlayerGenericAdmin ( iClient )) { PrintToConsole ( iClient , "Name: %s | SteamID: %s | IP: %s" , name , steamid , ip ); } else { PrintToConsole ( iClient , "Name: %s | SteamID: %s | IP: ADMINS ONLY" , name , steamid ); } } PrintToConsole ( iClient , "+------------------------------------------------------------------------+" ); } return Plugin_Handled ; } public Action Command_List ( int iClient , int iArgs ) { decl String : name [ 64 ], String : ip [ 24 ], String : steamid [ 24 ], String : userid [ 12 ]; Format ( name , sizeof ( name ), "Nick" ); Format ( ip , sizeof ( ip ), "IP" ); Format ( steamid , sizeof ( steamid ), "SteamID" ); Format ( userid , sizeof ( userid ), "UserID" ); PrintToConsole ( iClient , "+------------------------- %s -------------------------+" , LIST_PLAYERS ); for (new i = 1 ; i <= MaxClients ; i ++) { if( IsClientInGame ( i ) && ! IsFakeClient ( i )) { GetClientName ( i , name , sizeof ( name )); GetClientIP ( i , ip , sizeof ( ip )); GetClientAuthId ( i , AuthId_Steam2 , steamid , sizeof ( steamid )); IntToString ( GetClientUserId ( i ), userid , sizeof ( userid )); if ( IsPlayerGenericAdmin ( iClient )) { PrintToConsole ( iClient , " %s | Name: %s | SteamID: %s | IP: %s" , userid , name , steamid , ip ); } else { PrintToConsole ( iClient , " %s | Name: %s | SteamID: %s | IP: ADMINS ONLY" , userid , name , steamid ); } } } PrintToConsole ( iClient , "+------------------------------------------------------------------------+" ); return Plugin_Handled ; } 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_GENERIC , false ); }
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 : 54 : SourceMod error session started L 09 / 13 / 2017 - 15 : 50 : 54 : Info ( map "de_dust2" ) ( file "errors_20170913.log" ) L 09 / 13 / 2017 - 15 : 50 : 54 : [ SM ] Exception reported : Client 17 is not connected L 09 / 13 / 2017 - 15 : 50 : 54 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 15 : 50 : 54 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 15 : 50 : 54 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 15 : 50 : 54 : [ SM ] [ 1 ] Line 106 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] Exception reported : Client 18 is not connected L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] [ 1 ] Line 106 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] Exception reported : Client 18 is not connected L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 15 : 51 : 13 : [ SM ] [ 1 ] Line 106 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 15 : 52 : 01 : [ SM ] Exception reported : Client 18 is not connected L 09 / 13 / 2017 - 15 : 52 : 01 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 15 : 52 : 01 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 15 : 52 : 01 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 15 : 52 : 01 : [ SM ] [ 1 ] Line 106 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 15 : 52 : 55 : [ SM ] Exception reported : Client 18 is not connected L 09 / 13 / 2017 - 15 : 52 : 55 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 15 : 52 : 55 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 15 : 52 : 55 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 15 : 52 : 55 : [ SM ] [ 1 ] Line 105 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 15 : 53 : 06 : [ SM ] Exception reported : Client 18 is not connected L 09 / 13 / 2017 - 15 : 53 : 06 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 15 : 53 : 06 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 15 : 53 : 06 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 15 : 53 : 06 : [ SM ] [ 1 ] Line 105 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 15 : 53 : 18 : [ SM ] Exception reported : Client 17 is not connected L 09 / 13 / 2017 - 15 : 53 : 18 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 15 : 53 : 18 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 15 : 53 : 18 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 15 : 53 : 18 : [ SM ] [ 1 ] Line 105 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 16 : 03 : 04 : [ SM ] Exception reported : Client 5 is not connected L 09 / 13 / 2017 - 16 : 03 : 04 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 16 : 03 : 04 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 16 : 03 : 04 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 16 : 03 : 04 : [ SM ] [ 1 ] Line 105 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 16 : 03 : 10 : [ SM ] Exception reported : Client 5 is not connected L 09 / 13 / 2017 - 16 : 03 : 10 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 16 : 03 : 10 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 16 : 03 : 10 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 16 : 03 : 10 : [ SM ] [ 1 ] Line 105 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 16 : 07 : 59 : Error log file session closed . L 09 / 13 / 2017 - 16 : 10 : 24 : SourceMod error session started L 09 / 13 / 2017 - 16 : 10 : 24 : Info ( map "de_dust2" ) ( file "errors_20170913.log" ) L 09 / 13 / 2017 - 16 : 10 : 24 : [ SM ] Exception reported : Client 2 is not connected L 09 / 13 / 2017 - 16 : 10 : 24 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 16 : 10 : 24 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 16 : 10 : 24 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 16 : 10 : 24 : [ SM ] [ 1 ] Line 107 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 16 : 10 : 41 : [ SM ] Exception reported : Client 2 is not connected L 09 / 13 / 2017 - 16 : 10 : 41 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 16 : 10 : 41 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 16 : 10 : 41 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 16 : 10 : 41 : [ SM ] [ 1 ] Line 107 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 16 : 11 : 36 : [ SM ] Exception reported : Client 2 is not connected L 09 / 13 / 2017 - 16 : 11 : 36 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 16 : 11 : 36 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 16 : 11 : 36 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 16 : 11 : 36 : [ SM ] [ 1 ] Line 107 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 16 : 42 : 30 : Error log file session closed . L 09 / 13 / 2017 - 18 : 28 : 59 : SourceMod error session started L 09 / 13 / 2017 - 18 : 28 : 59 : Info ( map "de_dust2" ) ( file "errors_20170913.log" ) L 09 / 13 / 2017 - 18 : 28 : 59 : [ SM ] Exception reported : Client 4 is not connected L 09 / 13 / 2017 - 18 : 28 : 59 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 18 : 28 : 59 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 18 : 28 : 59 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 18 : 28 : 59 : [ SM ] [ 1 ] Line 101 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 18 : 30 : 19 : [ SM ] Exception reported : Client 5 is not connected L 09 / 13 / 2017 - 18 : 30 : 19 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 18 : 30 : 19 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 18 : 30 : 19 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 18 : 30 : 19 : [ SM ] [ 1 ] Line 101 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 18 : 33 : 56 : [ SM ] Exception reported : Client 9 is not connected L 09 / 13 / 2017 - 18 : 33 : 56 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 18 : 33 : 56 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 18 : 33 : 56 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 18 : 33 : 56 : [ SM ] [ 1 ] Line 101 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 19 : 02 : 08 : Error log file session closed . L 09 / 13 / 2017 - 19 : 38 : 26 : SourceMod error session started L 09 / 13 / 2017 - 19 : 38 : 26 : Info ( map "de_dust2" ) ( file "errors_20170913.log" ) L 09 / 13 / 2017 - 19 : 38 : 26 : [ SM ] Exception reported : Client 4 is not connected L 09 / 13 / 2017 - 19 : 38 : 26 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 19 : 38 : 26 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 19 : 38 : 26 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 19 : 38 : 26 : [ SM ] [ 1 ] Line 103 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 19 : 38 : 40 : [ SM ] Exception reported : Client 8 is not connected L 09 / 13 / 2017 - 19 : 38 : 40 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 19 : 38 : 40 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 19 : 38 : 40 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 19 : 38 : 40 : [ SM ] [ 1 ] Line 103 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 19 : 39 : 01 : [ SM ] Exception reported : Client 4 is not connected L 09 / 13 / 2017 - 19 : 39 : 01 : [ SM ] Blaming : last . smx L 09 / 13 / 2017 - 19 : 39 : 01 : [ SM ] Call stack trace : L 09 / 13 / 2017 - 19 : 39 : 01 : [ SM ] [ 0 ] GetClientName L 09 / 13 / 2017 - 19 : 39 : 01 : [ SM ] [ 1 ] Line 103 , C :\ Users \ SSadistic \ Desktop \ SMCompile \ last . sp :: Command_List L 09 / 13 / 2017 - 19 : 47 : 37 : Error 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 .