Raised This Month: $ Target: $400
 0% 

set_task(0.01, "func", id) question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 12-05-2011 , 10:35   set_task(0.01, "func", id) question
Reply With Quote #1

Hi, i have one question.

why no one use tast time 0.01?

I try it, and it working good.
I've heard that is impossible or something like that, put it is a possible and working when i test it in new game.

Is it bad or something, crash the server?
.Dare Devil. is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-05-2011 , 10:37   Re: set_task(0.01, "func", id) question
Reply With Quote #2

Task every 0.01 seconds cost a lot of CPU. That's so bad.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-05-2011 , 11:02   Re: set_task(0.01, "func", id) question
Reply With Quote #3

The minimal value is 0.1. If you write a value below, like 0.01, 0.1 will be used.
__________________

Last edited by Arkshine; 12-05-2011 at 11:03.
Arkshine is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-05-2011 , 12:05   Re: set_task(0.01, "func", id) question
Reply With Quote #4

Quote:
Originally Posted by Arkshine View Post
The minimal value is 0.1. If you write a value below, like 0.01, 0.1 will be used.
I didn't know, thank's
__________________
You can do anything you set your mind to, man.

Devil259 is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 12-05-2011 , 12:13   Re: set_task(0.01, "func", id) question
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
The minimal value is 0.1. If you write a value below, like 0.01, 0.1 will be used.
I tested it.
changed the task(0.1
to task(0.01
and that task was lot a faster.
Then i tryed 0.001, this was faster than 0.01
and then 0.00001 that was same.
.Dare Devil. is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 12-05-2011 , 12:23   Re: set_task(0.01, "func", id) question
Reply With Quote #6

Quote:
Originally Posted by .Dare Devil. View Post
I tested it.
changed the task(0.1
to task(0.01
and that task was lot a faster.
Then i tryed 0.001, this was faster than 0.01
and then 0.00001 that was same.
I doubt that you can even see the difference of directly calling it and set_task(0.1...
And no it wasn't faster. The compiler automatically converts it to 0.1 if the number is lower.
Erox902 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-05-2011 , 12:20   Re: set_task(0.01, "func", id) question
Reply With Quote #7

You don't understand. There is a check inside the native code where you CAN'T go below 0.1.

If you still don't understand :

Code:
static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */ {     CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx);     int a, iFunc;     char* stemp = get_amxstring(amx, params[2], 1, a);     if (params[5])     {         iFunc = registerSPForwardByName(amx, stemp, FP_ARRAY, FP_CELL, FP_DONE);     } else {         iFunc = registerSPForwardByName(amx, stemp, FP_CELL, FP_DONE);     }         if (iFunc == -1)     {         LogError(amx, AMX_ERR_NATIVE, "Function is not present (function \"%s\") (plugin \"%s\")", stemp, plugin->getName());         return 0;     }     float base = amx_ctof(params[1]);     if (base < 0.1f)         base = 0.1f;     char* temp = get_amxstring(amx, params[6], 0, a);     g_tasksMngr.registerTask(plugin, iFunc, UTIL_ReadFlags(temp), params[3], base, params[5], get_amxaddr(amx, params[4]), params[7]);     return 1; }
__________________

Last edited by Arkshine; 12-05-2011 at 12:23.
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-05-2011 , 15:43   Re: set_task(0.01, "func", id) question
Reply With Quote #8

Quote:
Originally Posted by Arkshine View Post
You don't understand. There is a check inside the native code where you CAN'T go below 0.1.

If you still don't understand :

Code:
static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */ {     CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx);     int a, iFunc;     char* stemp = get_amxstring(amx, params[2], 1, a);     if (params[5])     {         iFunc = registerSPForwardByName(amx, stemp, FP_ARRAY, FP_CELL, FP_DONE);     } else {         iFunc = registerSPForwardByName(amx, stemp, FP_CELL, FP_DONE);     }         if (iFunc == -1)     {         LogError(amx, AMX_ERR_NATIVE, "Function is not present (function \"%s\") (plugin \"%s\")", stemp, plugin->getName());         return 0;     }     float base = amx_ctof(params[1]);     if (base < 0.1f)         base = 0.1f;     char* temp = get_amxstring(amx, params[6], 0, a);     g_tasksMngr.registerTask(plugin, iFunc, UTIL_ReadFlags(temp), params[3], base, params[5], get_amxaddr(amx, params[4]), params[7]);     return 1; }
Read My Fucking Post.
__________________
Arkshine is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 12-05-2011 , 13:18   Re: set_task(0.01, "func", id) question
Reply With Quote #9

I tested it with message Te_Dlight

when the task time is 0.1
then light does not blink

light life byte was 2


and when i changed it 0.01 , just to testing
then
the light blink

light life byte was also 2

then i edit the light life to 1
tested it
also light blink


Then i changed a task time 0.05
and light life byte was 1

then light does not blink and it was lot more faster then task 0.1 time.
Mayby that code fail.


Also i tested it what compile write in amxx whit hex reading.
and result the task time what was 0.01 and i compiled
in .amxx the task time was also 0.01.

Sorry my bad english, I hope that you understand me.



Edit:

Tested now that on this plugin

PHP Code:
 
#include <amxmodx>
#include <amxmisc>
new g_test[2]
new 
g_testcount[2]
public 
plugin_init()
{
 
register_plugin"9""9""9" )
 
register_clcmd("say /testit""cmd_test")
}
public 
cmd_test(id)
{
 
g_test[1] = 2
 g_testcount
[1] = 0
 set_task
0.01"testit")
 
set_task0.1 "test_over")
}
public 
testit()
{
 if(
g_test[1] == 2)
 {
  
g_testcount[1]++
  
set_task0.01"testit")
 }
}
public 
test_over()
{
 static 
result
 result 
g_testcount[1]
 
g_test[1] = 1
 client_print
(0print_chat,"[TEST] %d"result);

and



0.01 time working fine.
But one time frame is missing only, it must be 10 i think.
So its a slower a little bit.

Edit

I Download amxmodx from http://www.amxmodx.org/downloads.php
And first i looked the dll size and my amxmodx what i use in cs are smaller than http://www.amxmodx.org/downloads.php

Then i test task 0.01 on new amxmodx on this plugin and result was 1
But if i use that task 0.01 it did not change it 0.1, its like little bit smaller value idk
The lighting is faster 0.01 than 0.1 task time.

Mayby the problem is that the script where i use 0.01 task time is very big.



question 2,

Why the amxmodx autors limit the task time?
Is it bad to use it smaller value than 0.1?
Attached Thumbnails
Click image for larger version

Name:	de_dust20000.jpg
Views:	982
Size:	21.1 KB
ID:	96284  

Last edited by .Dare Devil.; 12-05-2011 at 14:32.
.Dare Devil. is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 12-05-2011 , 20:49   Re: set_task(0.01, "func", id) question
Reply With Quote #10

Code:
void C_StartFrame_Post(void)
{
	if (g_task_time > gpGlobals->time)
		RETURN_META(MRES_IGNORED);

	g_task_time = gpGlobals->time + 0.1f;
	g_tasksMngr.startFrame();

	RETURN_META(MRES_IGNORED);
}
the reason why amxx limit task check frequency to 0.1s is that it's in server_frame, if every frame it loops all task list to find your task is ready to run, that cost a lot of cpu indeed.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang 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 12:04.


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