id + any_defined_value in set_task()
OK, I'm sick of this, it made me confused.
I read in some codes and tutorials (especially Exolent's tutorial about enums): Code:
It's just confusing!!!! |
Re: id + any_defined_value in set_task()
PHP Code:
public function(id) where id = playerid from 1 to 32 |
Re: id + any_defined_value in set_task()
The id (3rd param.) in set_task() has to be unique, so you
Defines are usually used in cases when a plugin has several set_task() functions which are related to players (but not only). When set_task() executes a function it is possible to get player's id. |
Re: id + any_defined_value in set_task()
Quote:
|
Re: id + any_defined_value in set_task()
i use that all the time and i remove the task when player disconnected if the task is with B flag and i never had any problems, you can set a random constant + playerid if you don't like
new const task = 32784; and set task with the id + task |
Re: id + any_defined_value in set_task()
EDIT: This example I've used is misleading and is likely to fail. See post #9.
A player might have several tasks running which require their player index when ready. For example, a weapon pickup delay for both primary and secondary weapons, therefore you need 2 task identifiers, incase a player picks up a secondary weapon before his delay has expired for his primary weapon ( or vice versa ): Code:
You add the identifier to their player index: Code:
And then deduct the identifier to retain the player index once again: Code:
Hope that helps. |
Re: id + any_defined_value in set_task()
Basically if you want to remove (or change) a task, you need to provide its ID. It gets problematic when you have several tasks with same ID and want to remove/change a certain task.
|
Re: id + any_defined_value in set_task()
Ahhhhh, now I understood it.
Thanks all! :up: |
Re: id + any_defined_value in set_task()
Quote:
Usually you will see authors use an enum to do this: Code:
enum += 32 |
Re: id + any_defined_value in set_task()
Quote:
Thanks :) |
| All times are GMT -4. The time now is 06:15. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.