Change map [message #437234] |
Thu, 30 September 2010 10:15 |
|
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!
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 #437343 is a reply to message #437235] |
Sat, 02 October 2010 09:09 |
|
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
|
"mlistc %d %s" I've never heard of that... is that a legitimate stock ssgm command?
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 |
|
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
|
"mlistc %d %s" I've never heard of that... is that a legitimate stock ssgm command?
|
Its a scripts console command
|
|
|
Re: Change map [message #437351 is a reply to message #437234] |
Sat, 02 October 2010 11:05 |
|
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
|
|
|