AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check value of a cvar for x seconds (https://forums.alliedmods.net/showthread.php?t=229073)

Bladell 11-01-2013 07:51

Check value of a cvar for x seconds
 
How can I check, for example, if mp_timelimit value is 20 for x seconds?

alan_el_more 11-01-2013 08:32

Re: Check
 
Check this

Bladell 11-01-2013 09:20

Re: Check
 
Sure, thnaks...I still wait a answer.

alan_el_more 11-01-2013 10:33

Re: Check
 
Quote:

Use descriptive topic titles. People should know at a glance of the title what the thread is about.

Bladell 11-01-2013 10:55

Re: Check value of a cvar for x seconds
 
Done, hope you are happy now because I really need some help asap.

fysiks 11-01-2013 10:56

Re: Check value of a cvar for x seconds
 
Quote:

Originally Posted by Bladell (Post 2055473)
How can I check, for example, if mp_timelimit value is 20 for x seconds?

Your request doesn't make any sense. What are you actually trying to accomplish?

Bladell 11-04-2013 11:46

Re: Check value of a cvar for x seconds
 
I have a problem with a plugin but I don't know how to solve it.The problem is that sometimes sv_maxspeed is blocked at 0 and players can't play untill change of map.So, I want to check if sv_maxspeed is 0 for more than 30 seconds, if yes, change the map to dust2.
Don't ask me to post here the source of plugin because I don't have it yet...

YamiKaitou 11-04-2013 11:51

Re: Check value of a cvar for x seconds
 
Wouldn't it make more sense to try and figure out why you are having this issue than to create a plugin to workaround it? If you know the plugin that is causing the issue, go bug the author to fix it

Bladell 11-04-2013 12:07

Re: Check value of a cvar for x seconds
 
I think that is because of podbot module...

Code:

public plugin_init() {
        set_task(1.0, "check_cvar", _, _, _, "b")
}
       
public check_cvar() {
        new i;
        if(get_cvar_num("sv_maxspeed") <= 100)
                i++;

        if(i>=30)
                server_cmd("amx_map de_dust2")
}

Should work, right?

About the plugin...it's Super map chooser, but the author announced that the plugin have a lot of bugs and he will not update it.So...the source from alliedmodders isn't good.I fixed this plugin a few weeks ago, but I lost the source.
Trying to remove all bugs again isn't an option because I don't have enough time to make again 100 tests...I think that this is the reason because the author left this plugin.
Is my method good?

YamiKaitou 11-04-2013 12:12

Re: Check value of a cvar for x seconds
 
Quote:

Originally Posted by Bladell (Post 2056810)
I think that is because of podbot module...

Code:

public plugin_init() {
        set_task(1.0, "check_cvar", _, _, _, "b")
}
       
public check_cvar() {
        new i;
        if(get_cvar_num("sv_maxspeed") <= 100)
                i++;

        if(i>=30)
                server_cmd("amx_map de_dust2")
}

Should work, right?

No, because i will always be 0 at the start of the check. Move i to be a global variable and then it will work. Though, you should use PCVARs and reset i to 0 when it detects that it is higher than 100


All times are GMT -4. The time now is 23:16.

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