[Release] auto save function [FIXED!]

Page 1 of 9 123456789 LastLast
Results 1 to 15 of 130
  1. #1
    Proficient Member 2azn4u is offline
    MemberRank
    Sep 2007 Join Date
    Down Under....Location
    156Posts

    [Release] auto save function [FIXED!]

    Alas the long awaited auto save function :)

    EDIT: I've now found the better way to do the autosave :) check it out! ^_^ can't believe this took me a few hours =.= You only need to edit one file

    1. Make sure you've installed: http://forum.ragezone.com/f427/relea...ommand-382734/

    2. Open MapleStoryServer.cpp

    3. At the top with the includes, put:
    Code:
    #include <process.h>
    #include <windows.h>
    #include <stdio.h>
    #include "PlayersPacket.h"
    #include "Players.h"
    4. Above
    Code:
    void main(){
    put:
    Code:
    void autoSave( void * );
    5. Above
    Code:
    	while(getchar()){}
    put:
    Code:
    	int saveInterval = 150; // save interval in seconds
    	_beginthread( autoSave, 0, (void*)saveInterval);
    6. At the bottom of the file put:
    Code:
    void autoSave( void *arg ) {
    	while(true) {
    		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", 5);
    		printf("All progress saved by autosave\n");
    		Sleep(((INT_PTR)arg)*1000);
    	}
    }
    If you want to change the save interval in seconds, change the part where it says:
    Code:
    	int saveInterval = 150; // save interval in seconds
    If you don't want the save message to appear in game, delete:
    Code:
            PlayersPacket::showMassage("All progress has been saved successfully", 5);

    credits to me and the internet for helping me research threads
    Last edited by 2azn4u; 13-04-08 at 06:44 AM.


  2. #2
    Account Upgraded | Title Enabled! ctZ'... is offline
    MemberRank
    Dec 2006 Join Date
    533Posts

    Re: [Release] auto save function

    simply amazing, seriously, for me this is the best release that ever came in rz ;) congrats

    edit: why are there 2 empty includes in autosave.cpp?

  3. #3
    Valued Member alxbandit is offline
    MemberRank
    Apr 2008 Join Date
    116Posts

    Re: [Release] auto save function

    yayerz!!! Sticky please!!

  4. #4
    Account Upgraded | Title Enabled! LilAznKevin is offline
    MemberRank
    Oct 2007 Join Date
    225Posts

    Re: [Release] auto save function

    You are my god :D i luffs u <3!

  5. #5
    Member Lorrenzo is offline
    MemberRank
    Apr 2008 Join Date
    OH - - - IOLocation
    97Posts

    Re: [Release] auto save function

    Wow, great release!

  6. #6
    Member JadedShards is offline
    MemberRank
    Apr 2008 Join Date
    58Posts

    Re: [Release] auto save function

    ZDoesn't work......
    says save is not defined as player.........

  7. #7
    Proficient Member 2azn4u is offline
    MemberRank
    Sep 2007 Join Date
    Down Under....Location
    156Posts

    Re: [Release] auto save function

    recheck step 2.... the code bbcode wouldnt let the #include <stdio.h>
    #include <time.h> show up

  8. #8
    Proficient Member 2azn4u is offline
    MemberRank
    Sep 2007 Join Date
    Down Under....Location
    156Posts

    Re: [Release] auto save function

    Quote Originally Posted by ctZ'... View Post
    simply amazing, seriously, for me this is the best release that ever came in rz ;) congrats

    edit: why are there 2 empty includes in autosave.cpp?
    should be fixed now

  9. #9
    Apprentice tangkwokkim is offline
    MemberRank
    Jan 2008 Join Date
    11Posts

    Re: [Release] auto save function

    nice !!!!!

  10. #10
    Account Upgraded | Title Enabled! ctZ'... is offline
    MemberRank
    Dec 2006 Join Date
    533Posts

    Re: [Release] auto save function

    2azn4u, what parts from ur save script do we need to add for this to work, i dont find that script usefull, so i was not pretending to add it to me server, unless i really have to

  11. #11
    Account Upgraded | Title Enabled! theonendonly is offline
    MemberRank
    Apr 2008 Join Date
    411Posts

    Re: [Release] auto save function

    yes cant wait to test .

  12. #12
    Proficient Member 2azn4u is offline
    MemberRank
    Sep 2007 Join Date
    Down Under....Location
    156Posts

    Re: [Release] auto save function

    Quote Originally Posted by ctZ'... View Post
    2azn4u, what parts from ur save script do we need to add for this to work, i dont find that script usefull, so i was not pretending to add it to me server, unless i really have to
    all of the updated one is important

  13. #13
    Valued Member vioLy is offline
    MemberRank
    Apr 2008 Join Date
    101Posts

    Re: [Release] auto save function

    Hmm after adding this it's caused my server to just crash "fatal error" when I debug it.

  14. #14
    Account Upgraded | Title Enabled! ctZ'... is offline
    MemberRank
    Dec 2006 Join Date
    533Posts

    Re: [Release] auto save function

    Code:
    d:\games\fantasyms project\server\serversource\maplestoryserver\autosave.cpp(19) : error C2955: 'stdext::hash_map' : use of class template requires template argument list
            c:\programas\microsoft visual studio 9.0\vc\include\hash_map(87) : see declaration of 'stdext::hash_map'
    d:\games\fantasyms project\server\serversource\maplestoryserver\autosave.cpp(19) : error C2955: 'stdext::hash_map' : use of class template requires template argument list
            c:\programas\microsoft visual studio 9.0\vc\include\hash_map(87) : see declaration of 'stdext::hash_map'
    d:\games\fantasyms project\server\serversource\maplestoryserver\autosave.cpp(20) : error C2227: left of '->second' must point to class/struct/union/generic type
            type is 'list<_Hash<_Traits>::_Traits::value_type,_Hash<_Traits>::_Traits::allocator_type>::iterator'
    d:\games\fantasyms project\server\serversource\maplestoryserver\autosave.cpp(20) : error C2227: left of '->save' must point to class/struct/union/generic type
    Any idea how to fix it?

    here my edited part of player.cpp, i don't think i did something wront but :\
    Code:
    Player::~Player(){
    	if(isconnect){
    		Maps::removePlayer(this);
    		Players::deletePlayer(this);
    		save();
    		isconnect= false;
    	}
    }
    void Player::save() {
    			char sql[2000];
    		sprintf_s(sql, 2000, "update keymap set ");
    		for(int i=0; i<90; i++){
    			char temp[100];
    			if(i!=89)
    				sprintf_s(temp, 100, "pos%d=%d, ", i, keys[i]);
    			else
    				sprintf_s(temp, 100, "pos%d=%d where charid=%d; ", i, keys[i], getPlayerid());
    			strcat_s(sql, 2000, temp);
    		}
    		MySQL::insert(sql);
    		sprintf_s(sql, 2000, "update characters set level=%d, job=%d, str=%d, dex=%d, intt=%d, luk=%d, chp=%d, mhp=%d, cmp=%d, mmp=%d, ap=%d, sp=%d, exp=%d, fame=%d, map=%d, gender=%d, skin=%d, eyes=%d, hair=%d, mesos=%d where id=%d", getLevel(), getJob(), getStr(), getDex(), getInt(), getLuk(), getHP(), getMHP(), getMP(), getMMP(), getAp(), getSp(), getExp(), getFame(), getMap(), getGender(), getSkin(), getEyes(), getHair(), inv->getMesos() ,getPlayerid());
    		MySQL::insert(sql);
    		char temp[100];
    		sprintf_s(temp, 100, "where charid=%d;", getPlayerid());
    		strcat_s(sql, 2000, temp);
    		MySQL::insert(sql);
    		sprintf_s(sql, 2000, "delete from equip where charid=%d;", getPlayerid());
    		MySQL::insert(sql);
    		for(int i=0; i<inv->getEquipNum(); i++){
    			sprintf_s(sql, 2000, "insert into equip values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);", inv->getEquip(i)->id, Drops::equips[inv->getEquip(i)->id].type ,getPlayerid(), inv->getEquipPos(i), inv->getEquip(i)->slots, inv->getEquip(i)->scrolls,
    				inv->getEquip(i)->istr, inv->getEquip(i)->idex, inv->getEquip(i)->iint, inv->getEquip(i)->iluk, inv->getEquip(i)->ihp, inv->getEquip(i)->imp, inv->getEquip(i)->iwatk, inv->getEquip(i)->imatk, inv->getEquip(i)->iwdef, 
    				inv->getEquip(i)->imdef, inv->getEquip(i)->iacc, inv->getEquip(i)->iavo, inv->getEquip(i)->ihand, inv->getEquip(i)->ijump, inv->getEquip(i)->ispeed);
    			MySQL::insert(sql);
    		}
    		sprintf_s(sql, 2000, "delete from skills where charid=%d;", getPlayerid());
    		MySQL::insert(sql);
    		for(int i=0; i<skills->getSkillsNum(); i++){
    			sprintf_s(sql, 2000, "insert into skills values(%d, %d, %d)", getPlayerid(), skills->getSkillID(i), skills->getSkillLevel(skills->getSkillID(i)));
    			MySQL::insert(sql);
    		}
    		sprintf_s(sql, 2000, "delete from items where charid=%d;", getPlayerid());
    		MySQL::insert(sql);
    		for(int i=0; i<inv->getItemNum(); i++){
    			sprintf_s(sql, 2000, "insert into items values(%d, %d, %d, %d, %d);", inv->getItem(i)->id, getPlayerid() ,inv->getItem(i)->inv, inv->getItem(i)->pos, inv->getItem(i)->amount);
    			MySQL::insert(sql);
    		}
    		Skills::stopTimerPlayer(this);
    		MySQL::setInt("characters", "online", this->getPlayerid(), 0);
    		isconnect = false;
    }

  15. #15
    Account Upgraded | Title Enabled! metroix is offline
    MemberRank
    Apr 2008 Join Date
    389Posts

    Re: [Release] auto save function

    i can set it to 1 seg o.o?



Page 1 of 9 123456789 LastLast

Advertisement