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

[REQ] Snapshot of all players


Post New Thread Reply   
 
Thread Tools Display Modes
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 12-15-2016 , 13:38   Re: [REQ] Snapshot of all players
Reply With Quote #11

Quote:
Originally Posted by OciXCrom View Post
Display the message first, then take the screenshot. I assume there will be a little delay when executing the command, so delay the message as well.

Oh, you're right, i forgot that thing.

Try the code again.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-15-2016 , 14:33   Re: [REQ] Snapshot of all players
Reply With Quote #12

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(idiLeveliCid)
{
    if(!
cmd_access(idiLeveliCid2))
        return 
PLUGIN_HANDLED
        
    
new szArg[32]
    
read_argv(1szArgcharsmax(szArg))
    
    if(
equali(szArg"@all"))
    {
        new 
szTime[32], szName[32]
        
get_time("%X @ %x"szTimecharsmax(szTime))
        
get_user_name(idszNamecharsmax(szName))
        
client_print(0print_chat"[%s] Admin %s took a snapshot of ALL players."szTimeszName)
        
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(idszArgCMDTARGET_ALLOW_SELF)
        
        if(!
iPlayer)
            return 
PLUGIN_HANDLED
            
        
new szTime[32], szName[2][32]
        
get_time("%X @ %x"szTimecharsmax(szTime))
        
get_user_name(idszName[0], charsmax(szName[]))
        
get_user_name(iPlayerszName[1], charsmax(szName[]))
        
client_print(iPlayerprint_chat"[%s] Admin %s took a snapshot of YOU [%s]"szTimeszName[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 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.
__________________

Last edited by OciXCrom; 12-15-2016 at 14:36.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 19:20.


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