Senior Member
Join Date: Jan 2015
Location: Black Mesa
|
09-13-2017
, 13:27
Re: sm_last
|
#12
|
Spoiler
Quote:
Originally Posted by PinHeaDi
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];
Format(name, sizeof(name), "Nick"); Format(ip, sizeof(ip), "IP"); Format(steamid, sizeof(steamid), "SteamID"); 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)); if (IsPlayerGenericAdmin(iClient)) { PrintToConsole(iClient, "ID: %s | Name: %s | SteamID: %s | IP: %s", GetClientUserId(i), name, steamid, ip); } else { PrintToConsole(iClient, "ID: %s | Name: %s | SteamID: %s | IP: ADMINS ONLY", GetClientUserId(i), name, steamid); } } } 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_GENERIC, false); }
PHP Code:
RegConsoleCmd("sm_list", Command_List, "Shows player list");
sm_listt is not working properly.
|
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.
|
|