Help, About CharName

If you want to help us or give some corrections / codes, put it here ;)

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

Help, About CharName

Postby AdiShochat on Sat Nov 06, 2010 3:07 am

in the CharType.h I can find that the character name come from charname[17],
but i can't change it that if the accsess level is 300, or 150, it will be with string before.
(i came from C# btw)
this is wasn't working for me ..
  1.  
  2. struct INFO
  3. {
  4. if (thisclient->Session->accesslevel == 300)
  5.     char charname["[Admin]"+17];
  6. else if (thisclient->Session->accesslevel == 300)
  7.     char charname["[GM]"+17];
  8. else
  9.     char charname[17];
  10.                       .
  11.                       .
  12.                       .
  13.                       .
  14.  

Why isn't this code working ?

BTW, What about this code ?
  1.  
  2. else if (strcmp(command, "logasgm")==0) // Getting Accsess Level
  3.     {
  4.         if((Config.Command_LogAsGM > thisclient->Session->accesslevel) && thisclient->CharInfo->isGM == true)
  5.            SendGlobalMSG(CPlayer* thisclient, "GameMaster %i Is Now Logged In !", thisclient->CharInfo->charname);
  6.     }
  7.  
AdiShochat
Little soul
Little soul
 
Posts: 4
Joined: Sat Nov 06, 2010 2:42 am

Re: Help, About CharName

Postby Planetary_Myth on Sat Nov 06, 2010 4:12 am

AdiShochat wrote:in the CharType.h I can find that the character name come from charname[17],
but i can't change it that if the accsess level is 300, or 150, it will be with string before.
(i came from C# btw)
this is wasn't working for me ..
  1.  
  2. struct INFO
  3. {
  4. if (thisclient->Session->accesslevel == 300)
  5.     char charname["[Admin]"+17];
  6. else if (thisclient->Session->accesslevel == 300)
  7.     char charname["[GM]"+17];
  8. else
  9.     char charname[17];
  10.                       .
  11.                       .
  12.                       .
  13.                       .
  14.  

Why isn't this code working ?

BTW, What about this code ?
  1.  
  2. else if (strcmp(command, "logasgm")==0) // Getting Accsess Level
  3.     {
  4.         if((Config.Command_LogAsGM > thisclient->Session->accesslevel) && thisclient->CharInfo->isGM == true)
  5.            SendGlobalMSG(CPlayer* thisclient, "GameMaster %i Is Now Logged In !", thisclient->CharInfo->charname);
  6.     }
  7.  


Well i mess with C# and C++ I found does not like else if statements

  1. struct INFO
  2. {
  3. if (thisclient->Session->accesslevel == 400) <--- can not have same accesslevel
  4.     char charname["[Admin]"+17];
  5. if (thisclient->Session->accesslevel == 300) <--- C++ does not like else if
  6.     char charname["[GM]"+17];
  7. else
  8.     char charname[17];
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Help, About CharName

Postby AdiShochat on Sat Nov 06, 2010 1:07 pm

Planetary_Myth wrote:
AdiShochat wrote:in the CharType.h I can find that the character name come from charname[17],
but i can't change it that if the accsess level is 300, or 150, it will be with string before.
(i came from C# btw)
this is wasn't working for me ..
  1.  
  2. struct INFO
  3. {
  4. if (thisclient->Session->accesslevel == 300)
  5.     char charname["[Admin]"+17];
  6. else if (thisclient->Session->accesslevel == 300)
  7.     char charname["[GM]"+17];
  8. else
  9.     char charname[17];
  10.                       .
  11.                       .
  12.                       .
  13.                       .
  14.  

Why isn't this code working ?

BTW, What about this code ?
  1.  
  2. else if (strcmp(command, "logasgm")==0) // Getting Accsess Level
  3.     {
  4.         if((Config.Command_LogAsGM > thisclient->Session->accesslevel) && thisclient->CharInfo->isGM == true)
  5.            SendGlobalMSG(CPlayer* thisclient, "GameMaster %i Is Now Logged In !", thisclient->CharInfo->charname);
  6.     }
  7.  


Well i mess with C# and C++ I found does not like else if statements

  1. struct INFO
  2. {
  3. if (thisclient->Session->accesslevel == 400) <--- can not have same accesslevel
  4.     char charname["[Admin]"+17];
  5. if (thisclient->Session->accesslevel == 300) <--- C++ does not like else if
  6.     char charname["[GM]"+17];
  7. else
  8.     char charname[17];


still.. it shows error
  1. C:\*****\*****\*****\osrose\World Server\chartype.h|238|error: expected unqualified-id before "if"|
AdiShochat
Little soul
Little soul
 
Posts: 4
Joined: Sat Nov 06, 2010 2:42 am

Re: Help, About CharName

Postby Planetary_Myth on Sat Nov 06, 2010 2:15 pm

That error is telling you that C++ does not like else before if.
The code I posted was an example not copy and paste.
As for your other code it has the else before the if and again C++ does not like this.
Hope that clears it up for you.

The comments I made beside it should of been removed.
  1. struct INFO
  2. {
  3. if (thisclient->Session->accesslevel == 400)
  4.     char charname["[Admin]"+17];
  5. if (thisclient->Session->accesslevel == 300)
  6.     char charname["[GM]"+17];
  7. else
  8.     char charname[17];
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Help, About CharName

Postby PurpleYouko on Sat Nov 06, 2010 3:42 pm

Charname[17] is an array of bytes.
All strings are stored that way in C++

you can't put strings directly into the charname array the way you tried to. the only thing allowed between the brackets is a number defining the size of the array
There are special functions that put strings into the char array.

Additionally you are not allowed to use this kind of conditionals inside a struct command.
This is where the original structure of the variables is defined. Once the server is compiled, the data in a struct is FIXED and cannot ever be changed again till you recompile it.

Why not try modifying it in Playerdata.cpp where the character data is loaded into the string.
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: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Help, About CharName

Postby AdiShochat on Sat Nov 06, 2010 10:09 pm

Thank you very much, both !
I have more to learn in C#, only a freshment in this (school) class.
In my senior project i will try to open a new open source rose, in C#
BTW, basiclly this source is build with functions, that each one of them do diffrent actions, right ?
and again , thank you both very much !
Oh, and Planetary_Myth, gmcmds.cpp has alot of "else if",
why is it matters in this code ?
AdiShochat
Little soul
Little soul
 
Posts: 4
Joined: Sat Nov 06, 2010 2:42 am

Re: Help, About CharName

Postby Planetary_Myth on Sun Nov 07, 2010 4:38 am

Thanks for pointing that out in gmcmds.cpp.
I assumed C++ did not use "else if" as it complained every time I used it.
I know very little about C++ so I am learning as I go.
Most of the code I have messed with has been in C#.
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Help, About CharName

Postby Maxxon on Sun Nov 07, 2010 9:54 am

What you was trying to do is not possible in C# either.
Image
an anymous comment on a program called reloader:
what if a fatal error happens, will it restart it?
User avatar
Maxxon
Hawker's pet
Hawker's pet
 
Posts: 1305
Joined: Sat Nov 10, 2007 12:42 pm

Re: Help, About CharName

Postby AdiShochat on Sun Nov 07, 2010 9:46 pm

Maxxon wrote:What you was trying to do is not possible in C# either.

I didn't try to do it like C#, I just said my base is C#, so I tried to use this base on C++
AdiShochat
Little soul
Little soul
 
Posts: 4
Joined: Sat Nov 06, 2010 2:42 am


Return to Submit Code

Who is online

Users browsing this forum: No registered users and 4 guests