Variable life time?
Hi. I have a question.
What is a variable life time? For this case: PHP Code:
Or this is a bad code practise? Because here: http://www.amxmodx.org/funcwiki.php?go=func&id=253 phatency wrote: PHP Code:
|
Re: Variable life time?
Typically, the scope of a variable is only as wide as the routine its defined in. Thus, the life of your variables is only valid as long as each routine is executing. As soon as the sub/function is exited, the variables are released. A variable defined globally (not within a sub/function, like args in the second example)), lives and is visible throughout the entire plugin.
In the example you cited, I'd assume the author was referring the the value of the variable being deleted rather than the variable itself. In your code, you don't really need to sent a parameter. You could simplely obtain the plrid again by subtracting out the BASE_TASK_ID |
Re: Variable life time?
Quote:
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() |
Re: Variable life time?
Thanks Vet and Bugsy!
Quote:
Quote:
Quote:
Quote:
Quote:
BTW If we have PHP Code:
|
Re: Variable life time?
It should.
|
| All times are GMT -4. The time now is 17:04. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.