That won't work properly. Here's my version (tested and works):
PHP Code:
#include <amxmodx>
#include <amxmisc>
#define SNAPSHOT_DELAY 0.5
#define SNAPSHOT_ALL 33
#define TASK_SNAPSHOT 997884
public plugin_init()
{
register_plugin("Take Snapshot", "1.0", "OciXCrom")
register_concmd("amx_snapshot", "SnapshotCommand", ADMIN_SLAY, "<nick|#userid|@ALL>")
}
public SnapshotCommand(id, iLevel, iCid)
{
if(!cmd_access(id, iLevel, iCid, 2))
return PLUGIN_HANDLED
new szArg[32]
read_argv(1, szArg, charsmax(szArg))
if(equali(szArg, "@all"))
{
new szTime[32], szName[32]
get_time("%X @ %x", szTime, charsmax(szTime))
get_user_name(id, szName, charsmax(szName))
client_print(0, print_chat, "[%s] Admin %s took a snapshot of ALL players.", szTime, szName)
log_amx("Admin %s took a snapshot of ALL players.", szName)
set_task(SNAPSHOT_DELAY, "TakeSnapshot", SNAPSHOT_ALL + TASK_SNAPSHOT)
}
else
{
new iPlayer = cmd_target(id, szArg, CMDTARGET_ALLOW_SELF)
if(!iPlayer)
return PLUGIN_HANDLED
new szTime[32], szName[2][32]
get_time("%X @ %x", szTime, charsmax(szTime))
get_user_name(id, szName[0], charsmax(szName[]))
get_user_name(iPlayer, szName[1], charsmax(szName[]))
client_print(iPlayer, print_chat, "[%s] Admin %s took a snapshot of YOU [%s]", szTime, szName[0], szName[1])
log_amx("Admin %s took a snapshot of %s", szName[0], szName[1])
set_task(SNAPSHOT_DELAY, "TakeSnapshot", iPlayer + TASK_SNAPSHOT)
}
return PLUGIN_HANDLED
}
public TakeSnapshot(id)
{
id -= TASK_SNAPSHOT
client_cmd(id == SNAPSHOT_ALL ? 0 : id, "snapshot")
}
@EFFx:
1.
new iArg[11] -- Should be 32, because this can also be a player's name. You don't need to have two arguments. What's the chance of a player being named "@all"? It just makes the command harder to use.
2.
"[AMXX] ScreenShot time: %d" -- %d should be %s.
3.
new target = cmd_target(id, iTarget, CMDTARGET_ALLOW_SELF) -- You didn't check if the player is valid after using this, so you can easily force the server to take the snapshot.
4. You'll need to delay
client_cmd in order for the chat message to appear on the screenshot.
5. Also, why are you using "i" for strings and "sz" for integers? i = integer, sz = string. It's confusing.
6. You shold use charsmax instead of typing the length by yourself.
__________________