Reborninging limit CPlayer error!

Results 1 to 14 of 14
  1. #1
    Account Upgraded | Title Enabled! fransh is offline
    MemberRank
    Jun 2010 Join Date
    Junon polisLocation
    285Posts

    Reborninging limit CPlayer error!

    Hi,


    So I'm working on making some limits @ Reborns, which should not be to hard, so what I did was

    Code:
    // Reborn command credits Core
    bool CWorldServer::pakGMReborn(CPlayer* thisclient)
    {
        if(thisclient->Party->party!=NULL)
        {
            Log(MSG_INFO,"Player %s tried to use reborn but he was in a party.");
            return true;
        }
    
         if(thisclient->Stats->Level < 250) //Level 250 can be changed to any level you want
         {
            GServer->SendPM(thisclient, "Reborning is for level 250!");
         }
    if (thisclient->nb_reborn>2)
         {
              SendPM(thisclient, "You already add the maximum amount of reborn");
              return true;
         } 
         else
         {
    thisclient->nb_reborn++;
         DB->QExecute("UPDATE characters SET nb_reborn=%i WHERE id=%i", thisclient->nb_reborn, thisclient->CharInfo->charid);
    
             thisclient->CharInfo->SkillPoints = 0;
             thisclient->CharInfo->StatPoints = 0;
            
    
             thisclient->Stats->Level = 1;
             thisclient->CharInfo->Exp = 0;
    
             thisclient->ActiveQuest = 0;
    So I've created nb_reborn in my character table, after that I tried to rebuild the whole thing but CB tells me that nb_reborn is NOT a member of Cplayer*, what does this mean?


    Thanks in advance.

    -UPDATE-
    I've added it on playerdata.cpp aswell!
    Last edited by fransh; 18-02-11 at 09:33 PM.


  2. #2
    Proficient Member redgie is offline
    MemberRank
    Feb 2009 Join Date
    196Posts

    Re: Reborninging limit CPlayer error!

    well i have something in mind hope its possible well limiting reborns means not maxing the stats or depends on the devs wanted but just want to ask if...

    lets say max stat is 500 and you need to have 6 reborns to max 1 stat, so you 36 reborns to max all stats right? 36 continuous reborns are possible and even till 1000reborns but now heres my question...

    after having 20reborns.... the reborn 21 will still be counted but when you level you wont gain any STAT POINTS means you can max 4 or 5 stats now not anymore to max all stats...

    is there anyway to stop earning stat points when you reach 21x of reborns?
    so that characters cant max stats but can have 1000reborns

  3. #3
    Account Upgraded | Title Enabled! fransh is offline
    MemberRank
    Jun 2010 Join Date
    Junon polisLocation
    285Posts

    Re: Reborninging limit CPlayer error!

    Why would they reborn 1000 times when they don't get anything for it?
    And I'm not asking for another question .

  4. #4
    Proficient Member redgie is offline
    MemberRank
    Feb 2009 Join Date
    196Posts

    Re: Reborninging limit CPlayer error!

    Quote Originally Posted by fransh View Post
    Why would they reborn 1000 times when they don't get anything for it?
    And I'm not asking for another question .
    well like a reborn set for having 1000reborns but i wanted if theres a possibility to stop stat points when reached 20 reborns?

  5. #5
    Account Upgraded | Title Enabled! fransh is offline
    MemberRank
    Jun 2010 Join Date
    Junon polisLocation
    285Posts

    Re: Reborninging limit CPlayer error!

    Idk, won't be easy and it would be terribly boring rbing 1000 times..

  6. #6
    Last of the OsRose Devs Purpleyouko is offline
    MemberRank
    Oct 2006 Join Date
    Missouri USALocation
    2,161Posts

    Re: Reborninging limit CPlayer error!

    So I've created nb_reborn in my character table, after that I tried to rebuild the whole thing but CB tells me that nb_reborn is NOT a member of Cplayer*, what does this mean?
    Cplayer is a "Class" defined in CPlayer.h
    if you ever want an extra member in a class then you first have to define it in the header {.h) file and then rebuild the entire server rather than just compiling changes. This is because almost all the .cpp files load in the headers and use them as part of their own structure when you compile.

    notice at the top of your function you first cast "thisclient" as CPlayer
    Code:
    // Reborn command credits Core
    bool CWorldServer::pakGMReborn(CPlayer* thisclient)
    {
    This means that thisclient will inherit the entire structure contained in the CPlayer class. At this point CPlayer has no member named nb_reborn since you have yet to define it.

    Go to your Player.h and find a this function
    Code:
    class CPlayer: public CCharacter
    {
    Somewhere in this function (doesn't really matter where) add this
    Code:
    unsigned int nb_reborn;
    then recompile and your code should work.

  7. #7
    Proficient Member redgie is offline
    MemberRank
    Feb 2009 Join Date
    196Posts

    Re: Reborninging limit CPlayer error!

    purple is there a way how to stop earning stat points even though your reborning continuously?

  8. #8
    Last of the OsRose Devs Purpleyouko is offline
    MemberRank
    Oct 2006 Join Date
    Missouri USALocation
    2,161Posts

    Re: Reborninging limit CPlayer error!

    yes. it should be pretty easy to add a conditional in the level up function that will stop you getting stat points after a reborn.

    You could use the nb_reborn variable mentioned above.

    Look in Playerfunctions.cpp then in function...
    Code:
    bool CPlayer::CheckPlayerLevelUP( )
    {
    you should have a line of code that reads something like this
    Code:
    CharInfo->StatPoints += int((Stats->Level*0.8)+10);
    Since Playerfunctions.cpp already uses the CPlayer class as it's default we can just call nb_reborn directly
    so you could replace this with
    Code:
    if (nb_reborns == 0)
    {
        CharInfo->StatPoints += int((Stats->Level*0.8)+10);
    }
    That way your players will only get stat points added if they have zero reborns recorded in their player profile.

    The stats formula will possibly be different for your server. this code comes from my osprose server. Just use whatever you have in your own.

  9. #9
    Account Upgraded | Title Enabled! fransh is offline
    MemberRank
    Jun 2010 Join Date
    Junon polisLocation
    285Posts

    Re: Reborninging limit CPlayer error!

    Thanks, Purple, it works now.


    EDIT:

    Code:
    // Reborn command credits Core
    bool CWorldServer::pakGMReborn(CPlayer* thisclient)
    {
        if(thisclient->Party->party!=NULL)
        {
            Log(MSG_INFO,"Player %s tried to use reborn but he was in a party.");
            return true;
        }
    
         if(thisclient->Stats->Level < 250) //Level 250 can be changed to any level you want
         {
            GServer->SendPM(thisclient, "Reborning is for level 250!");
          return true;
         }
         if(thisclient->reborns>1)
         {
         SendPM(thisclient,"Too many reborns");
         Log(MSG_INFO,"Too many reborns");
         return true;
         }
     
         else
         {
    
            thisclient->reborns++;
            GServer->DB->QExecute(" UPDATE characters SET reborns = '%i' WHERE id = '%i' ",thisclient->reborns,thisclient->CharInfo->charid);
            Log(MSG_INFO,"Reborns changed to %i",thisclient->reborns);
    After rebuilding, I still can reborn more then once, even though my table is called reborns and it adds one point each reborn.


    Code:
    if(thisclient->reborns>1)
         {
         SendPM(thisclient,"Too many reborns");
         Log(MSG_INFO,"Too many reborns");
         return true;
    Being more specific, I think it has to do with this one.
    Last edited by fransh; 20-02-11 at 07:42 PM.

  10. #10
    Account Upgraded | Title Enabled! fransh is offline
    MemberRank
    Jun 2010 Join Date
    Junon polisLocation
    285Posts

    Re: Reborninging limit CPlayer error!

    Any suggestions plox?

  11. #11
    Last of the OsRose Devs Purpleyouko is offline
    MemberRank
    Oct 2006 Join Date
    Missouri USALocation
    2,161Posts

    Re: Reborninging limit CPlayer error!

    Where is this function being called from?

    Is it possible that the true or false value returned from the function is having an effect?

    I can't look for myself since I do not have reborn code.
    To be perfectly honest if any server needs reborns then it is just set up wrong in the first place

  12. #12
    Account Upgraded | Title Enabled! fransh is offline
    MemberRank
    Jun 2010 Join Date
    Junon polisLocation
    285Posts

    Re: Reborninging limit CPlayer error!

    It's called from my table 'reborns' if that is what you mean. This is added perfectly every reborn but still it seems to check it wrong.


    Thisclient - > Reborns >(BiggerThen) 1 return true;
    else
    blablabla


    So I think it just doesn't read the data properly.
    Last edited by fransh; 23-02-11 at 03:34 PM. Reason: ..

  13. #13
    Enthusiast dannygga is offline
    MemberRank
    Mar 2009 Join Date
    35Posts

    Re: Reborninging limit CPlayer error!

    Quote Originally Posted by fransh View Post
    Code:
    if(thisclient->reborns>1)
         {
         SendPM(thisclient,"Too many reborns");
         Log(MSG_INFO,"Too many reborns");
         return true;
    to make it clear to everyone // ->reborns>1 \\

    if put 1 your max reborn = 2
    if put 2 max reborn = 3

    hmm well i i look at the osrose forums i found this script 2

    and when rebuild this world server u get a Cplayer error
    and a UINT error so do this :

    Code:
    MYSQL_RES *result = GServer->DB->QStore("SELECT level,face,hairStyle,sex,classid,zuly,str,dex,_int, con,cha,sen,curHp,curMp,id,statp,skillp,exp,stamina,quickbar,basic_skills, class_skills,class_skills_level,respawnid,clanid,clan_rank,townid,rewardpoints,unionid,unionfame,union01,union02,union03,union04,union05,bonusxp,timerxp,shoptype,timershop,isGM,unique_skills,mileage_skills,driving_skills,unique_skills_level,mileage_skills_level,bonusddrop,timerddrop,bonusstatdrop,timerstatdrop,bonusgraydrop,timergraydrop FROM characters WHERE char_name='%s'", CharInfo->charname);
    with
    Code:
    MYSQL_RES *result = GServer->DB->QStore("SELECT level,face,hairStyle,sex,classid,zuly,str,dex,_int, con,cha,sen,curHp,curMp,id,statp,skillp,exp,stamina,quickbar,basic_skills, class_skills,class_skills_level,respawnid,clanid,clan_rank,townid,rewardpoints,unionid,unionfame,union01
    ,union02,union03,union04,union05,bonusxp,timerxp,shoptype,timershop,isGM,unique_skills,mileage_skills,driving_skills
    ,unique_skills_level,mileage_skills_level,bonusddrop,timerddrop,bonusstatdrop,timerstatdrop,bonusgraydrop,timergraydrop,reborns FROM characters WHERE char_name='%s'", CharInfo->charname);
    and add
    Code:
        reborns=atoi(row[51]);
    	Log(MSG_INFO,"Nb reborns for %s is %i",CharInfo->charname,reborns);
    after
    Code:
    timergraydrop=atoi(row[50]);
    and add

    Code:
        UINT reborns;
    after
    Code:
        bool isGM; // GM Security
    and design your character table add a field called

    PHP Code:
    reborns int(1) DEFAULT '0' 
    Now will it work ;)
    Last edited by dannygga; 24-02-11 at 01:41 PM.

  14. #14
    Last of the OsRose Devs Purpleyouko is offline
    MemberRank
    Oct 2006 Join Date
    Missouri USALocation
    2,161Posts

    Re: Reborninging limit CPlayer error!

    Quote Originally Posted by fransh View Post
    It's called from my table 'reborns' if that is what you mean. This is added perfectly every reborn but still it seems to check it wrong.


    Thisclient - > Reborns >(BiggerThen) 1 return true;
    else
    blablabla


    So I think it just doesn't read the data properly.
    No that's not what I meant.

    Every function is called from some other place in the code and then returns to that same position in the code afterward.
    It is this function call that could be critical to whether or not the reborns variable gets updated.

    Do a string search for pakGMReborn to find out where the function gets called from in your code.
    As the function returns a Boolean value it will most likely be in the form of a conditional such as
    Code:
    if (pakGMReborn())
    {
        // do something
    }else{
        // do something else
    }
    or it might appear as
    Code:
    return pakGMReborn()
    in which case you have to go back even further to find where that function was called from.

    Ain't it fun debugging C++



Advertisement