AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_task issue (https://forums.alliedmods.net/showthread.php?t=156274)

epix 05-03-2011 17:13

set_task issue
 
Hi, I'm trying to make a simple lo3 script.

I got something like this:

Code:
public lo3() {     server_cmd("say < LIVE ON 3 RESTARTS >")     set_task(1.0, "server_cmd", TASKID_LO3, "say < RESTART 1 >")     set_task(1.1, "rr", TASKID_LO3, "1")     set_task(2.5, "server_cmd", TASKID_LO3, "say < RESTART 2 >")     set_task(2.6, "rr", TASKID_LO3, "1")     set_task(4.0, "server_cmd", TASKID_LO3, "say < RESTART 3 >")     set_task(4.1, "rr", TASKID_LO3, "1")     set_task(5.2, "server_cmd", TASKID_LO3, "say < LIVE >")     set_task(5.3, "server_cmd", TASKID_LO3, "say < LIVE >")     set_task(5.4, "server_cmd", TASKID_LO3, "say < LIVE >")     set_task(5.5, "server_cmd", TASKID_LO3, "say < LIVE >") } public rr(time) {     //set_cvar_num("sv_restartround", time)     server_cmd("sv_restartround %d", time) }
As far as I know this would be correct, but server gives me this error:
Code:

Function is not present (function "server_cmd")
It does work without the say commands. So the problem is that it works on my own functions but not on native functions I guess ?
Is there an explanation and solution for this?

(set_cvar_num and server_cmd both work in for rr function)

Doc-Holiday 05-03-2011 17:18

Re: set_task issue
 
the second parameter of set task is the call back

server_cmd would be your call back and there is no function called that

epix 05-03-2011 17:26

Re: set_task issue
 
Quote:

Originally Posted by Doc-Holiday (Post 1462761)
the second parameter of set task is the call back

server_cmd would be your call back and there is no function called that

Yes ok, I get that. But the server_cmd actualy does exist, it's just not my function. I was thinking a possible workaround would be something like this:

Code:
public lo3() {     server_cmd("say < LIVE ON 3 RESTARTS >")     set_task(1.0, "srv_chat", TASKID_LO3, "< RESTART 1 >")     set_task(1.1, "rr", TASKID_LO3, "1")     set_task(2.5, "srv_chat", TASKID_LO3, "< RESTART 2 >")     set_task(2.6, "rr", TASKID_LO3, "1")     set_task(4.0, "srv_chat", TASKID_LO3, "< RESTART 3 >")     set_task(4.1, "rr", TASKID_LO3, "1")     set_task(5.2, "srv_chat", TASKID_LO3, "< LIVE >")     set_task(5.3, "srv_chat", TASKID_LO3, "< LIVE >")     set_task(5.4, "srv_chat", TASKID_LO3, "< LIVE >")     set_task(5.5, "srv_chat", TASKID_LO3, "< LIVE >") } public rr(time) {     //set_cvar_num("sv_restartround", time)     server_cmd("sv_restartround %d", time) } public srv_chat(msg[]) {     server_cmd("say %s", msg) }
now it does the restarts, but server console shows these errors:
Code:

Error, bad server command say
Error, bad server command say
Error, bad server command say
...


ConnorMcLeod 05-03-2011 18:01

Re: set_task issue
 
You use task params to pass the string, but as param num you should pass string length.

epix 05-03-2011 18:23

Re: set_task issue
 
Quote:

Originally Posted by ConnorMcLeod (Post 1462794)
You use task params to pass the string, but as param num you should pass string length.

Thanks! Passing the string length to set_task fixed it :)


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

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