[TUT] Tasks are Healthy, go for it
I'll not be explaining the basic stuff, you have the search button available.
This tutorial is made for intermediate-advanced level scripters. I keep watching people talking non-sense on scripting help so i am here to give some explanations. First i did a little research to figure out why there are so many people wrong and i found a Tutorial made by Hawk552. This tutorial is old and is not accurate. Quote:
It will check every cycle even if you are not using tasks. So using a task will not overkill anything. It is completly fine to use and you should use it as long as it fits your needs the best. So, when should you not use a task?
And this brings us to the other myth: When should we use task_exists? Many people think that this function exists to remove a task safely. This is also False. This function allows you not to waste memory while playing with Task Id. Instead of using a bool to define something true/false on the task you can just use task_exists to know if the user has the temporary tool. Also you don't need to check if the task exists in order to remove it. The remove_task function already checks if it exists. Actually there is no harm on checking if the task exists, but you are making a repeated unnecessary step. |
Re: [TUT] Tasks are Healthy, go for it
people should keep in mind some topics are from ancient times where almost everything could be considered as a overkill for server hardware enviroment
set_task could be a overkill, depends on what you do on it |
Re: [TUT] Tasks are Healthy, go for it
Quote:
|
Re: [TUT] Tasks are Healthy, go for it
I recall reading that it was not the task running that was expensive, it was the creation of the task. Granted, computers have come a long way since 2010 so this likely doesn't matter anymore assuming you are not calling set_task() a million times. In the past I have used a thinking entity opposed to set_task() based on this mindset, but set_task() is certainly easier.
|
Re: [TUT] Tasks are Healthy, go for it
@Bugsy maybe back in the days it was somehow expensive, but i am not so sure. This looks fine to me
Code:
static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */ Code:
void CTaskMngr::registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags, cell iId, float fBase, int iParamsLen, const cell *pParams, int iRepeat) |
Re: [TUT] Tasks are Healthy, go for it
I don't know, I'm only the messenger. I've personally never had any problems using set_task() so I wouldn't hesitate to use it going forward. Granted, I still try to use it sparingly, as you should with all code/natives - eg. if you need a task to do XYZ on a player, create a single repeating task and perform XYZ on player(s) when conditions are met.
|
Re: [TUT] Tasks are Healthy, go for it
According to IgnacioFDM https://github.com/alliedmodders/amxmodx/pull/380, set_task has some performance issues, like using a linked list instead of std::vector or not ordering tasks by execution time instead so you don't iterate over the entire task list every frame. Unfortunately, the PR has never been finished and it also fixes some precision issues. With today's computer will be this an issue? I don't think so, it all depends on what the set_task is being used for.
|
Re: [TUT] Tasks are Healthy, go for it
It was believed that these tasks were expensive in terms of memory and CPU requirements, but it seems that it no longer matters, technology has advanced, another piece of information, if you need to execute a task less than 0.1, It will not be your alternative
PHP Code:
|
Re: [TUT] Tasks are Healthy, go for it
Are you aware that set_task algorithm has changed since 2006, the year that topic was made? You can find many of "nonsense" on Scripting Help talking about what to optimize or not, but today's machine are not aware at all of that kind of comsumption wasting. I assume you're looking today's AMXX source code, which is fine to refute in nowadays; but that can't be assumed as false, since it WAS a reality those days.
If you're an intermediate-expert AMXX code you'll notice that everything in the past is vastly considered "expensive/unoptimized", like, skipping function calls, avoid native calls, engine > fakemeta (because a few decimals in benchmarkings), the typical new vs static argument, variable size reductions, etcetera. set_task should be avoided if you want to be accurate and that's all, you can use timers and think functions instead, everything else is upon coder's decisions. |
Re: [TUT] Tasks are Healthy, go for it
The reason why i created this topic is because there was still a lot of people missinformed at scripting help.
I’ve no idea how it was in 2006, it doesn’t matter, UP TO THIS DATE, people were providing wrong information. About what you said on when tasks should be avoided, it is already mentioned on the thread. Anyway, good to see you active. I hope you are staying. |
All times are GMT -4. The time now is 13:13. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.