Raised This Month: $ Target: $400
 0% 

set_task help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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