Raised This Month: $ Target: $400
 0% 

How to make a delay?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-21-2011 , 21:37   Re: How to make a delay?
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
Using set_task() is the correct action to do what you want. Try this:

PHP Code:
public handlemenu(idmenuitem)
{
    new 
szItem[33], _accesscallback;
    
menu_item_getinfo(menuitem_access""0szItem32callback);

    
load(id1szItem);
    
set_task(2.0"load"12345szItemstrlen(szItem)+1)

}

load(idszConfigsName[])
{
    new 
szPath[129];
    
format(szPath128"%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 handlemenuid menu item )
{
    new 
szItem34 ] , _access callback;
    
menu_item_getinfomenu item _access "" szItem] , charsmaxszItem ) - callback );

    
//Passed as "number" to load function
    
szItem] = 2468;
    
copyszItem] , charsmaxszItem ) - "Test String" );
    
    
loadszItem ,  id );
    
set_task2.0 "load" 12345 szItem sizeofszItem ) );


public 
load( const szData34 ] , id )
{
    new 
szPath129 ] , iNumber;
    
    
iNumber szData];
    
formatexszPath charsmaxszPath ) , "%s.test" szData] );

    
//Check that the data made it correctly.
    
server_print"id=%d Number=%d String=%s Path=%s" id iNumber szData] , szPath );

__________________

Last edited by Bugsy; 07-21-2011 at 23:02.
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 01:09.


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