- int Command_ABC; // ABC = name of the GMcommand
based on the source code of : /allskill {By CrAshInSiDe}
GMcommand :
example : GMcommande "ABC"
inGame, this GMcommand will be called by : /abc CHARNAME
The goal of this command is really simple, it returns the job of the character.
Code :
Files to modify :
- common/sockets.h
- World Server/worldserver.cpp
- World Server/gmcmds.cpp
- Binary/commands.ini
In worldserver.cpp find:
- int Command_Mute;
- int Command_Tele;
- int Command_Level;
Under it add:
In World Server/WorldServer.h Find
- bool pakGMChangeFairyStay(CPlayer* thisclient, int newvalue);
- bool pakGMChangeFairyTestMode(CPlayer* thisclient, int mode);
- bool pakGMTelePlayerHere( CPlayer* thisclient, char* name );
After Add
- bool pakGMABC ( CPlayer* thisclient, char* name); // ABC = name of the GMcommand
In World Server/worldserver.cpp Find
- Config.Command_Info = ConfigGetInt ( "commands.ini", "info", 299 );
- Config.Command_IQuest = ConfigGetInt ( "commands.ini", "iquest", 299 );
- Config.Command_Item = ConfigGetInt ( "commands.ini", "item", 299 );
After Add
- Config.Command_ABC = ConfigGetInt ( "commands.ini", "abc", 299 ); // ABC, abc = name, call of the GMcommand
In World Server/gmcmds.cpp Find
- if (strcmp(command, "tele")==0) // **** TELEPORT TO MAX AND X Y POINTS *****
- {
- if(Config.Command_Tele > thisclient->Session->accesslevel)
- return true;
- if ((tmp = strtok(NULL, " "))==NULL) return true; unsigned map=atoi(tmp);
- if ((tmp = strtok(NULL, " "))==NULL) return true; float x=(float)atoi(tmp);
- if ((tmp = strtok(NULL, " "))==NULL) return true; float y=(float)atoi(tmp);
- Log( MSG_GMACTION, " %s : /tele %i,%i,%i" , thisclient->CharInfo->charname, map, x, y);
- return pakGMTele(thisclient, map, x, y);
- }
After Add
- else if (strcmp(command, "abc")==0) // abc = call of the GMcommand
- {
- if(Config.Command_ABC > thisclient->Session->accesslevel) // ABC = name of the GMcommand
- return true;
- if ((tmp = strtok(NULL, " "))==NULL) return true; char* name=tmp;
- Log( MSG_GMACTION, " %s : /abc %s", thisclient->CharInfo->charname, name); // abc = call of the GMcommand
- return pakGMABC(thisclient, name); // ABC = name of the GMcommand
- }
To End Of File Add
- //GM: ABC : returns the job of teh character
- bool CWorldServer::pakGMABC(CPlayer* thisclient, char* name) // ABC = name of the GMcommand
- {
- int classid = thisclient->CharInfo->Job;
- CPlayer* otherclient = GetClientByCharName( name );
- if(otherclient==NULL)
- return true;
- if ( classid == 321 ) //Raider
- { SendPM (thisclient, "job : Raider"); }
- else if ( classid == 121 ) //Knight
- { SendPM (thisclient, "job : Knight"); }
- else if ( classid == 122 ) //Champion
- { SendPM (thisclient, "job : Champion"); }
- else if ( classid == 222 ) //Cleric
- { SendPM (thisclient, "job : Cleric"); }
- else if ( classid == 221 ) //Mage
- { SendPM (thisclient, "job : Mage"); }
- else if ( classid == 322 ) //Scout
- { SendPM (thisclient, "job : Scout"); }
- else if ( classid == 422 ) //Artisan
- { SendPM (thisclient, "job : Artisan"); }
- else if ( classid == 421 ) //Bourgeois
- { SendPM (thisclient, "job : Bourgeois"); }
- else
- { SendPM (thisclient, "job : not 2nd job"); }
- return true;
- }
In Binary/commands.ini Find
- Ani=299
- Ann=299
- Ban=299
- Cha=299
Before Add
- ABC=299
how to create your own GMcommand ?
- - Name of the command
Replace the 2 words in red by your own :
ABC : the name of your command in the Server
abc : the name used to call your command
for exemple : MyCommand01 for the name and com01 for the call
- - Want give access to all players at te fonction ?
Only, change value 299 to 99 in the commands.ini file
- - Create your own command
Modify the "to End of file add" part in the gmcmds.cpp file
for example :
- //GM: MyCommand01
- bool CWorldServer::pakGMMyCommand01(CPlayer* thisclient, char* name)
- {
- CPlayer* otherclient = GetClientByCharName( name );
- if(otherclient==NULL)
- return true;
- {
- char obuffer[200];
- sprintf ( obuffer, "%s is level %i", otherclient->CharInfo->charname, otherclient->Stats->Level );
- SendPM(thisclient, obuffer);
- }
- return true;
- }
This last example code is just an illustration and was not tested.