AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_task(0.01, "func", id) question (https://forums.alliedmods.net/showthread.php?t=173451)

.Dare Devil. 12-05-2011 10:35

set_task(0.01, "func", id) question
 
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?

Devil259 12-05-2011 10:37

Re: set_task(0.01, "func", id) question
 
Task every 0.01 seconds cost a lot of CPU. That's so bad. :)

Arkshine 12-05-2011 11:02

Re: set_task(0.01, "func", id) question
 
The minimal value is 0.1. If you write a value below, like 0.01, 0.1 will be used.

Devil259 12-05-2011 12:05

Re: set_task(0.01, "func", id) question
 
Quote:

Originally Posted by Arkshine (Post 1608167)
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 :)

.Dare Devil. 12-05-2011 12:13

Re: set_task(0.01, "func", id) question
 
Quote:

Originally Posted by Arkshine (Post 1608167)
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.

Arkshine 12-05-2011 12:20

Re: set_task(0.01, "func", id) question
 
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; }

Erox902 12-05-2011 12:23

Re: set_task(0.01, "func", id) question
 
Quote:

Originally Posted by .Dare Devil. (Post 1608201)
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.

.Dare Devil. 12-05-2011 13:18

Re: set_task(0.01, "func", id) question
 
1 Attachment(s)
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

http://forums.alliedmods.net/attachm...1&d=1323110519

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?

Arkshine 12-05-2011 15:43

Re: set_task(0.01, "func", id) question
 
Quote:

Originally Posted by Arkshine (Post 1608204)
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.

jim_yang 12-05-2011 20:49

Re: set_task(0.01, "func", id) question
 
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.


All times are GMT -4. The time now is 12:04.

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