Quote:
Originally Posted by fysiks
Using set_task() is the correct action to do what you want. Try this:
PHP Code:
public handlemenu(id, menu, item) { new szItem[33], _access, callback; menu_item_getinfo(menu, item, _access, "", 0, szItem, 32, callback);
load(id, 1, szItem); set_task(2.0, "load", 12345, szItem, strlen(szItem)+1)
}
load(id, szConfigsName[]) { new szPath[129]; format(szPath, 128, "%s.test", szConfigsName); }
Nope, he just wants to delay the task. The code I presented there is to see if a command is allowed (depending on how long ago the last usage was).
|
There are a few problems with that code.
1. Functions called by set_task() must be public.
2. The load() function params are in the wrong order. Data is passed first followed by task-id when called by set_task.
3. Use sizeof() instead of strlen(), and charsmax() instead of size - 1.
4. Use formatex() when you are not passing the destination string as a param.
5. If you need to pass multiple params through set_task(), you must pack them all into the same array. You needing only to pass a number and string is easy since you can use the first cell to store the number and the remainder for the string. You can pack a lot of different data if needed, though.
6. You are calling load() with 3 params while it only has 2 in the declaration.
Try this, let me know if you need any adjustments.
PHP Code:
public handlemenu( id , menu , item )
{
new szItem[ 34 ] , _access , callback;
menu_item_getinfo( menu , item , _access , "" , 0 , szItem[ 1 ] , charsmax( szItem ) - 1 , callback );
//Passed as "number" to load function
szItem[ 0 ] = 2468;
copy( szItem[ 1 ] , charsmax( szItem ) - 1 , "Test String" );
load( szItem , id );
set_task( 2.0 , "load" , 12345 , szItem , sizeof( szItem ) );
}
public load( const szData[ 34 ] , id )
{
new szPath[ 129 ] , iNumber;
iNumber = szData[ 0 ];
formatex( szPath , charsmax( szPath ) , "%s.test" , szData[ 1 ] );
//Check that the data made it correctly.
server_print( "id=%d Number=%d String=%s Path=%s" , id , iNumber , szData[ 1 ] , szPath );
}
__________________