Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Change map
Change map [message #437234] Thu, 30 September 2010 10:15 Go to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
Hey guys I've looked everywhere but I can't seem to find out how to change the current map to a specified one.

Any help is appreciated,
thanks!


http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Re: Change map [message #437235 is a reply to message #437234] Thu, 30 September 2010 12:01 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
IDK a way to do it within scripts at once but I do know a work around.

(pseudo-real)
char *actionMainSave;
cmd = strtok_s((char *)message, " ", &actionMainSave);
map = strtok_s(NULL, "\r\n", &actionMainSave);

if(strcmp(cmd, "!setnextmap") == 0)
{
	Console_Input(StrFormat("mlistc %d %s", The_Game()->MapNumber + 1, map).c_str());
	Console_Input(StrFormat("msg Next map changed to: %s", map).c_str());
}


Then just gameover the current game Smile


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg
Re: Change map [message #437237 is a reply to message #437234] Thu, 30 September 2010 12:07 Go to previous messageGo to next message
cAmpa is currently offline  cAmpa
Messages: 597
Registered: March 2006
Karma: 0
Colonel
Server RR got the console command "map <map>".

Bückstabü!
Re: Change map [message #437254 is a reply to message #437234] Thu, 30 September 2010 14:29 Go to previous messageGo to next message
Ethenal is currently offline  Ethenal
Messages: 2532
Registered: January 2007
Location: US of A
Karma: 0
General (2 Stars)

Typically bots simply insert a map after the current one into the rotation then end the map. I think BR uses a "mapnum" command or something that tells it which entry the server is on, then it adds the chosen map into the entry right after it (moving the actual next map one slot forward). I don't think there's an actual built-in way to switch to a chosen map, but that usually works fine.

-TLS-DJ-EYE-K wrote on Mon, 18 March 2013 07:29

Instead of showing us that u aren't more inteligent than a Toast, maybe you should start becomming good in renegade Thumbs Up

Re: Change map [message #437343 is a reply to message #437235] Sat, 02 October 2010 09:09 Go to previous messageGo to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
Omar007 wrote on Thu, 30 September 2010 14:01

IDK a way to do it within scripts at once but I do know a work around.

(pseudo-real)
char *actionMainSave;
cmd = strtok_s((char *)message, " ", &actionMainSave);
map = strtok_s(NULL, "\r\n", &actionMainSave);

if(strcmp(cmd, "!setnextmap") == 0)
{
	Console_Input(StrFormat("mlistc %d %s", The_Game()->MapNumber + 1, map).c_str());
	Console_Input(StrFormat("msg Next map changed to: %s", map).c_str());
}


Then just gameover the current game Smile



"mlistc %d %s" I've never heard of that... is that a legitimate stock ssgm command?


http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Re: Change map [message #437350 is a reply to message #437343] Sat, 02 October 2010 11:04 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
halo2pac wrote on Sat, 02 October 2010 18:09

Omar007 wrote on Thu, 30 September 2010 14:01

IDK a way to do it within scripts at once but I do know a work around.

(pseudo-real)
char *actionMainSave;
cmd = strtok_s((char *)message, " ", &actionMainSave);
map = strtok_s(NULL, "\r\n", &actionMainSave);

if(strcmp(cmd, "!setnextmap") == 0)
{
	Console_Input(StrFormat("mlistc %d %s", The_Game()->MapNumber + 1, map).c_str());
	Console_Input(StrFormat("msg Next map changed to: %s", map).c_str());
}


Then just gameover the current game Smile



"mlistc %d %s" I've never heard of that... is that a legitimate stock ssgm command?

Its a scripts console command Smile


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg
Re: Change map [message #437351 is a reply to message #437234] Sat, 02 October 2010 11:05 Go to previous message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
This is the source to my randon rotation plugin, it shows clearly how to changhe the next map.

#include "scripts.h"
#include <stdarg.h>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include "engine.h"
#include "gmmain.h"
#include <time.h>
#include "randomrotation.h"


RRSettingsStruct *RRSettings = 0;
char *mapname;
std::vector<int> LastMaps;


void RRSettingsStruct::Load() {
	SettingsLoader::Load();
	LoadInt(PreviousLimit,"PreviousLimit", 5, true, false, true);
}


int Get_Random_Int_Not_Crap(int n){
return rand() % n;
}


//This just announces what the next map will be. The global variable "mapname" gets set by the request random map code.
void mapnameannounce(){
Console_Input(StrFormat("msg The next map will be %s",mapname).c_str());
}


//This function basically updates the most recently played maps, by pushing them along One each time One is added, then "trimming" the vector using .resize()
//How many maps are kept track of depend on the setting in the ini file.
void addmap(int MapNumber){
	LastMaps.push_back(MapNumber);
	for(int i = 0; i <= RRSettings->PreviousLimit - 1; i++){
		LastMaps[i] = LastMaps[i + 1];
	}
	LastMaps.resize(RRSettings->PreviousLimit, MapNumber);
}




//This is the function that makes the next map a random one from the current list of maps on your server.
//You can call it at any time with "requestrandommap();".
void requestrandommap(){
    //I initialise and delcare the variable "numberofmaps here"
    int numberofmaps = 0;
    //Many thanks to Roshambo for this nice little "for" loop
    //The loop is basically responsible for getting the amount of maps in the rotation
    for(;*The_Game()->MapList[numberofmaps] != 0; numberofmaps++);
    //I get a random number between 0 (maps use 0 based indexing) and the amount of maps in rotation (hence the need to know the amount of maps).
    int RandomNum = Get_Random_Int_Not_Crap(numberofmaps);
    if (RandomNum + 1 > numberofmaps - 1){
        RandomNum = 0;
    }
    //Code to make sure the next map will never be the same one as the current map
    for(int i = 0; i <= (RRSettings->PreviousLimit - 1); i++){
        if(RandomNum == LastMaps[i]){
            Console_Output("Had to re-request a new map, this One was recently played.\n");
            requestrandommap();
        }
    }
        //This code here makes the server think that the current map is a different one, so it logically will play the map next in the list to the one it thinks is currently being played
        The_Game()->MapNumber = RandomNum;
        //Therefore the next map that will get played is the one after the one that the server thinks is playing right now (but isn't), so this is how I get the name of the next map
        mapname = The_Game()->MapList[RandomNum +1];
        //Just log the next map on the console
        Console_Output("The next map will be: %s\n",mapname);
        //Call the function that announces the next map to be played in-game.
        mapnameannounce();
}



class mapChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		mapnameannounce();	
	}
};
ChatCommandRegistrant<mapChatCommand> mapChatCommandReg("!nextmap;!n;!N;!NEXT;!Nextmap;!next;!NEXTMAP",CHATTYPE_ALL,0,GAMEMODE_ALL);





void Plugin_Load() {
	srand(time(NULL));
	RRSettings = new RRSettingsStruct("RandomRotation.ini");
	printf("Loaded reborns random rotation system plugin\n");
	RRSettings->Load();
	for(int i = 0; i <= RRSettings->PreviousLimit -1; i++){ 
		LastMaps.push_back(-1);
	}

}

void Plugin_Unload() {
	printf("Un-loaded reborns random rotation system plugin\n");
	delete RRSettings;
}




extern "C" {
	DLLEXPORT void SSGM_Level_Loaded_Hook() {
		int numberofmaps = 0;
		for(;*The_Game()->MapList[numberofmaps] != 0; numberofmaps++);
		if(numberofmaps > RRSettings->PreviousLimit){
			addmap(The_Game()->MapNumber); // new map has loaded and is being played, add it to the list of recently played maps
			requestrandommap(); // Choose the next map to be played (even though the current map has just stared)
		}
		else{
			printf("ERROR! You have less maps in rotation than what's set in the RandomRotation.ini file's previous limit key.\n The plugin will not function as you want it to!\n");
		}
	}
}




#include "gmsettingsclass.h"

#define PluginName "reborn's random rotation plugin"
#define PluginVersion "1.1"


struct RRSettingsStruct : public virtual SettingsLoader {
	RRSettingsStruct(const char *ININame) : SettingsLoader(ININame) {
		PreviousLimit = 5;
	}
	void Load();
	int PreviousLimit;
};


int Get_Random_Int_Not_Crap(int n);
void mapnameannounce();
void addmap(int MapNumber);
void requestrandommap();

void Plugin_Load();
void Plugin_Unload();




[Updated on: Sat, 02 October 2010 11:06]

Report message to a moderator

Previous Topic: Measuring and rewarding team work programatically?
Next Topic: vtach/detach command
Goto Forum:
  


Current Time: Tue Aug 06 23:55:16 MST 2024

Total time taken to generate the page: 0.00674 seconds