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

Screenshot on death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-25-2012 , 15:23   Screenshot on death
Reply With Quote #1

the idea
take a screenshot on death (The victim only) around every 3 or 5 deaths.
I realize this is a global event, tho I thought it was possible to read it for victim only, wouldn't it be possible to do this command on the victim only as well?
so far

PHP Code:
#include <amxmodx>

public plugin_init()
{
register_event("DeathMsg" "deaTHshot" "a")
}
public 
deaTHshot(id)
{
    
client_cmd(id"screenshot");
    
client_printidprint_chat"screenshot taken");    

vamppa is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-25-2012 , 15:26   Re: Screenshot on death
Reply With Quote #2

Event functions don't have ids.
You should get the victim id with read_data(). Victim is the second parameter of DeathMsg event:
PHP Code:
new id read_data(2// victim 
__________________
<VeCo> is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-25-2012 , 19:08   Re: Screenshot on death
Reply With Quote #3

thanks, updated

PHP Code:
#include <amxmodx> 

public plugin_init() 

register_event("DeathMsg" "deaTHshot" "a"

public 
deaTHshot(id

    new 
id read_data(2// victim 
    
client_cmd(id"screenshot"); 
    
client_printidprint_chat"screenshot taken");     

how can I make it so it only takes a screenshot every 5 deaths?
vamppa is offline
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 05-25-2012 , 19:32   Re: Screenshot on death
Reply With Quote #4

Remove the id paramter from the ().

And you do it like that, tell me if you understand the code:

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define SCREENSHOT_PER_DEATHS 5

new gDeaths[33]
new 
gMaxPlayers

public plugin_init()  
{  
    
register_event("DeathMsg" "deaTHshot" "a")  
    
gMaxPlayers get_maxplayers()
}  

public 
client_connect(id)
    
gDeaths[id] = 0
    
public deaTHshot()  
{  
    new 
attacker read_data(1)
    new 
victim read_data(2
    
    if ( !( 
<= attacker <= gMaxPlayers ) || !( <= victim <= gMaxPlayers ) || !is_user_connected(attacker) || !is_user_connected(victim) )
        return 
PLUGIN_CONTINUE
        
    gDeaths
[victim]++
    
    if ( 
gDeaths[victim] % SCREENSHOT_PER_DEATHS == )
    {    
        
engclient_cmd(id"screenshot");  
        
client_printidprint_chat"Screenshot has been successfully taken.");      
    }
    
    return 
PLUGIN_CONTINUE

__________________
My Projects:

Auto-Mix (Pug): 100%

Joined the Military (a soldier now) - Inactive

Last edited by Diegorkable; 05-25-2012 at 19:35.
Diegorkable is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-25-2012 , 20:10   Re: Screenshot on death
Reply With Quote #5

Don't bother with all those checks.
Also engclient_cmd won't work.

PHP Code:
#include <amxmodx>

#define SCREENSHOT_PER_DEATHS 5

new gDeaths[33]

public 
plugin_init()
{
    
register_event("DeathMsg" "Event_DeathMsg" "a")
}

public 
client_putinserver(id)
{
    
gDeaths[id] = 0
}

public 
Event_DeathMsg()
{
    new 
id read_data(2)

    if ( ! (++
gDeaths[id] % SCREENSHOT_PER_DEATHS) )
    {
        
client_cmd(id"screenshot")
        
client_printidprint_chat"Screenshot has been successfully taken.")
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 05-25-2012 , 20:26   Re: Screenshot on death
Reply With Quote #6

lol I dont know why I changed it to engclient, rofl.
__________________
My Projects:

Auto-Mix (Pug): 100%

Joined the Military (a soldier now) - Inactive

Last edited by Diegorkable; 05-25-2012 at 20:27.
Diegorkable is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-26-2012 , 07:42   Re: Screenshot on death
Reply With Quote #7

thanks everyone, am using connors one.
works wonderful ^^
vamppa is offline
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 06:16.


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