This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[TUT] Tasks are Healthy, go for it


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 09-09-2023 , 12:53   [TUT] Tasks are Healthy, go for it
Reply With Quote #1

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:
Originally Posted by Hawk552 View Post
set_task can sometimes be an extremely useful function, but other times it is really overkill. What few people know is that it is a very expensive operation, the CPU has to literally check every cycle if it is time for the set_task to be executed. Usually, there are ways around a set_task.
This information is False.

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?
  • When you need the cycle to be checked in less than 0.1 seconds, this way you should use an entity think.
  • When you want to retrieve accurate data. This way you should create a float and play with it. Like i did on my Harry Potter mod, i've used g_fSkillTime[id] so i could later get it's value to display on Hud.

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.
__________________
Jhob94 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 09:45.


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