AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_task help (https://forums.alliedmods.net/showthread.php?t=214443)

Podarok 04-27-2013 07:11

set_task help
 
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) }

baneado 04-27-2013 07:30

Re: set_task help
 
yes, why not? did you test it?

jimaway 04-27-2013 08:36

Re: set_task help
 
why not just make that task end in some seconds? no reason to make another task for it

^SmileY 04-27-2013 21:40

Re: set_task help
 
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...



ConnorMcLeod 04-28-2013 05:26

Re: set_task help
 
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");
    }




All times are GMT -4. The time now is 10:50.

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