Raised This Month: $ Target: $400
 0% 

Variable life time?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-17-2009 , 00:54   Re: Variable life time?
Reply With Quote #3

Quote:
Originally Posted by Flasher View Post
Hi. I have a question.
What is a variable life time?
For this case:
PHP Code:
public client_putinserver(plrid)
{
    new 
param[1];
    
param[0] = plrid;
    
set_task(30.0"showInfo"BASE_TASK_ID plridparam1);
    return 
PLUGIN_CONTINUE;
}

public 
showInfo(param[])
{
    new 
plrid param[0];
    
//....

How long this task can be delayed to function to get an alive variable? For me this is working, but I doesn't know can I depend on this or not.
Or this is a bad code practise?
The variable will be passed without issue but you need to do additional checking in showinfo to confirm the player is still connected after 30 seconds.

ie.
- id 21 connects
- set_task called with id 21 as a param
- 10 seconds later id 21 disconnects
- 20 seconds later, showInfo(21) gets called from set_task but player no longer connected. any functions called on id 21 will error without first checking is_user_connected()
__________________

Last edited by Bugsy; 02-17-2009 at 00:57.
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 17:04.


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