AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Rotate server_cmd() (https://forums.alliedmods.net/showthread.php?t=205974)

chungsy 01-17-2013 01:58

Rotate server_cmd()
 
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?
}

YamiKaitou 01-17-2013 02:04

Re: Rotate server_cmd()
 
Show us your exact code, because what you have shown us doesn't cause the map to change

fysiks 01-17-2013 02:04

Re: Rotate server_cmd()
 
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.

simanovich 01-18-2013 03:12

Re: Rotate server_cmd()
 
Inf. loop of execing config file, not recommanded

chungsy 01-20-2013 20:31

Re: Rotate server_cmd()
 
Quote:

Originally Posted by fysiks (Post 1874839)
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?

YamiKaitou 01-20-2013 20:40

Re: Rotate server_cmd()
 
What is in the files? The code isn't causing the server to restart...

chungsy 01-21-2013 16:39

Re: Rotate server_cmd()
 
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.

fysiks 01-21-2013 18:02

Re: Rotate server_cmd()
 
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++



chungsy 01-26-2013 02:25

Re: Rotate server_cmd()
 
#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?

chungsy 01-26-2013 02:29

Re: Rotate server_cmd()
 
Quote:

Originally Posted by YamiKaitou (Post 1877163)
What is in the files? The code isn't causing the server to restart...


I know right, but Pretty sure thats what happened, which is weird.

You will be amaze when you find out how many "Mapchange to de_dust2" are there in the log file.

-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
-------- Mapchange to de_dust2 --------
.......


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

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