• 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!

C++ Monster Nickname

zxmatzx

Advanced OT User
Joined
Dec 1, 2010
Messages
312
Solutions
27
Reaction score
155
Location
Brazil
GitHub
Mateuso8
Hello,
Im needing a function to change the monster name when summoned, i found this: SetCreatureName, but it need some changes, which i don't know how to do, then i asking for help.
In the post, in comments some people said that have a bug, when we change the monster name with players in area, the client don't update the name, a guy posted a solution for this using same function that Convince Creature uses, i think we can solve this with Lua too, doing: teleport monster to specific position with no players, change name and teleport back to original position with altered name.
The real problem is, if i summon a rat with nickname "Mickey" and kill it, i think that onKill and others functions that use creature name, will recive "Mickey" name and not "Rat", then i need a Nickname field not changing the Name field, the client will show the nickname and the server will handle the name normally.

If someone can help, I would be grateful. Even if you don't do the code, giving ideas on how to get around it would help.
Thanks.

--Using TFS 1.2
 
Last edited:
monster:getType():getName() in an onKill event will return the monster's original name.
Then don't have "needing" for the code, would be great if works without tricks, but don't matter if is working, if i select as best answer the thread will be closed? Maybe in future someone do the changes to update name to players in area. Thanks for always help!
 
Then don't have "needing" for the code, would be great if works without tricks, but don't matter if is working, if i select as best answer the thread will be closed? Maybe in future someone do the changes to update name to players in area. Thanks for always help!
What do you mean there's no need for the code? I gave you the solution of your "real problem" with onKill events. Also, what tricks?
 
Could you try to explain better? I don't understand what it is you need. Are you looking for code to fix name changes with players around?
 
Could you try to explain better? I don't understand what it is you need. Are you looking for code to fix name changes with players around?
Sorry, english is not my main language. My problem is solved, but the code in the URL that i sended in first post have a bug(creatures with name changed, don't are updated for players in area). For me, don't really matter, because i can solve the problem with Lua.
Would be great have the code fully working, maybe could help some others, is a great function that open oportunities to many systems.
That is it. I really apreciate your help to me and comunnity, thanks a lot!
 
Sorry, english is not my main language. My problem is solved, but the code in the URL that i sended in first post have a bug(creatures with name changed, don't are updated for players in area). For me, don't really matter, because i can solve the problem with Lua.
Would be great have the code fully working, maybe could help some others, is a great function that open oportunities to many systems.
That is it. I really apreciate your help to me and comunnity, thanks a lot!
If the thread is solved, it should be marked as solved. If you already solved the problem with Lua you can post that solution in the name change thread to help other users.
 
When u change the monster name with the function, if have players in area, those players don't have the monster name updated, to solve this, before u change the monster name, teleport away from any players, and teleport back to right position.

Lua:
local farAwayPosition = {x = 1, y = 1, z = 7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local myMonster = Game.createMonster("Cat", Position(farAwayPosition))--Create a monster far away
    
    myMonster:setName("Tom, the cat", "a Tom")--Change monster name
    
    myMonster:teleportTo(cid:getPosition())--Teleport to player position
    
    return true
end
 
Back
Top