Raised This Month: $32 Target: $400
 8% 

Task And Revive


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 10-23-2016 , 10:14   Task And Revive
Reply With Quote #1

I wanna check if user is dead after new round start for 20 seconds and then want to revive but after 20 seconds the task must be removed. How to do that.. Thanks
Awesome_man is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-23-2016 , 10:22   Re: Task And Revive
Reply With Quote #2

This should check all players?
__________________
Bugsy is offline
OGQH
Junior Member
Join Date: Jul 2016
Location: Kazakhstan, Aktau
Old 10-23-2016 , 10:29   Re: Task And Revive
Reply With Quote #3

Quote:
#define TASK_ID 2281137

set_task(_, _, id+TASK_ID....);

if(task_exists(id+TASK_ID)) remove_task(id+TASK_ID);
__________________

Last edited by OGQH; 10-23-2016 at 10:30.
OGQH is offline
Send a message via Skype™ to OGQH
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 10-23-2016 , 10:35   Re: Task And Revive
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
This should check all players?
yeah but for 20 seconds only after round start then it should remove the task till dere is next new round
Awesome_man is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-23-2016 , 10:38   Re: Task And Revive
Reply With Quote #5

@OGQH , you do not need to call task_exists() before calling remove_task(); remove_task() will only remove it if it exists. task_exists() should only be called if you actually want to know if a task with the specified id currently exists.

Quote:
Originally Posted by Awesome_man View Post
yeah but for 20 seconds only after round start then it should remove the task till dere is next new round
PHP Code:
#include <amxmodx>
#include <hamsandwich>

new const Version[] = "0.1";

new 
g_RoundStart g_pReviveSeconds;

public 
plugin_init() 
{
    
register_plugin"Revive Seconds" Version "bugsy" );
    
    
RegisterHamHam_Killed "player" "HamKilled_Post" true );
    
register_logevent"RoundStart" "1=Round_Start" );
    
    
g_pReviveSeconds register_cvar"rs_seconds" "20" );
}

public 
HamKilled_PostiPlayer )
{
    if ( ( 
get_systime() - g_RoundStart ) <= get_pcvar_numg_pReviveSeconds ) )
        
set_task0.1 "DelayRevive" iPlayer );
}

public 
RoundStart()
{
    
g_RoundStart get_systime();
}

public 
DelayReviveiPlayer )
{
    
ExecuteHamBHam_CS_RoundRespawn iPlayer );

__________________

Last edited by Bugsy; 10-23-2016 at 10:51.
Bugsy is offline
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 10-24-2016 , 08:30   Re: Task And Revive
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
@OGQH , you do not need to call task_exists() before calling remove_task(); remove_task() will only remove it if it exists. task_exists() should only be called if you actually want to know if a task with the specified id currently exists.


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

new const Version[] = "0.1";

new 
g_RoundStart g_pReviveSeconds;

public 
plugin_init() 
{
    
register_plugin"Revive Seconds" Version "bugsy" );
    
    
RegisterHamHam_Killed "player" "HamKilled_Post" true );
    
register_logevent"RoundStart" "1=Round_Start" );
    
    
g_pReviveSeconds register_cvar"rs_seconds" "20" );
}

public 
HamKilled_PostiPlayer )
{
    if ( ( 
get_systime() - g_RoundStart ) <= get_pcvar_numg_pReviveSeconds ) )
        
set_task0.1 "DelayRevive" iPlayer );
}

public 
RoundStart()
{
    
g_RoundStart get_systime();
}

public 
DelayReviveiPlayer )
{
    
ExecuteHamBHam_CS_RoundRespawn iPlayer );

Thanks Work Perfect.

But can you please tell me details for this line

Code:
if ( ( get_systime() - g_RoundStart ) <= get_pcvar_num( g_pReviveSeconds ) )
Awesome_man is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-24-2016 , 09:18   Re: Task And Revive
Reply With Quote #7

Quote:
Originally Posted by Awesome_man View Post
Thanks Work Perfect.

But can you please tell me details for this line

Code:
if ( ( get_systime() - g_RoundStart ) <= get_pcvar_num( g_pReviveSeconds ) )
It's just simple math:
Code:
if ( ( Time now - Time when round started ) <= Revive Seconds )
__________________
Bugsy is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-24-2016 , 11:16   Re: Task And Revive
Reply With Quote #8

What time is actually returned when get_systime is called? the time of the server like if you type "thetime"?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 10-24-2016 , 11:36   Re: Task And Revive
Reply With Quote #9

Always consult the API documentation first. It's system time.
klippy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-24-2016 , 12:19   Re: Task And Revive
Reply With Quote #10

Quote:
Originally Posted by Napoleon_be View Post
What time is actually returned when get_systime is called? the time of the server like if you type "thetime"?
It's the number of seconds that have elapsed since 1/1/1970. https://en.wikipedia.org/wiki/Unix_time
__________________
Bugsy 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 00:01.


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