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

set task


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 02-26-2020 , 12:02   set task
Reply With Quote #1

PHP Code:
public Event_RoundStart() 

    
g_RespawnAllowed true
    set_task
(30.0,"DisableRespawn"
    
CromChat(0"!g[hS DeathRun] !nFree respawn enabled for the next !g30.0 seconds.")


public 
DisableRespawn(id

    
g_RespawnAllowed false 
    CromChat
(0"!g[hS DeathRun] !nFree respawn time has ended.")

so, what isn't right here? because when round starts, it shows me that message and right after that shows me the one from Disable Respawn, wasn't it supposed to show after 30 seconds? what i did wrong?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 02-26-2020 , 12:42   Re: set task
Reply With Quote #2

Can u show your full code please?

think this should fix the problem

PHP Code:
public DisableRespawn(id
-->
PHP Code:
public DisableRespawn() 
__________________

Last edited by Napoleon_be; 02-26-2020 at 12:46.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 02-26-2020 , 12:45   Re: set task
Reply With Quote #3

PHP Code:
#include <amxmodx> 
#include <hamsandwich> 
#define CC_COLORS_TYPE CC_COLORS_SHORT
#include <cromchat>  

#define PLUGIN "Deathrun Respawn" 
#define VERSION "1.0" 
#define AUTHOR "nutu." 

new bool:g_RespawnAllowed true

public plugin_init() { 
    
register_plugin(PLUGINVERSIONAUTHOR
    
    
RegisterHam(Ham_Killed"player""H_PlayerDeath"1
    
register_logevent("Event_RoundStart"2"1=Round_Start"


public 
Event_RoundStart() 

    
g_RespawnAllowed true
    set_task
(30.0,"DisableRespawn"
    
CromChat(0"!g[hS DeathRun] !nFree respawn enabled for the next !g30.0 seconds.")


public 
H_PlayerDeath(victimattackershouldgib

    
set_task(0.1"respawnmenu"victim


public 
DisableRespawn(id

    
g_RespawnAllowed false 
    CromChat
(0"!g[hS DeathRun] !nFree respawn time has ended.")

public 
respawnmenu(id)
{
    if(
g_RespawnAllowed
    { 
        new 
menu menu_create("\wDeathrun Features:^nWould you like to respawn?""rspmenu");
        
        
menu_additem(menu"\wYes""1"0);
        
menu_additem(menu"\rNo""2"0);
        
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(idmenu0);
    }
}
public 
rspmenu(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1:
        {
            if(!
is_user_alive(id)) 
            { 
                
ExecuteHamB(Ham_CS_RoundRespawnid
                
CromChat(id"!g[hS DeathRun] !nYou have been respawned!")    
            } 
        }
        case 
2:
        {
            
CromChat(id"!g[hS DeathRun] !nYou've refused the respawn")
        }
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;

here you go, now it seems like it works, but if i die and these 30 seconds passed (the menu still remain) and i can respawn by menu after 30 seconds, could you help me with that?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 02-26-2020 , 12:48   Re: set task
Reply With Quote #4

sorry for dp but can you please add a hud with count down with these 30 seconds please?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 02-26-2020 , 13:05   Re: set task
Reply With Quote #5

This could be done without using a bool. Just check everytime if the task still exists, if it does, proceed. This is how it looks like right now:

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <cromchat>

#define PLUGIN "Deathrun Respawn"
#define VERSION "1.0"
#define AUTHOR "nutu. & NapoleoN#"

#define TASKID 54132

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_logevent("eRoundStart"2"1=Round_Start");
    
    
RegisterHam(Ham_Killed"player""PostPlayerKilled"1);
}

public 
eRoundStart()
{
    if(
task_exists(TASKID))
    {
        
remove_task(TASKID);
    }
    
    
set_task(30.0"DisableRespawn"TASKID);
    
CromChat(0"!g[hS DeathRun] !nFree respawn enabled for the next !g30.0 seconds.");
}

public 
DisableRespawn()
{
    
CromChat(0"!g[hS DeathRun] !nFree respawn time has ended.");
}

public 
PostPlayerKilled(iVictimiKillerShouldGib)
{
    if(
task_exists(TASKID)) 
    { 
        new 
menu menu_create("\wDeathrun Features:^nWould you like to respawn?""HandleRespawn");
        
        
menu_additem(menu"\wYes""1"0);
        
menu_additem(menu"\rNo""2"0);
        
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(iVictimmenu0);
    }
}

public 
HandleRespawn(idmenuitem)
{
    if(!
is_user_alive(id) && item != MENU_EXIT && task_exists(TASKID))
    {
        switch(
item)
        {
            case 
0:
            {
                
ExecuteHamB(Ham_CS_RoundRespawnid);
                
CromChat(id"!g[hS DeathRun] !nYou have been respawned!");
            }
            
            case 
1:
            {
                
CromChat(id"!g[hS DeathRun] !nYou've refused the respawn");
            }
        }
    }
    
menu_destroy(menu);

It's untested, players shouldn't be able to see the menu when they die if the task doesn't exist anymore.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 02-26-2020 , 13:11   Re: set task
Reply With Quote #6

gotta test it, if players die after the respawn time the menu doesn't appear anymore, but per example if someone died before the time passed, the menu didn't closed, and if the time passed with menu opened, it used to respawn, i'll come with a feedback
btw, only in first round these messages were showing right after one, because of server restart i guess
EDIT: as i said, could you add the count down hud? please
__________________
a simple act of caring creates an endless ripple.

Last edited by Nutu_; 02-26-2020 at 13:14.
Nutu_ is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 02-26-2020 , 13:27   Re: set task
Reply With Quote #7

Quote:
Originally Posted by Nutu_ View Post
gotta test it, if players die after the respawn time the menu doesn't appear anymore, but per example if someone died before the time passed, the menu didn't closed, and if the time passed with menu opened, it used to respawn, i'll come with a feedback
btw, only in first round these messages were showing right after one, because of server restart i guess
EDIT: as i said, could you add the count down hud? please
Does it work?

Also, this is the scripting help section, if u want it to get added, u should post it in suggestions/requests.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 02-26-2020 , 13:42   Re: set task
Reply With Quote #8

yeah, this works as i wanted
i know but somehow this a script help because i made 99% of plugin, i just want to add something that i dont know how, that count down for 30 seconds, so if i already have a topic here why should i open another one? doesn't matter anyway but if we already made it, could you add that too?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 02-26-2020 , 13:53   Re: set task
Reply With Quote #9

untested

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <cromchat>

#define PLUGIN "Deathrun Respawn"
#define VERSION "1.0"
#define AUTHOR "nutu. & NapoleoN#"

#define TASKID 54132
#define HUDID 13234

new iCountDown 30;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_logevent("eRoundStart"2"1=Round_Start");
    
    
RegisterHam(Ham_Killed"player""PostPlayerKilled"1);
}

public 
eRoundStart()
{
    if(
task_exists(TASKID))
    {
        
remove_task(TASKID);
    }
    
    if(
task_exists(HUDID))
    {
        
remove_task(HUDID);
    }
    
    
set_task(30.0"DisableRespawn"TASKID);
    
CromChat(0"!g[hS DeathRun] !nFree respawn enabled for the next !g30.0 seconds.");
}

public 
DisableRespawn()
{
    
set_hudmessage(25500, -1.00.000.01.00.00.0, -1);
    
    if(
iCountDown == 0)
    {
        
show_hudmessage(0"Respawn has been disabled.");
        
CromChat(0"!g[hS DeathRun] !nFree respawn time has ended.");
    }
    
    else
    {
        
show_hudmessage(0"Time until respawn disabled: %i"iCountDown--);
        
set_task(1.0"DisableRespawn"HUDID);
    }
}

public 
PostPlayerKilled(iVictimiKillerShouldGib)
{
    if(
task_exists(TASKID)) 
    { 
        new 
menu menu_create("\wDeathrun Features:^nWould you like to respawn?""HandleRespawn");
        
        
menu_additem(menu"\wYes""1"0);
        
menu_additem(menu"\rNo""2"0);
        
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(iVictimmenu0);
    }
}

public 
HandleRespawn(idmenuitem)
{
    if(!
is_user_alive(id) && item != MENU_EXIT && task_exists(TASKID))
    {
        switch(
item)
        {
            case 
0:
            {
                
ExecuteHamB(Ham_CS_RoundRespawnid);
                
CromChat(id"!g[hS DeathRun] !nYou have been respawned!");
            }
            
            case 
1:
            {
                
CromChat(id"!g[hS DeathRun] !nYou've refused the respawn");
            }
        }
    }
    
menu_destroy(menu);

__________________

Last edited by Napoleon_be; 02-27-2020 at 09:22.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 02-26-2020 , 14:18   Re: set task
Reply With Quote #10

sometimes it shows the hud, sometimes not
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Reply


Thread Tools
Display Modes

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 21:35.


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