PHP Code:
#include <amxmodx>
#include <chatcolor>
#define MAX_MAPS 5
new g_szMapNames[MAX_MAPS][32]
public plugin_init()
{
register_plugin("last played maps", "0.3.0", "ConnorMcLeod")
register_clcmd("amx_lastmaps", "lastmapsCmd")
register_clcmd("say /lastmaps", "lastmapsSayCmd")
}
public plugin_cfg()
{
new szLastMapsFile[64]
get_localinfo("amxx_configsdir", szLastMapsFile, charsmax(szLastMapsFile))
add(szLastMapsFile, charsmax(szLastMapsFile), "/lastmaps.txt")
new File = fopen(szLastMapsFile, "rt")
new i
new szTemp[32]
if(File)
{
for(i=0; i<MAX_MAPS; i++)
{
if(!feof(File))
{
fgets(File, szTemp, charsmax(szTemp))
trim(szTemp)
formatex(g_szMapNames[i], charsmax(g_szMapNames[]), szTemp)
}
}
fclose(File)
}
new szCurrentMap[32]
get_mapname(szCurrentMap, charsmax(szCurrentMap))
File = fopen(szLastMapsFile, "wt")
if(File)
{
fprintf(File, "%s^n", szCurrentMap)
for(i=0; i<MAX_MAPS-1; i++)
{
if( !copy(szCurrentMap, charsmax(szCurrentMap), g_szMapNames[i]) )
{
break
}
fprintf(File, "%s^n", szCurrentMap)
}
fclose(File)
}
}
public lastmapsCmd(id)
{
new LastMaps[256]
new n = formatex(LastMaps, charsmax(LastMaps), "Last maps played are :")
for(new i; i<MAX_MAPS; i++)
{
if(!g_szMapNames[i][0])
{
break
}
n += formatex(LastMaps[n], charsmax(LastMaps)-n, "^n%s", g_szMapNames[i])
}
client_print(id, print_console, LastMaps)
return PLUGIN_HANDLED
}
public lastmapsSayCmd(id)
{
new LastMaps[192]
new n = formatex(LastMaps, charsmax(LastMaps), "^4Last maps played are :^3")
for(new i; i<MAX_MAPS; i++)
{
if(!g_szMapNames[i][0])
{
LastMaps[--n] = '.'
break
}
n += formatex(LastMaps[n], charsmax(LastMaps)-n, " %s%c", g_szMapNames[i], i+1 == MAX_MAPS ? '.' : ',')
}
client_print_color(id, DontChange, LastMaps)
return PLUGIN_CONTINUE
}
__________________