• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Compiling [Source-Edit] Player name contains his level?

slavi

#define SLAVI32 _WIN32
Senator
Joined
Sep 9, 2015
Messages
681
Solutions
11
Reaction score
560
GitHub
slavidodo
Hello everybody.
I need to make player's name containing his level.
I've check the player.cpp, player.h and i've found
Code:
void setName(std::string name) {
            this->name = name;
        }
So to use this ?? how? i think i should edit protocolgame.cpp in :
Code:
player = new Player(this);
        player->setName(name);
and editing when player levels up in player.cpp so the name matches the level, Hope someone help me :D
 
Hello everybody.
I need to make player's name containing his level.
I've check the player.cpp, player.h and i've found
Code:
void setName(std::string name) {
            this->name = name;
        }
So to use this ?? how? i think i should edit protocolgame.cpp in :
Code:
player = new Player(this);
        player->setName(name);
and editing when player levels up in player.cpp so the name matches the level, Hope someone help me :D

This may seem like a simple thing to do but it really is not, you will have to set the name in sendAddCreature, which means that every time the level changes you have to tell the client to remove that creature from the battlelist and then add it once more. If i were you i would go with the OTClient approche, and in the function that displays the name, lets say it looks like:
std::string name = creature->getName();
Then do something like
if(creature->getPlayer())
name = creature->getLevel() + " " + name;

This is just pseudo code to show you the basic idea so you don't confuse it with actual code
 
This may seem like a simple thing to do but it really is not, you will have to set the name in sendAddCreature, which means that every time the level changes you have to tell the client to remove that creature from the battlelist and then add it once more. If i were you i would go with the OTClient approche, and in the function that displays the name, lets say it looks like:
std::string name = creature->getName();
Then do something like
if(creature->getPlayer())
name = creature->getLevel() + " " + name;

This is just pseudo code to show you the basic idea so you don't confuse it with actual code
There is sure a way to do it i have the idea but i don't really know how!! and sure it's not simple :

My idea is when the player login it adds [level] to his name and when he logs out it removes [level] from his name, thats may done by regex , "IDK how :D"
and same when he advance level or lose level. that's it but how to do , i have no idea.
 
There is sure a way to do it i have the idea but i don't really know how!! and sure it's not simple :

My idea is when the player login it adds [level] to his name and when he logs out it removes [level] from his name, thats may done by regex , "IDK how :D"
and same when he advance level or lose level. that's it but how to do , i have no idea.
Yeah ofc, the serversided story is simple, just change the variable containing the name. It's getting the client to recognize it that's the tricky part.
 
I don't think that is possible to change the name of the player without reloading the player as the player's name doesn't update as you play.
So if the player was level 10 and the player logged in with the name Joe [level 10] when Joe leveled up his name would remain as Joe [level 10] even though he was level 11.
 
I don't think that is possible to change the name of the player without reloading the player as the player's name doesn't update as you play.
So if the player was level 10 and the player logged in with the name Joe [level 10] when Joe leveled up his name would remain as Joe [level 10] even though he was level 11.
I agree with you, now i figured that this is can't be done without custom client (otclient)
 
Yeah ofc, the serversided story is simple, just change the variable containing the name. It's getting the client to recognize it that's the tricky part.
I had tried all the ways to do it :D all attempts failed . no way so without custom client.
 
It is possible without custom client i think, but custom client would be the easiest approch
Actually it isn't possible with a regular client, monsters load their names just as players do.
Lets say you have a map of trolls and you decide you don't like that name you want them to be mean trolls so you change the name and reload the monsters, any monsters that have already spawned on the map will still be named troll but all new monsters that spawn will be named mean troll.
 
Why do you assume it is not possible with regular client?
VCgd1hkiK.gif


I quote what Scarlet metion:
Tibia client stores in its memories the id of each creature and its name(along with other stuff I believe), so if you for example see a troll in thais, then walk to venore, change the troll name to something else like "FakeTroll" and go back to the Thais troll, you'd still see the name troll because your client had already seen that creature, so it stored its id and name, other players that had never seen that troll before you changed the name will see the new name, but anyone that had already seen it, continues to see the old name, same applies to NPCs and Players.

So only way to get around this is to update creature info to the spectators.
 
Why do you assume it is not possible with regular client?
VCgd1hkiK.gif


I quote what Scarlet metion:


So only way to get around this is to update creature info to the spectators.
So you say it's possible, Could I ask you how to make it then?
 
Actually it isn't possible with a regular client, monsters load their names just as players do.
Lets say you have a map of trolls and you decide you don't like that name you want them to be mean trolls so you change the name and reload the monsters, any monsters that have already spawned on the map will still be named troll but all new monsters that spawn will be named mean troll.
Nah it's surely possible :D i swear.
 
Printer just proved it was possible, he just didn't release his source.
Yeah, It's his own and i should ask for if he expect he don't give.
I was busy the latest hours making the map , surely when i finish i am going to take a very hard look at the source, and if you read my post you would figure that i got some good information and the code used to change player name is
Code:
setname(name)
in (player.h) and if you looked at protocollogin.cpp you will find that the code i 've given is used to give the player a name when he log in.
 
The source is somewhere in the forum, you just need to create an onLogin and onAdvance script to update the name and the creature list.
 
Back
Top