Raised This Month: $ Target: $400
 0% 

set_task help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 04-27-2013 , 07:11   set_task help
Reply With Quote #1

Hey there. So i want to set task with unique id.
id+1337 and repeat it. Alright I KNOW how to do it, but can I set_task to remove this id+1337 task in some seconds.
Is it right?
Code:
set_task(5.0, "remove", id) public remove(id) {    remove_task(id+1337) }

Last edited by Podarok; 04-27-2013 at 07:14.
Podarok is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 04-27-2013 , 07:30   Re: set_task help
Reply With Quote #2

yes, why not? did you test it?
baneado is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-27-2013 , 08:36   Re: set_task help
Reply With Quote #3

why not just make that task end in some seconds? no reason to make another task for it
jimaway is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-27-2013 , 21:40   Re: set_task help
Reply With Quote #4

PHP Code:
set_task(5.0"remove"id 1337)

public 
remove(id)
{
   
id -= 1337;

   
client_print(id,"Task removed");

   
// You not need to remove_task(); you task has ended...

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 04-27-2013 at 21:40.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Old 04-28-2013, 04:56
didoWEE
This message has been deleted by didoWEE.
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-28-2013 , 05:26   Re: set_task help
Reply With Quote #6

Here is a snippet on how you could do with tasks, player tasks and other tasks.
Should be usable in any plugin except if you pass an entity index as task index, if you want to pass an entity and use this, use rather task params to store the entity index.
Same if you want to pass a representating number of something, use params.

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

#pragma semicolon 1

#define PLUGIN ""
#define VERSION "0.0.1"
#define AUTHOR ""

const MAGIC_NUMBER 33;

enum _:playerTasks ( += MAGIC_NUMBER )
{
    
TASK_PLR_PRINT,
    
TASK_PLR_RESPAWN,
    
TASK_PLR_REMOVE
}

enum _:genericTasks
{
    
TASK_PRINTALL TASK_PLR_REMOVE+1// use last player tasks + 1
    
TASK_GIVENADES
}

public 
plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR );

    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0");

    
set_task(2.0"PrintAll"TASK_PRINTALL, .flags="b");
}

public 
Event_HLTV_New_Round()
{
    
set_task(10.0"GiveNade"TASK_GIVENADES, .flags="b");
}

public 
bomb_planted/* planter */ )
{
    
remove_taskTASK_GIVENADES );
}

public 
client_putinserver(id)
{
    
set_task(15.0"Advertise_Player"id TASK_PLR_PRINT);
}

public 
client_disconnect(id)
{
    
remove_task(id TASK_PLR_PRINT);
}

public 
Advertise_Playerid )
{
    
id %= MAGIC_NUMBER;
    if( 
is_user_connected(id) )
    {
        
client_print(idprint_chat"4Welcome on this server, please invit some friends");
    }
}

public 
PrintAll( )
{
    
client_print(0print_chat"^4Random Text");
}

public 
GiveNade()
{
    new 
players[32], num;
    
get_players(playersnum"a");
    for(--
numnum>=0num--)
    {
        
give_item(players[num], "weapon_hegrenade");
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 10:50.


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