Raised This Month: $ Target: $400
 0% 

Rotate server_cmd()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
chungsy
Member
Join Date: Nov 2011
Old 01-17-2013 , 01:58   Rotate server_cmd()
Reply With Quote #1

How do I keep rotating a server_cmd() for a certain amount for time?

I tried to do the following but failed the map changes when I tried to make it repeat :


public START(id, level, cid)
{
server_cmd("exec ^"%s^"", COMMANDHERE);

set_task(30,"REPEAT");
}

public REPEAT(id, level, cid)
{
server_cmd("exec ^"%s^"", COMMANDTWOHERE);

set_task(30, "START"); <-- The map will change here, how to slove it?
}

Last edited by chungsy; 01-17-2013 at 01:59.
chungsy is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-17-2013 , 02:04   Re: Rotate server_cmd()
Reply With Quote #2

Show us your exact code, because what you have shown us doesn't cause the map to change
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-17-2013 , 02:04   Re: Rotate server_cmd()
Reply With Quote #3

You might need to explain that better. Are you trying to just alternate the file that you execute? I.e. Execute file_one.cfg then execute file_two.cfg then execute file_one.cfg then execute file_two.cfg etc.
__________________
fysiks is offline
chungsy
Member
Join Date: Nov 2011
Old 01-20-2013 , 20:31   Re: Rotate server_cmd()
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
You might need to explain that better. Are you trying to just alternate the file that you execute? I.e. Execute file_one.cfg then execute file_two.cfg then execute file_one.cfg then execute file_two.cfg etc.

Yes. But when its time to execute file one again, the server restarts.

Can you show me how to do that?

Last edited by chungsy; 01-20-2013 at 20:32.
chungsy is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 01-18-2013 , 03:12   Re: Rotate server_cmd()
Reply With Quote #5

Inf. loop of execing config file, not recommanded
__________________
simanovich is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-20-2013 , 20:40   Re: Rotate server_cmd()
Reply With Quote #6

What is in the files? The code isn't causing the server to restart...
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
chungsy
Member
Join Date: Nov 2011
Old 01-21-2013 , 16:39   Re: Rotate server_cmd()
Reply With Quote #7

I actually don't know how to write, but fysiks was right ->Execute file_one.cfg then execute file_two.cfg then execute file_one.cfg then execute file_two.cfg etc.


public START(id, level, cid)
{
server_cmd("exec ^"%s^"", COMMANDHERE);

set_task(30,"REPEAT");
}

public REPEAT(id, level, cid)
{
server_cmd("exec ^"%s^"", COMMANDTWOHERE);

set_task(30, "START"); <-- I WAS TRYING TO EXECUTE THE FIRST TAST AGAIN


thats all I did. Can someone quickly show me some examples? Just repeating it.

Last edited by chungsy; 01-21-2013 at 16:41.
chungsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-21-2013 , 18:02   Re: Rotate server_cmd()
Reply With Quote #8

In your original post you said something about "failed the map changes" and nobody know what that means.

To do what I described I would do something like this:

PHP Code:
new g_iCounter 0
new g_szCfgs[][] = {
    
"cfg_one.cfg",
    
"cfg_two.cfg"
}

// plugin_init()
    
set_task(30.0"myTask", .repeat=1)
    
public 
myTask()
{
    
server_cmd("exec %s"g_szCfgs[g_iCounter sizeof(g_szCfgs)])
    
g_iCounter++

__________________
fysiks is offline
chungsy
Member
Join Date: Nov 2011
Old 01-26-2013 , 02:25   Re: Rotate server_cmd()
Reply With Quote #9

#include <amxmodx>
#include <amxmisc>
#define PLUGIN "exec cfg"
#define VERSION "1.0"
#define AUTHOR "chungsy"
#define LOADING "^n^t%s v%s, Copyright (C) 2013 by %s^n"

new g_iCounter = 0
new g_szCfgs[][] = {
"cfg_one.cfg",
"cfg_two.cfg"
}

public plugin_init()
{
register_plugin("PLUGIN", "VERSION", "AUTHOR");
server_print("LOADING", "PLUGIN", "VERSION", "AUTHOR");
set_task(30.0, "myTask", .repeat=1)
}

public myTask()
{
server_cmd("exec %s", g_szCfgs[g_iCounter % sizeof(g_szCfgs)])
g_iCounter++
}




The code doesn't work for some reason. If the one above works, thats good, but what if I want to exec the first cfg for 30s and the 2nd one for 10s? Can you make it more flexible?

Last edited by chungsy; 01-27-2013 at 15:59.
chungsy is offline
chungsy
Member
Join Date: Nov 2011
Old 01-27-2013 , 13:12   Re: Rotate server_cmd()
Reply With Quote #10

Quote:
Originally Posted by chungsy View Post
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "exec cfg"
#define VERSION "1.0"
#define AUTHOR "fysiks!"
#define LOADING "^n^t%s v%s, Copyright (C) 2013 by %s^n"

new g_iCounter = 0
new g_szCfgs[][] = {
"cfg_one.cfg",
"cfg_two.cfg"
}

public plugin_init()
{
register_plugin("PLUGIN", "VERSION", "AUTHOR");
server_print("LOADING", "PLUGIN", "VERSION", "AUTHOR");
set_task(30.0, "myTask", .repeat=1)
}

public myTask()
{
server_cmd("exec %s", g_szCfgs[g_iCounter % sizeof(g_szCfgs)])
g_iCounter++
}




The code doesn't work for some reason. If the one above works, thats good, but what if I want to exec the first cfg for 30s and the 2nd one for 10s? Can you make it more flexible?

Posted already. I want to change a plugin Cvar.

Last edited by chungsy; 01-27-2013 at 13:19.
chungsy 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 23:56.


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