Raised This Month: $ Target: $400
 0% 

Pass multiple parameters to set_task


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-05-2011 , 08:58   Re: Pass multiple parameters to set_task
Reply With Quote #5

You can pack anything into an array and pass it to a function via set_task as long as you keep the data organized so it can be retrieved in the called function. The easiest way to do this is with an enum to create a 'hacked' structure. Also make sure your called function has parameters in the correct order; the data/array is first then task-id.
PHP Code:
#include <amxmodx>
#include <amxmisc>

//You can include anything including integers, strings, arrays, floats
enum _:TaskData
{
    
PlayerIndex,
    
PlayerName33 ],
    
SteamID35 ],
    
Health,
    
Float:Whatever,
    
ArrayNumbers]
}

public 
plugin_init() 
{
    
register_plugin"Set_task Example" "0.1" "bugsy" );
    
    
register_clcmd"say test" "CmdTask" );
}

public 
CmdTaskid )
{
    new 
tdDataTaskData ];
    
    
tdDataPlayerIndex ] = id;
    
get_user_nameid tdDataPlayerName ] , charsmaxtdDataPlayerName ] ) );
    
get_user_authidid tdDataSteamID ] , charsmaxtdDataSteamID ] ) );
    
tdDataHealth ] = get_user_healthid );
    
tdDataWhatever ] = _:55.25;
    
tdDataArrayNumbers ][ ] = 12
    
tdDataArrayNumbers ][ ] = 34;
    
tdDataArrayNumbers ][ ] = 56;
    
    
set_task1.0 "YourFunc" 12345 tdData sizeoftdData ) );
}

public 
YourFunctdIncomingTaskData ] , iTaskID )
{
    
server_print"TaskID=%d ^"%d^" ^"%s^" ^"%s^" ^"%d^" ^"%f^" [%d,%d,%d]" iTaskID tdIncomingPlayerIndex ] , 
                                                                                     
tdIncomingPlayerName ] , 
                                                                                     
tdIncomingSteamID ] , 
                                                                                     
tdIncomingHealth ] , 
                                                                                     
tdIncomingWhatever ] , 
                                                                                     
tdIncomingArrayNumbers ][ ] , 
                                                                                     
tdIncomingArrayNumbers ][ ] , 
                                                                                     
tdIncomingArrayNumbers ][ ] );

Code:
TaskID=12345 "1" "bugsy" "STEAM_0:0:123456" "100" "55.250000" [12,34,56]
__________________

Last edited by Bugsy; 05-05-2011 at 09:21.
Bugsy 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 04:29.


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