Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Save all command and banning system!

Status
Not open for further replies.
Initiate Mage
Joined
Apr 5, 2008
Messages
3
Reaction score
0
Credits: 2azn4u for creating the save command first.
Me for the save all characters progress command.
I cant find the thread where i got the banning script, but it was someone from cheatengine.org that made it. Thanks to who ever made it.

sprintfOkay the Save all command will save for all the players, not only the player thats says it.
well just follow these steps for it.

go to 2azn4u thread
Link: http://forum.ragezone.com/f427/release-save-command-382734/
Just do the things he says. Then open up your players.cpp.
add this:

Code:
else if(strcmp(command, "save all") == 0) {
             for (hash_map <int, Player*>::iterator iter = Players::players.begin(); iter != Players::players.end(); iter++)
             iter->second->save();
             PlayersPacket::showMassage("All progress has been saved successfully", 0);
             }
Thats all now just say "!save all" and it will display a message that all progress has been save.

Now to the banning. This will make you able to ban players, just by saying "!ban Playername".
if you wanna unban you need to say "!unban playername".

First open up your MySQL browser and add the banned to the users table.

Code:
ALTER TABLE users ADD banned INT DEFAULT 0;

Okay then you need to open up your MySQLM.cpp
and add these codes.

Code:
void MySQL::ban(int userid){
    char sql[200];
  sprintf_s(sql,200,"UPDATE users SET banned=1 WHERE id=%d;",userid);
        MySQL::insert(sql);
}



void MySQL::unban(int userid){
    char sql[200];
        sprintf_s(sql,200,"UPDATE users SET banned=0 WHERE id=%d;",userid);
        MySQL::insert(sql);
}




int MySQL::getBan(char* username){
   MYSQL_RES *mres;
   MYSQL_ROW mrow;
   char query[255];
    sprintf_s(query, 255, "select banned from users where username='%s';", username);
   mysql_real_query(&maple_db, query, strlen(query));
   printf(mysql_error(&maple_db));
   mres = mysql_store_result(&MySQL::maple_db);
   mrow = mysql_fetch_row(mres);
   printf(mysql_error(&maple_db));
   int ret = 0;
   printf(mysql_error(&maple_db));
   if(mysql_num_fields(mres) > 0){
      string mr = string((char*)mrow[0]);
      istringstream buffer(mr);
      buffer >> ret;
   }
return ret;
}
Thats all you need to do to your MySQLM.cpp

Then open up your MySQLM.h
and add this

Code:
static void ban(int userid);
static void unban(int userid);
static int getBan(char* username);
Just close it.

Then you need to open up your Login.cpp
and add this, instead of the LoginUser and CheckLogin thats already there :

Code:
void Login::loginUser(PlayerLogin* player, unsigned char* packet){
   int usersize = getShort(packet);
   int passsize = getShort(packet+usersize+2);
   char username[MAX_FIELD_SIZE], password[MAX_FIELD_SIZE];
   getString(packet+2, usersize, username);   
   getString(packet+4+usersize, passsize, password);   
   int s = checkLogin(username, password);
   if(s == 1){
      player->setUserid(MySQL::getUserID(username));
      player->setPin(MySQL::getInt("users", player->getUserid(), "pin"));
      int pin = player->getPin();
      if(pin == -1)
         player->setStatus(1); // New PIN
      else
         player->setStatus(2); // Ask for PIN
      player->setGender(MySQL::getInt("users", player->getUserid(), "gender"));
      LoginPacket::loginConnect(player, username, usersize);
   }
   else if(s == 0)
      LoginPacket::loginError(player, 0x04);
   else if(s == -1)
      LoginPacket::loginError(player, 0x05);
   else if(s == 2)
      LoginPacket::loginError(player, 0x03);
}



int Login::checkLogin(char *username, char *password){
   char rpassword[13];
   if(!MySQL::isString("users","username", username)){
      return -1;
   }
   MySQL::getString("users", "username",username,"password", rpassword);
   if(strcmp(rpassword, password) == 0)
   {
      if(MySQL::getBan(username))
         return 2;

      return 1;
   }

   return 0;
   
}
Close you Login.cpp

Then open up your player.cpp
and add the code under "gm = MySQL::getInt("users", MySQL::getInt("characters", getPlayerid(), "userid"), "gm");" :

Code:
userid = MySQL::getInt("characters", getPlayerid(), "userid");
just close player.cpp again.

Now open up your player.h
and add this, you should know where:

Code:
int getUserid(){
return userid;
}
and

Code:
int userid;
close player.h.

Now you just need to add the commands.
open players.cpp add this:

Code:
else if(strcmp(command, "ban") == 0){
            char *name = strtok_s(NULL, " ",&next_token);
            if (strlen(name) > 0)
            for (hash_map <int, Player*>::iterator iter = Players::players.begin(); iter != Players::players.end(); iter++)
            if (strcmp(iter->second->getName(), name) == 0)
                MySQL::ban(iter->second->getUserid());
             }



else if(strcmp(command, "unban") == 0){
            char *name = strtok_s(NULL, " ",&next_token);
            if (strlen(name) > 0)
            for (hash_map <int, Player*>::iterator iter = Players::players.begin(); iter != Players::players.end(); iter++)
            if (strcmp(iter->second->getName(), name) == 0)
                MySQL::unban(iter->second->getUserid());
             }

And remember to check if MySQLM.h is included in your players.cpp

Now youre done! Enjoy. xD :flag_schw
BTW this is my first release. The next thing im working on is some skills like haste.
 
Last edited:
Experienced Elementalist
Joined
Apr 2, 2008
Messages
255
Reaction score
0
Re: [Release] !Save all command and banning system!

i cant click any npc when im using the !save from 2azn4u u might know why?
 
Initiate Mage
Joined
Apr 5, 2008
Messages
3
Reaction score
0
Re: [Release] !Save all command and banning system!

Sorry i cant help you, dont know the problem. :pinch:
 
Newbie Spellweaver
Joined
Apr 4, 2008
Messages
7
Reaction score
0
Re: [Release] !Save all command and banning system!

int MySQL::getBan(char* username){
MYSQL_RES *mres;
MYSQL_ROW mrow;
char query[255];
sprintf_s(query, 255, "select banned from users where username='%s';", username);
mysql_real_query(&maple_db, query, strlen(query));
printf(mysql_error(&maple_db));
mres = mysql_store_result(&MySQL::maple_db);
mrow = mysql_fetch_row(mres);
printf(mysql_error(&maple_db));
int ret = 0;
printf(mysql_error(&maple_db));
if(mysql_num_fields(mres) > 0){
string mr = string((char*)mrow[0]);
istringstream buffer(mr);
buffer >> ret;
}
return ret;
}


I believe that is how it should finish, it seems to work for me.

this code is giving me problems
and I believe you forgot to add a second '}'

mysqlm.cpp(289) : error C4716: 'MySQL::getBan' : must return a value

also in players.cpp i believe you have to add #include "MySQLM.h"
to the top
 
Newbie Spellweaver
Joined
Apr 8, 2008
Messages
14
Reaction score
0
Re: [Release] !Save all command and banning system!

i had 5 errors and fixed them all.
you have to put an extra } in MySQLM.cpp
and you have to put #include "MySQLM.h" at the top of players.cpp :)

oh lol pete said it already :p

i get another error when i try to compile again.

mysqlm.cpp(288) : error C4716: 'MySQL::getBan' : must return a value
 
Newbie Spellweaver
Joined
Mar 8, 2008
Messages
21
Reaction score
0
Re: [Release] !Save all command and banning system!

I also get:
mysqlm.cpp(288) : error C4716: 'MySQL::getBan' : must return a value
 
Newbie Spellweaver
Joined
Apr 2, 2008
Messages
89
Reaction score
1
Re: [Release] !Save all command and banning system!

3>Players.cpp
3>.\Players.cpp(69) : error C2653: 'MySQL' : is not a class or namespace name
3>.\Players.cpp(69) : error C3861: 'ban': identifier not found
3>.\Players.cpp(76) : error C2653: 'MySQL' : is not a class or namespace name
3>.\Players.cpp(76) : error C3861: 'unban': identifier not found

i got that error can someone help me

EDIT - nvm fixed it but have another error

3>c:\documents and settings\admin\my documents\rev006\maplestoryserver\maplestoryserver\mysqlm.cpp(284) : error C4716: 'MySQL::getBan' : must return a value
3>LINK : fatal error LNK1257: code generation failed
 
Newbie Spellweaver
Joined
Apr 5, 2008
Messages
40
Reaction score
0
Re: [Release] !Save all command and banning system!

Now open up your player.h
and add this, you should know where:

Code:
int getUserid(){
return userid;
}
and

Code:
int userid;
close player.h.

[/quote]

Can u tell me where? i couldnt find it..
 
Elite Diviner
Joined
Feb 28, 2007
Messages
446
Reaction score
4
Re: [Release] !Save all command and banning system!

I;m getting this

Code:
c:\documents and settings\compaq\desktop\krytical2\maplestoryserver\mysqlm.cpp(288) : error C4716: 'MySQL::getBan' : must return a value
 
Newbie Spellweaver
Joined
Apr 7, 2008
Messages
5
Reaction score
0
Re: [Release] !Save all command and banning system!

c:\documents and settings\administrator\desktop\maple\maplestoryserver\Player.h(38) : error C2039: 'userid' : is not a member of 'Player'
c:\documents and settings\administrator\desktop\maple\maplestoryserver\Player.h(21) : see declaration of 'Player'

how to fix this?
 
Newbie Spellweaver
Joined
Apr 8, 2008
Messages
17
Reaction score
0
Re: [Release] !Save all command and banning system!

Code:
1>c:\users\matt\desktop\private server\maplestoryserver\mysqlm.cpp(57) : error C4716: 'MySQL::getBan' : must return a value

Thats the only error i get
 
Newbie Spellweaver
Joined
Apr 5, 2008
Messages
40
Reaction score
0
Re: [Release] !Save all command and banning system!

can any 1 tell me where to put the
int getUserid(){
return userid;
}
code?!?!?
 
Newbie Spellweaver
Joined
Apr 5, 2008
Messages
40
Reaction score
0
Re: [Release] !Save all command and banning system!

3>Players.cpp
3>.\Players.cpp(69) : error C2653: 'MySQL' : is not a class or namespace name
3>.\Players.cpp(69) : error C3861: 'ban': identifier not found
3>.\Players.cpp(76) : error C2653: 'MySQL' : is not a class or namespace name
3>.\Players.cpp(76) : error C3861: 'unban': identifier not found

i got that error can someone help me

EDIT - nvm fixed it but have another error

3>c:\documents and settings\admin\my documents\rev006\maplestoryserver\maplestoryserver\mysqlm.cpp(284) : error C4716: 'MySQL::getBan' : must return a value
3>LINK : fatal error LNK1257: code generation failed


HOW U FIX THESE ERRORS?

please tell me.

and here is ur fix for your error:
(Credit to- Pete0145
)

int MySQL::getBan(char* username){
MYSQL_RES *mres;
MYSQL_ROW mrow;
char query[255];
sprintf_s(query, 255, "select banned from users where username='%s';", username);
mysql_real_query(&maple_db, query, strlen(query));
printf(mysql_error(&maple_db));
mres = mysql_store_result(&MySQL::maple_db);
mrow = mysql_fetch_row(mres);
printf(mysql_error(&maple_db));
int ret = 0;
printf(mysql_error(&maple_db));
if(mysql_num_fields(mres) > 0){
string mr = string((char*)mrow[0]);
istringstream buffer(mr);
buffer >> ret;
}
return ret;
}
 
Newbie Spellweaver
Joined
Apr 2, 2008
Messages
89
Reaction score
1
Re: [Release] !Save all command and banning system!

OMG i got it working!!!!!
 
Newbie Spellweaver
Joined
Apr 5, 2008
Messages
40
Reaction score
0
Re: [Release] !Save all command and banning system!

CAN U atleast help me?
i helped u!
 
Elite Diviner
Joined
Feb 28, 2007
Messages
446
Reaction score
4
Re: [Release] !Save all command and banning system!

HOW U FIX THESE ERRORS?

please tell me.

and here is ur fix for your error:
(Credit to- Pete0145
)

int MySQL::getBan(char* username){
MYSQL_RES *mres;
MYSQL_ROW mrow;
char query[255];
sprintf_s(query, 255, "select banned from users where username='%s';", username);
mysql_real_query(&maple_db, query, strlen(query));
printf(mysql_error(&maple_db));
mres = mysql_store_result(&MySQL::maple_db);
mrow = mysql_fetch_row(mres);
printf(mysql_error(&maple_db));
int ret = 0;
printf(mysql_error(&maple_db));
if(mysql_num_fields(mres) > 0){
string mr = string((char*)mrow[0]);
istringstream buffer(mr);
buffer >> ret;
}
return ret;
}


Doesnt work If I change my account in the banned Collumn from 1 to 0 It says Banned and Vise versa
 
Newbie Spellweaver
Joined
Apr 5, 2008
Messages
40
Reaction score
0
Re: [Release] !Save all command and banning system!

its not my code. it pete0145 code
Ask him.
 
Newbie Spellweaver
Joined
Apr 7, 2008
Messages
10
Reaction score
0
Re: [Release] !Save all command and banning system!

the banning system doesnt work..
it does work for the login part but when i do !ban [char name] every user in my database gets banned .. lol =D

grtz
 
Newbie Spellweaver
Joined
Apr 5, 2008
Messages
40
Reaction score
0
Re: [Release] !Save all command and banning system!

1>c:\documents and settings\אביב\desktop\titanmsver006\maplestoryserver\maplestoryserver\players.cpp(204) : error C2653: 'MySQL' : is not a class or namespace name
1>c:\documents and settings\אביב\desktop\titanmsver006\maplestoryserver\maplestoryserver\players.cpp(204) : error C3861: 'ban': identifier not found
1>c:\documents and settings\אביב\desktop\titanmsver006\maplestoryserver\maplestoryserver\players.cpp(214) : error C2653: 'MySQL' : is not a class or namespace name
1>c:\documents and settings\אביב\desktop\titanmsver006\maplestoryserver\maplestoryserver\players.cpp(214) : error C3861: 'unban': identifier not found


Can any 1 tell me how the duck i can solved these problems?!
 
Newbie Spellweaver
Joined
Apr 5, 2008
Messages
40
Reaction score
0
Re: [Release] !Save all command and banning system!

Why U Dont Help Me!?
 
Status
Not open for further replies.
Back
Top