Quote:
Originally Posted by Flasher
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 + plrid, param, 1); 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()
__________________