[Mod] gmcmd /go Using SQL

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

[Mod] gmcmd /go Using SQL

Postby likolfly on Mon Mar 21, 2011 4:08 pm

My first post :P
sorry my english so bad hope you can reading :oops:

change file
/World Server/gmcmds.cpp

find
  1.  
  2. else if (strcmp(command, "go")==0) // AtCommandGo
  3. {
  4.         if(Config.Command_go > thisclient->Session->accesslevel)
  5.         .................
  6.         .................
  7. }
  8.  


Replace
  1.  
  2. else if (strcmp(command, "go")==0) // Use SQL by Likol
  3.     {
  4.         if(Config.Command_go > thisclient->Session->accesslevel) return true;
  5.         if ((tmp = strtok(NULL, " ")) == NULL) tmp = 0;
  6.         int loc = atoi(tmp);
  7.         int x = 0;
  8.         int y = 0;
  9.         int map = 0;
  10.         MYSQL_ROW row;
  11.         MYSQL_RES *result = NULL;
  12.         result = DB->QStore("SELECT lvlmin,map,locx,locy,mapname,lvlmax FROM list_golist WHERE isactive=1 AND loc=%i",loc);
  13.         row = mysql_fetch_row(result);
  14.         if (row==NULL)
  15.         {
  16.             SendPM(thisclient, "Please input a number after the go command, below is a list of places and their appropriate number");
  17.             DB->QFree( );
  18.             result = DB->QStore("SELECT loc,mapname FROM list_golist WHERE isactive=1");
  19.             while(row = mysql_fetch_row(result)) SendPM(thisclient, "%i = %s",atoi(row[0]),row[1]);
  20.             SendPM(thisclient, "Example; /go 1");
  21.             DB->QFree( );
  22.             return true;
  23.         }
  24.         else
  25.         {
  26.             if (thisclient->Stats->Level<atoi(row[0]))
  27.             {
  28.                 SendPM(thisclient, "You need to be a least Level %i to visit %s!",atoi(row[0]),row[4]);
  29.                 DB->QFree( );
  30.                 return true;
  31.             }
  32.             if (thisclient->Stats->Level>atoi(row[5]))
  33.             {
  34.                 SendPM(thisclient, "You need to be between Level %i and %i to visit %s !",atoi(row[0]),atoi(row[5]),row[4]);
  35.                 DB->QFree( );
  36.                 return true;
  37.             }
  38.             if ( thisclient->Stats->HP < (thisclient->Stats->MaxHP / 2) || thisclient->Stats->HP < 1 || thisclient->Session->inGame == false )
  39.             {
  40.                     SendPM(thisclient, "You need at least 50% HP in order to warp");
  41.                     return true;
  42.             }
  43.                 int map = atoi(row[1]);
  44.                 int x = atoi(row[2]);
  45.                 int y = atoi(row[3]);
  46.                 int noqsd = 1;
  47.                 SendPM(thisclient, "Teleport to %s .",row[4]);
  48.                 DB->QFree( );
  49.                 return pakGMTele(thisclient, map, x, y,noqsd);
  50.         }
  51.     }
  52.  


and you need add list_golist.sql to your mysql database

Now you can add /delete your go list in sql :lol:
Attachments
list_golist.rar
(918 Bytes) Downloaded 672 times
Last edited by likolfly on Mon Mar 21, 2011 4:14 pm, edited 1 time in total.
likolfly
Little soul
Little soul
 
Posts: 1
Joined: Fri Mar 18, 2011 11:00 am

Re: [Mod] gmcmd /go Using SQL

Postby rl2171 on Mon Mar 21, 2011 4:14 pm

Nice job, much better than recompiling the EXE each time, just have it in SQL.
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Mod] gmcmd /go Using SQL

Postby merlon on Thu Mar 24, 2011 4:52 pm

great job!
User avatar
merlon
Antares
Antares
 
Posts: 359
Joined: Fri Jul 09, 2010 2:15 pm

Re: [Mod] gmcmd /go Using SQL

Postby WiseGuy on Wed Jun 08, 2011 1:19 am

small fix here
http://forum.dev-osrose.com/viewtopic.php?t=4979&p=51487#p51487

crash world server if player HP less than 50%
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta


Return to Submit Code

Who is online

Users browsing this forum: No registered users and 2 guests