[HELP] Command /reborn not working

This forum is for main questions (format files, STB / STL and so on).

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Forum rules
Client Editing is a delicate subject. osRose and osiRose will not support or use any Client Editing tool or results as a standard. So you are free to experiment, test, and develop there on Client Editing, but at your own risk :)

[HELP] Command /reborn not working

Postby ikill1 on Tue Sep 24, 2019 5:22 am

i made my own test server,
Client 434 + rev4 server

gmcmds.cpp has /reborn codes, but when i try it in-game it says "invalid command".
how to make it work?
ikill1
Jelly Bean
Jelly Bean
 
Posts: 17
Joined: Wed Sep 28, 2016 9:27 am

Re: [HELP] Command /reborn not working

Postby cdokkum on Tue Mar 24, 2020 8:43 pm

Same here bro.

I've tried to copy other commands which worked into the reborn command, but it did not do the trick.
So i was thinking that the problem should be somewhere else.

I've also tried to change the access level in the gmcmds.cpp sheet, but nothing happend.

I hope that someone can clarify this issue.

(What other things did you try to get it working?)
cdokkum
Little soul
Little soul
 
Posts: 4
Joined: Tue Mar 24, 2020 12:04 am

Re: [HELP] Command /reborn not working

Postby PurpleYouko on Thu Mar 26, 2020 5:36 pm

Are other commands working properly?
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4712
Joined: Fri Aug 10, 2007 2:05 pm

Re: [HELP] Command /reborn not working

Postby cdokkum on Thu Mar 26, 2020 7:08 pm

PurpleYouko wrote:Are other commands working properly?


That's the thing, everything else is working fine except for a couple other commands like:

commands.ini
[LEVELS]
AllSkill=299
Debuff=299
gmskills=399
Reborn=250


There might be a couple more, but these are the ones i tried.
cdokkum
Little soul
Little soul
 
Posts: 4
Joined: Tue Mar 24, 2020 12:04 am

Re: [HELP] Command /reborn not working

Postby PurpleYouko on Fri Mar 27, 2020 9:27 pm

250 is a rather strange vale for reborn in commands.ini.
The default is 99
otherwise ordinary players would not be able to use it since their access level is 100
I've checked the code in standard rev 4 and the only thing it checks is the config value from commands.ini
if you have that set to 99 then all players should be able to use reborn.

The error that you reported, however, has nothing to do with a failed access level check.
The "invalid command" message is telling you that the interpreter is not recognizing the word "reborn" at all

this is the default code in gmcmds.cpp
  1. else if (strcmp(command, "reborn")==0) //==== Reborn ==== (By Core)
  2.    {
  3.          if(Config.Command_Reborn > thisclient->Session->accesslevel)
  4.             return true;
  5.  
  6.         return pakGMReborn(thisclient);
  7.    }

Regardless of what happens in pakGMReborn(thisclient) if the command is recognized then you will never get that message
Check your spelling of the command that you entered against the code in gmcmds.cpp

Also check your server logs. Whenever that message is PMd to you it will also record the event in the logs with a little more detail as per this code
  1. else
  2.     {
  3.         Log( MSG_WARNING, "Invalid GM Command '%s' by '%s'", command, thisclient->CharInfo->charname);
  4.         //Wrong Command Alert {By CrAshInSiDe}
  5.         SendPM(thisclient, "Invalid Command");
  6.     }
  7.     return true;
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4712
Joined: Fri Aug 10, 2007 2:05 pm

Re: [HELP] Command /reborn not working

Postby cdokkum on Sun Mar 29, 2020 7:14 pm

So i've checked the following but without results :(

User privileges:
“accesslevel=999”

--------------------------------------
Worldserver.log
  1.  
  2. “Tried with lowercase”
  3. Sun Mar 29 17:41:57 2020 - [WARNING]: - Invalid GM Command 'reborn' by '[GM]Admin'
  4.  
  5. “Tried with uppercase”
  6. Sun Mar 29 17:43:02 2020 - [WARNING]: - Invalid GM Command 'Reborn' by '[GM]Admin'
  7.  


--------------------------------------
Commands.ini
“RaiseCG & Refine are working just fine, except for the reborn command”
  1.  
  2. RaiseCG=899
  3. Rate=899
  4. Reborn=99
  5. Refine=299
  6.  


--------------------------------------
Worldserver.cpp
  1.  
  2. Config.Command_Reborn = ConfigGetInt    ( "commands.ini", "reborn", 99 );
  3.  


--------------------------------------
Gmcmds.cpp
  1.  
  2. else if (strcmp(command, "reborn")==0) //==== Reborn ==== (By Core)
  3.    {
  4.          if(Config.Command_Reborn > thisclient->Session->accesslevel)
  5.             return true;
  6.  
  7.         return pakGMReborn(thisclient);
  8.    }
  9.  
  10.  


--------------------------------------
Gmcmds.cpp

  1.  
  2. bool CWorldServer::pakGMReborn(CPlayer* thisclient)
  3. {
  4.  
  5.     if(thisclient->Party->party!=NULL)
  6.     {
  7.         Log(MSG_INFO,"Player %s tried to use reborn but he was in a party.");
  8.         return true;
  9.     }
  10.  
  11.      if(thisclient->Stats->Level < GServer->Config.MaxLevel) //Level 260 can be changed to any level you want
  12.      {
  13.         GServer->SendPM(thisclient, "You have to be lvl %i to reborn !", GServer->Config.MaxLevel);
  14.      }
  15.      else
  16.      {
  17.  
  18.         thisclient = GServer->GetClientByCharName( thisclient->CharInfo->charname ); // adding this allows the server to retrieve the players client info for item removal
  19.         //starting the item removal process from slots 1 through 11
  20.         /*
  21.             slot 1, Face
  22.             slot 2, Head
  23.             slot 3, Body
  24.             slot 4, Back
  25.             slot 5, Hand
  26.             slot 6, Foot
  27.             slot 7, Weapon
  28.             slot 8, Offhand
  29.             slot 9, Necklace
  30.             slot 10, Ring
  31.             slot 11, Earring
  32.         */
  33.         for(int j=1; j<11; j++){
  34.             if(thisclient->items[j].itemnum == 0){ //prevents unknown itemtype error
  35.                 continue;
  36.             }
  37.  
  38.             UINT newslot = thisclient->GetNewItemSlot(thisclient->items[j]); // finds the first free slot in inventory
  39.             if(newslot==0xffff)
  40.             {
  41.                 Log(MSG_INFO,"Unable to find empty slot");
  42.                 SendPM(thisclient,"Your inventory is full");
  43.                 return false;
  44.             }
  45.  
  46.             thisclient->items[newslot] = thisclient->items[j];
  47.             ClearItem( thisclient->items[j] );
  48.             thisclient->UpdateInventory( newslot, j );
  49.             BEGINPACKET( pak, 0x7a5 );
  50.             ADDWORD    ( pak, thisclient->clientid );
  51.             ADDWORD    ( pak, j );
  52.             ADDWORD    ( pak, thisclient->items[j].itemnum );
  53.             ADDWORD    ( pak, GServer->BuildItemRefine( thisclient->items[j] ) );
  54.             ADDWORD    ( pak, thisclient->Stats->Move_Speed );
  55.             GServer->SendToVisible( &pak, (CCharacter*)this);
  56.             thisclient->SetStats( );
  57.         }
  58.         (CPlayer *)thisclient;
  59.  
  60.         //LMA: We remove all but basic skills.
  61.         for(int i=0;i<320;i++)  //For keeping the skills, remove this line
  62.         {  //For keeping the skills, remove this line
  63.             thisclient->cskills[i].id = 0;  //For keeping the skills, remove this line
  64.             thisclient->cskills[i].level = 1;  //For keeping the skills, remove this line
  65.             thisclient->cskills[i].thisskill=NULL;
  66.         }  //For keeping the skills, remove this line
  67.  
  68.         for(int i=0;i<MAX_QUICKBAR;i++)
  69.             thisclient->quickbar[i] = 0;
  70.  
  71.          thisclient->p_skills = 0;  //For keeping the skills, remove
  72.          thisclient->CharInfo->SkillPoints = 0;
  73.          thisclient->CharInfo->StatPoints = 0;
  74.          thisclient->CharInfo->Job = 0;
  75.  
  76.          thisclient->Stats->Level = 1;
  77.          thisclient->CharInfo->Exp = 0;
  78.  
  79.          thisclient->ActiveQuest = 0;
  80.          thisclient->MyQuest.clear();
  81.  
  82.         /*Update Reborn Command {By CrAshInSiDe*/
  83.         int x = 5098;
  84.         int y = 5322;
  85.         int map = 22;
  86.         if( (x != 0) && (y != 0) && (map != 0) )
  87.         {
  88.             fPoint coord;
  89.             coord.x = x;
  90.             coord.y = y;
  91.             MapList.Index[map]->TeleportPlayer( thisclient, coord, false );
  92.         }
  93.  
  94.          // Uncomment below if you want to use the Nobles part
  95.     /*
  96.         if(Reborn < 1)
  97.         {
  98.             int Reborn;
  99.             char newcharname[65];
  100.             strcpy (newcharname,"[Noble]");
  101.             strcat (newcharname, thisclient->CharInfo->charname);
  102.             GServer->DB->QExecute(" UPDATE characters SET char_name = '%s' WHERE id = '%i' ",newcharname, thisclient->CharInfo->charid);
  103.         }
  104.     */
  105.         GServer->DB->QExecute("UPDATE characters SET reborn = reborn + 1 WHERE id = '%i'", thisclient->CharInfo->charid);
  106.  
  107.          BEGINPACKET( pak, 0x702 );
  108.          ADDSTRING( pak, "You were disconnected from the server !" );
  109.          ADDBYTE( pak, 0 );
  110.          thisclient->client->SendPacket( &pak );
  111.  
  112.          RESETPACKET( pak, 0x707 );
  113.          ADDWORD( pak, 0 );
  114.          thisclient->client->SendPacket( &pak );
  115.          Log( MSG_GMACTION, " %s : /reborn" , thisclient->CharInfo->charname);
  116.  
  117.          //saving skills.
  118.          thisclient->saveskills();
  119.          thisclient->ResetSkillOffset();
  120.          thisclient->client->isActive = false;
  121.          thisclient->clearquest(thisclient);
  122.       }
  123.  
  124.  
  125.      return true;
  126. }
  127.  
  128.  


--------------------------------------
cdokkum
Little soul
Little soul
 
Posts: 4
Joined: Tue Mar 24, 2020 12:04 am

Re: [HELP] Command /reborn not working

Postby PurpleYouko on Tue Mar 31, 2020 3:44 pm

What do your logs show for the error?
It will print out the control text that it received. The one that didn't work for whatever reason.

I'm starting to suspect that your CodeBlocks is beginning to act up on you. It does that sometimes when a single command gets too long and complicated. The entire function in gmcmds.cpp is, in fact, ONE command. It's all a single logical statement filled with if/else if conditionals.
It can get too long for the compiler to be able to handle it but CB will not throw a visible error. It will just compile it wrong and then give you a bunch of unexpected results.
You could try replacing all the if statements with self contained ifs
  1. if (strcmp(command, "reborn")==0) //==== Reborn ==== (By Core)
  2.    {
  3.          if(Config.Command_Reborn > thisclient->Session->accesslevel)
  4.             return true;
  5.  
  6.         return pakGMReborn(thisclient);
  7.    }
rather than
  1. else if (strcmp(command, "reborn")==0) //==== Reborn ==== (By Core)
  2.    {
  3.          if(Config.Command_Reborn > thisclient->Session->accesslevel)
  4.             return true;
  5.  
  6.         return pakGMReborn(thisclient);
  7.    }

to get rid of all the ELSEs
I had to do that when converting the code to compile in Visual Studio because VS is smart enough to throw an error at compile time when a conditional statement gets too complex

Another issue that i bumped into with CodeBlocks was a very similar one involving the loading of commands.ini
I found that adding new commands to the config structure and loading them in from the ini file just stopped working at a certain point and once again just gave no compile error whatsoever.
It just left a bunch of Config values such as Config.Command_Reborn (just as an example) with uninitialized values which in CB actually translates as NULL most of the time.

If the problem was the config value then the error would not be what you see though. You appear to be seeing an unrecognized command name which gives you an error message in logs and a PM to the player
If the problem were an uninitialized config value then the function would return true and you would never get that error.
So while it is very likely that codeblocks is dicking around with your code and not compiling it correctly in more than one place, the error that you are seeing can most likely be fixed by getting rid of all the ELSE keywords in gmcmds.cpp

You could also completely ditch the unadulterated crap that is CodeBlocks and start using Visual Studio but that might take a little more work :lol:
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4712
Joined: Fri Aug 10, 2007 2:05 pm


Return to Client Editing Question Zone

Who is online

Users browsing this forum: No registered users and 3 guests

cron