[Release] online command

Junior Spellweaver
Joined
Sep 20, 2007
Messages
138
Reaction score
0
1. EDITED OUT. OLD POST -> UNNECESSARY STEP

2. EDITED OUT. OLD POST -> UNNECESSARY STEP

3. In Player.cpp, add under
Code:
		Skills::stopTimerPlayer(this);
Code:
		MySQL::setInt("characters", "online", this->getPlayerid(), 0);

4. Open Player.cpp, above
Code:
}

void Player::setHP(int hp, bool is){
put:
Code:
	MySQL::setInt("characters", "online", getPlayerid(), 1);
And at the top if its not already there:
Code:
#include "MySQLM.h"
5. Add to commands block in Players.cpp:
Code:
		else if(strcmp(command, "online") == 0) {
			PlayersPacket::showNoticeOneChar("Characters online: ", 5, player);
			for (hash_map <int, Player*>::iterator iter = Players::players.begin(); iter != Players::players.end(); iter++)
				PlayersPacket::showNoticeOneChar(iter->second->getName(), 5, player);
		}

6. Add to PlayersPacket.h :
Code:
	static void showNoticeOneChar(char* msg, char type, Player* player);

7. Add to PlayersPacket.cpp:
Code:
void PlayersPacket::showNoticeOneChar(char* msg, char type, Player* player){
    Packet packet = Packet();
    packet.addHeader(0x2d);
    packet.addByte(type);
    packet.addShort(strlen(msg));
    packet.addString(msg, strlen(msg));
    packet.packetSend(player);
}

8. Execute SQL query in your database SQL browser:
Code:
ALTER TABLE  `characters` ADD  `online` INT( 1 ) NOT NULL DEFAULT  '0';

9. Enjoy!! ^_^ !online now tells you whos online on your server

credits to me for coding this

edit: ive taken out unnecessary parts of code. if you used the old version, please feel free to update it. if you are an experienced programmer, you should see that the mysql parts of making the online field 0 or 1 does not affect in game. i've done this so php programmers for web cms's can use that to their advantage.... and here i've just spoiled the main reason why i put it there in the first place =.=
 
Last edited:
Re: [Release] !online command

URGENT NOTICE:
IF THIS DOESNT WORK FOLLOW THE INSTRUCTIONS AGAIN! I ACCIDENTALLY MISSED OUT SOME STUFF ON ORIGINAL POST.

and i've edited it so it should work now :)
 
Re: [Release] !online command

i did all and i did it even 2 times to check if i did somting worng and i still have the same error:
1>MySQLM.cpp
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2825: 'i': must be a class or namespace when followed by '::'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2143: syntax error : missing ';' before 'std::iterator'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2955: 'std::iterator' : use of class template requires template argument list
1> d:\program files\microsoft visual studio 9.0\vc\include\xutility(688) : see declaration of 'std::iterator'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : fatal error C1903: unable to recover from previous error(s);
 
Re: [Release] !online command

Maps.cpp
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\maps.cpp(24) : error C2653: 'MySQL' : is not a class or namespace name
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\maps.cpp(24) : error C3861: 'setInt': identifier not found
Player.cpp
Players.cpp
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\players.cpp(69) : error C2653: 'MySQL' : is not a class or namespace name
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\players.cpp(69) : error C3861: 'getOnline': identifier not found
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\players.cpp(338) : warning C4018: '<' : signed/unsigned mismatch
MySQLM.cpp
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\mysqlm.h(25) : error C2061: syntax error : identifier 'Player'
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\mysqlm.cpp(247) : error C2065: 'Player' : undeclared identifier
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\mysqlm.cpp(247) : error C2065: 'player' : undeclared identifier
c:\documents and settings\icyshadow\desktop\titanmsver006\maplestoryserver\maplestoryserver\mysqlm.cpp(247) : error C2448: 'MySQL::getOnline' : function-style initializer appears to be a function definition
PlayersPacket.cpp

Got that error.. iono what i did wrong but i think i did a lot fo things right.. Nice long tut tho
 
Re: [Release] !online command

lOlz, I had coded this myself, but didnt upload it. But seeing you have released it. I should post mine too. Judging from your coding, when users sign on, it add's to SQL table, what happens when they sign off?
 
Re: [Release] !online command

i did all and i did it even 2 times to check if i did somting worng and i still have the same error:
1>MySQLM.cpp
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2825: 'i': must be a class or namespace when followed by '::'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2143: syntax error : missing ';' before 'std::iterator'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2955: 'std::iterator' : use of class template requires template argument list
1> d:\program files\microsoft visual studio 9.0\vc\include\xutility(688) : see declaration of 'std::iterator'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : fatal error C1903: unable to recover from previous error(s);

Getting the same error.
 
Re: [Release] !online command

it could be that i installed the warp commands from the other thread in this forum....
 
Re: [Release] !online command

i did all and i did it even 2 times to check if i did somting worng and i still have the same error:
1>MySQLM.cpp
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2825: 'i': must be a class or namespace when followed by '::'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2143: syntax error : missing ';' before 'std::iterator'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : error C2955: 'std::iterator' : use of class template requires template argument list
1> d:\program files\microsoft visual studio 9.0\vc\include\xutility(688) : see declaration of 'std::iterator'
1>d:\maplestoryserver\maplestoryserver\mysqlm.cpp(258) : fatal error C1903: unable to recover from previous error(s);

i have the same error like u, i did those steps dubble and still same error,
i added tons of thins to my server, and this problem i can't solve,

may u help us?
 
Re: [Release] !online command

MySQLM.cpp
.\MySQLM.cpp(200) : error C2825: 'i': must be a class or namespace when followed by '::'
.\MySQLM.cpp(200) : error C2143: syntax error : missing ';' before 'std::iterator'
.\MySQLM.cpp(200) : error C2955: 'std::iterator' : use of class template requires template argument list
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(688) : see declaration of 'std::iterator'
.\MySQLM.cpp(200) : fatal error C1903: unable to recover from previous error(s); stopping compilation

thats my error >_>
 
Re: [Release] !online command

is this at the top of your MySQLM.cpp file?
Code:
#include "MySQLM.h"
#include <sstream>
#include <string>
#include "Player.h"
#include "Players.h"
#include "PlayerPacket.h"
#include "PlayersPacket.h"
using namespace std;
 
Back