AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_hudmessage connected with set_task (https://forums.alliedmods.net/showthread.php?t=11790)

LynX 03-28-2005 16:31

set_hudmessage connected with set_task
 
Well, I would like to do this thing. When I set task, I want that hudmessage appears as long as task is running. But, there should be a counter which counts like 15,14,13...3,2,1 untill task finished. How can I do this?
Code is below, alter it please:

Code:
#include <amxmodx> #include <fun> public plugin_init() { register_plugin("Hudmessage with task","dunno","LynX") register_clcmd("hudmessage","hudmessage1") return PLUGIN_HANDLED } public hudmessage1(id) { //I will put some stuff here later set_hudmessage(200,0,0, 0.03, 0.76, 2, 0.02, 1.0, 0.01, 0.1, 2) show_hudmessage(id,"Task finishes in <countdownthinghere> ") set_task(15, "hudmessage2",id) return PLUGIN_HANDLED } public hudmessage2(id) { //I will remove stuff here return PLUGIN_HANDLED }

Thanks.

LynX

v3x 03-28-2005 16:46

Make a time variable, set it so that each time the task it looped it decreases it by 1.

Twilight Suzuka 03-28-2005 16:58

You could set the hudmessage holdtime to a value like 1, and call the hudmessage to display every second until you are done. Then it would only appear until the task ends.

LynX 03-28-2005 17:01

You mean:

Code:
#include <amxmodx> #include <fun> new timer public plugin_init() { register_plugin("Hudmessage with task","dunno","LynX") register_clcmd("hudmessage","hudmessage1") return PLUGIN_HANDLED } public hudmessage1(id) { //I will put some stuff here later set_hudmessage(200,0,0, 0.03, 0.76, 2, 0.02, 1.0, 0.01, 0.1, 2) show_hudmessage(id,"Task finishes in d% time ", timer - 1) set_task(15, "hudmessage2",id) return PLUGIN_HANDLED } public hudmessage2(id) { //I will remove stuff here return PLUGIN_HANDLED }

[ edit ]

I know this above probably won't work, but can some1 show me a code snippet?

FeuerSturm 03-28-2005 17:43

Code:
public hudmessage(id){     if(timer > 0){         set_hudmessage(200,0,0, 0.03, 0.76, 2, 0.02, 1.0, 0.01, 0.1, 2)         show_hudmessage(id,"Task finishes in %d seconds",timer)         timer--         set_task(1.0,"hudmessage",id)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED }

LynX 03-28-2005 17:47

So, this above will work if I just put it into code, right?

FeuerSturm 03-28-2005 17:56

no, because you're not setting a value to "timer" anywhere

v3x 03-28-2005 17:57

Quote:

Originally Posted by LynX
So, this above will work if I just put it into code, right?

He eliminated the need for a second function..

So just take out your hudmessage() functions, and replace them with the above code that he's provided. Remember to change the command. ;)

LynX 03-28-2005 18:24

Argh, I'm now confused... Can some1 show me the whole plugin code, without having thrashing head into monitor? ^^

If nobody won't - won't that function just loop itself? And when it runs out nothing will happen? I gotta remove some stuff too in next function!

v3x 03-28-2005 18:30

Code:
#include <amxmodx> #include <fun> new timer = 15 public plugin_init() {     register_plugin("Hudmessage with task","dunno","LynX")     register_clcmd("hudmessage","hudmessage") } public hudmessage(id) {     if(timer > 0){         set_hudmessage(200,0,0, 0.03, 0.76, 2, 0.02, 1.0, 0.01, 0.1, 2)         show_hudmessage(id,"Task finishes in %d seconds",timer)         timer--         set_task(1.0,"hudmessage",id)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED }


All times are GMT -4. The time now is 09:51.

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