- 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
4. Open Player.cpp, above
put:
And at the top if its not already there:
5. Add to commands block in Players.cpp:
6. Add to PlayersPacket.h :
7. Add to PlayersPacket.cpp:
8. Execute SQL query in your database SQL browser:
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 =.=
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){
Code:
MySQL::setInt("characters", "online", getPlayerid(), 1);
Code:
#include "MySQLM.h"
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:

