Raised This Month: $32 Target: $400
 8% 

[QUESTION] Prethink vs Set_task


Post New Thread Reply   
 
Thread Tools Display Modes
Shiina.Mashiro
Senior Member
Join Date: Sep 2014
Location: Vietnam
Old 05-22-2015 , 21:28   Re: [QUESTION] Prethink vs Set_task
Reply With Quote #11

Quote:
Originally Posted by Depresie View Post
btw, what about the following function, is it cpu friendly?
Code:
register_forward(FM_CmdStart, "OnCmdStart")
Nope.
__________________
Shiina.Mashiro is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-23-2015 , 03:14   Re: [QUESTION] Prethink vs Set_task
Reply With Quote #12

Quote:
Originally Posted by HamletEagle View Post
Use a global task then. Also note that prethink is called around 20 times/second(IIRC) on every player. Do you still think that prethink is better ?
In my case, 500+ times/ second. It depends on how many FpS a player have.

As a note, a friend of mine computed the remaining Jetpack/ Bazooka fuel through Player(Pre|Post)Think(_Pre|_Post) forward.
Because I've got a higher number of FpS, my fuel was computed faster.
So it was a wrong idea.
__________________

Last edited by claudiuhks; 05-23-2015 at 03:20.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 05-23-2015 , 04:54   Re: [QUESTION] Prethink vs Set_task
Reply With Quote #13

Quote:
Originally Posted by claudiuhks View Post
In my case, 500+ times/ second. It depends on how many FpS a player have.

As a note, a friend of mine computed the remaining Jetpack/ Bazooka fuel through Player(Pre|Post)Think(_Pre|_Post) forward.
Because I've got a higher number of FpS, my fuel was computed faster.
So it was a wrong idea.
fps_max 20
jetpack forever

Quote:
Originally Posted by fysiks View Post
Huh? What is "0,(3)"? 300 fps equates to 3.33 ms.
sorry, I keep posting while I'm high
0,(3) = 0,33333333333333333333...
but I for some reason thought one second had 100 ms and not 1000

edited
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 05-23-2015 , 11:12   Re: [QUESTION] Prethink vs Set_task
Reply With Quote #14

any other opinions about this forward?
Code:
register_forward(FM_CmdStart, "OnCmdStart")
Quote:
fps_max 20
jetpack forever
lol

Last edited by Depresie; 05-23-2015 at 11:13.
Depresie is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-23-2015 , 11:49   Re: [QUESTION] Prethink vs Set_task
Reply With Quote #15

Quote:
Originally Posted by Depresie View Post
any other opinions about this forward?
Code:
register_forward(FM_CmdStart, "OnCmdStart")
Shiina.Mashiro has already told you that forward is inefficient. It is also called on every frame, for every player, I think. You'll get thousands of calls per second with it anyway, with a full server.

If I need some code to get executed with a delay, and is per-player, I usually go with a task.
If I have some code running constantly, for example every couple of seconds, and should do something globally (show a HUD message to every player, for example), I usually go with a thinking entity.

Last edited by klippy; 05-23-2015 at 11:50.
klippy is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 05-25-2015 , 16:53   Re: [QUESTION] Prethink vs Set_task
Reply With Quote #16

Quote:
Originally Posted by Depresie View Post
any other opinions about this forward?
Code:
register_forward(FM_CmdStart, "OnCmdStart")
edit:
On the topic Prethink vs set_task, [thank you Arkshine for clearing this up]
Quote:
Originally Posted by Arkshine View Post
CmdStart is exactly the same as Prethink. Just called first.
If you do "good" checks and only progress through the code on a necessary basis (ie. ignoring majority of additional code checks for ineligible players), then the usage will not be terrible and you probably won't notice a difference. This can also be said about prethink, so you will see scripters use the forwards in large/demanding plugins.

However, AMXx is able to compare set_tasks' timestamps faster than a Pawn script can run a bit & check and then also do a timestamp check. It would be hard to measure and compare these different methods, but a rule of thumb when comparing Pawn scripting to AMXx natives (obviously there are exceptions): less pawn script = better pawn script.

Last edited by Emp`; 05-26-2015 at 11:57.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-25-2015 , 17:39   Re: [QUESTION] Prethink vs Set_task
Reply With Quote #17

CmdStart is exactly the same as Prethink. Just called first.
__________________
Arkshine is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 05-28-2015 , 10:36   Re: [QUESTION] Prethink vs Set_task
Reply With Quote #18

i see thank you very much for the info
Depresie is offline
Reply



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 01:38.


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