Gmcommand : Creation Tutorial

If you want to help us or give some corrections / codes, put it here :)

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Gmcommand : Creation Tutorial

Postby BlackLousky on Sat Apr 19, 2008 10:24 pm

Small Tutorial on "How to create your first own 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:
  1.     int Command_Mute;
  2.     int Command_Tele;
  3.     int Command_Level;


Under it add:
  1.     int Command_ABC; // ABC = name of the GMcommand



In World Server/WorldServer.h Find
  1.        bool pakGMChangeFairyStay(CPlayer* thisclient, int newvalue);
  2.         bool pakGMChangeFairyTestMode(CPlayer* thisclient, int mode);
  3.         bool pakGMTelePlayerHere( CPlayer* thisclient, char* name );


After Add
  1.        bool pakGMABC ( CPlayer* thisclient, char* name);  // ABC = name of the GMcommand



In World Server/worldserver.cpp Find
  1.    Config.Command_Info = ConfigGetInt    ( "commands.ini", "info", 299 );
  2.     Config.Command_IQuest = ConfigGetInt    ( "commands.ini", "iquest", 299 );
  3.     Config.Command_Item = ConfigGetInt    ( "commands.ini", "item", 299 );


After Add
  1.    Config.Command_ABC = ConfigGetInt ( "commands.ini", "abc", 299 );  // ABC, abc = name, call of the GMcommand



In World Server/gmcmds.cpp Find
  1.    if (strcmp(command, "tele")==0) // **** TELEPORT TO MAX AND X Y POINTS *****
  2.     {
  3.         if(Config.Command_Tele > thisclient->Session->accesslevel)
  4.                         return true;
  5.         if ((tmp = strtok(NULL, " "))==NULL) return true; unsigned map=atoi(tmp);
  6.         if ((tmp = strtok(NULL, " "))==NULL) return true; float x=(float)atoi(tmp);
  7.         if ((tmp = strtok(NULL, " "))==NULL) return true; float y=(float)atoi(tmp);
  8.         Log( MSG_GMACTION, " %s : /tele %i,%i,%i" , thisclient->CharInfo->charname, map, x, y);    
  9.         return pakGMTele(thisclient, map, x, y);
  10.     }


After Add
  1.   else if (strcmp(command, "abc")==0) // abc = call of the GMcommand
  2.    {
  3.         if(Config.Command_ABC > thisclient->Session->accesslevel) // ABC = name of the GMcommand
  4.         return true;
  5.         if ((tmp = strtok(NULL, " "))==NULL) return true; char* name=tmp;
  6.         Log( MSG_GMACTION, " %s : /abc %s", thisclient->CharInfo->charname, name); // abc = call of the GMcommand
  7.         return pakGMABC(thisclient, name); // ABC = name of the GMcommand
  8.         }


To End Of File Add
  1. //GM: ABC : returns the job of teh character
  2.     bool CWorldServer::pakGMABC(CPlayer* thisclient, char* name) // ABC = name of the GMcommand
  3. {
  4.     int classid = thisclient->CharInfo->Job;
  5.     CPlayer* otherclient = GetClientByCharName( name );
  6.     if(otherclient==NULL)
  7.     return true;
  8. if ( classid == 321 ) //Raider
  9.     {   SendPM (thisclient, "job : Raider"); }
  10. else if ( classid == 121 ) //Knight
  11.     {   SendPM (thisclient, "job : Knight"); }
  12. else if ( classid == 122 ) //Champion
  13.     {   SendPM (thisclient, "job : Champion"); }
  14. else if ( classid == 222 ) //Cleric
  15.     {   SendPM (thisclient, "job : Cleric"); }
  16. else if ( classid == 221 ) //Mage
  17.     {   SendPM (thisclient, "job : Mage"); }
  18. else if ( classid == 322 ) //Scout
  19.     {   SendPM (thisclient, "job : Scout"); }
  20. else if ( classid == 422 ) //Artisan
  21.     {   SendPM (thisclient, "job : Artisan"); }
  22. else if ( classid == 421 ) //Bourgeois
  23.     {   SendPM (thisclient, "job : Bourgeois"); }
  24. else
  25.     {   SendPM (thisclient, "job : not 2nd job"); }
  26.  
  27.     return true;
  28. }



In Binary/commands.ini Find
  1.    Ani=299
  2.     Ann=299
  3.     Ban=299
  4.     Cha=299


Before Add



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 :
  1. //GM: MyCommand01
  2.     bool CWorldServer::pakGMMyCommand01(CPlayer* thisclient, char* name)
  3. {
  4.     CPlayer* otherclient = GetClientByCharName( name );
  5.     if(otherclient==NULL)
  6.     return true;
  7.  
  8.     {  
  9.         char obuffer[200];
  10.         sprintf ( obuffer, "%s is level %i", otherclient->CharInfo->charname, otherclient->Stats->Level );
  11.         SendPM(thisclient, obuffer);
  12.     }
  13.  
  14.     return true;
  15. }

This last example code is just an illustration and was not tested.
Last edited by BlackLousky on Sun Apr 20, 2008 12:00 am, edited 1 time in total.
BlackLousky
Little soul
Little soul
 
Posts: 8
Joined: Sat Apr 19, 2008 8:50 pm

Re: Gmcommand : Creation Tutorial

Postby Sethanye on Sat Apr 19, 2008 11:25 pm

nice tut, the command isnt that useful probably but still good job for the effort of writing all that ^.^
~ Learning Flash ~ Anyone Know Any Good Tutorial DVDs? ~
Image
"Come Into My Dream, Let Me Show You Where I've Been.
Its You And Me I've Seen, Let Me Tell You What I Mean."
User avatar
Sethanye
Neko Chan
Neko Chan
 
Posts: 2603
Joined: Fri Jan 18, 2008 11:23 am
Location: ~ Resident Graphics Artist ~

Re: Gmcommand : Creation Tutorial

Postby BlackLousky on Sun Apr 20, 2008 12:04 am

Ty, "clap clap clap".

It's my first day in osiRose code.

I don't know c++.
Usually, i'm working with PHP, sql.

I have some ideas and will make more useful for sure.
BlackLousky
Little soul
Little soul
 
Posts: 8
Joined: Sat Apr 19, 2008 8:50 pm

Re: Gmcommand : Creation Tutorial

Postby Sethanye on Sun Apr 20, 2008 1:41 am

your welcome, and welcome aboard osrose too ^.^
~ Learning Flash ~ Anyone Know Any Good Tutorial DVDs? ~
Image
"Come Into My Dream, Let Me Show You Where I've Been.
Its You And Me I've Seen, Let Me Tell You What I Mean."
User avatar
Sethanye
Neko Chan
Neko Chan
 
Posts: 2603
Joined: Fri Jan 18, 2008 11:23 am
Location: ~ Resident Graphics Artist ~

Re: Gmcommand : Creation Tutorial

Postby Souleater on Sun May 04, 2008 11:29 pm

welcome blacklousky :)
( I guess it's the blacklousky that I know huh ? :o )
Image
Souleater
Antares
Antares
 
Posts: 355
Joined: Thu Aug 09, 2007 10:59 pm

Re: Gmcommand : Creation Tutorial

Postby BlackLousky on Thu May 08, 2008 10:59 am

Yes for sure i am.

@Souleater : salut, comment ca va bien ?

Après des mois d'absence, je pense me repencher un peu sur un Pserv Rose.

J'ai hélas cru m'apercevoir de la mort de rose-emulation.

En tout cas, ravi de te revoir.
Je crois pouvoir dire sans risque de me tromper que t'es un des meilleurs de la scène fr.
BlackLousky
Little soul
Little soul
 
Posts: 8
Joined: Sat Apr 19, 2008 8:50 pm

Re: Gmcommand : Creation Tutorial

Postby Souleater on Thu May 08, 2008 7:39 pm

@black :
Hihi, merci ^^( mais n'oublis pas lmame :D )
Et oui rose-emu est morte depuis un moment, et pour être je ne suis pas prêt à me remettre dans un projet du genre, cette board est suffisante et est assez connue :)
Image
Souleater
Antares
Antares
 
Posts: 355
Joined: Thu Aug 09, 2007 10:59 pm


Return to Submit Code

Who is online

Users browsing this forum: No registered users and 7 guests

cron