Lua Function Change Existing Monster Name In-Game

perdigs

Member
Joined
Aug 22, 2010
Messages
114
Reaction score
1
I use this script in my server and thks for ideias Scarlet Ayleid
REP ++
 

lucas123

Member
Joined
Jun 6, 2010
Messages
85
Reaction score
4
error on compile in TFS 0.3.6 Crying danson..
please tutorial for 0.3.6


//edit.. i'm compiled =P


IMPORTANT
Tibia Client Limitation:
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,
You can bypass this by doing the same as was done for the guild emblems guildwar ..

protocolold.cpp it is done in [something] and is updated every second, could do the same to update the name of the creatures on screen = P

plz update if you can put .. I know it should be done but do not know that.

Thanks ..
Sorry for my English, S = GOOGLE TRANSLATE


PT:
você pode burlar isso fazendo o mesmo que foi feito para o guild emblems do guildwar..

ele é feito no protocolold.cpp [algo assim] e é atualizado de segundo em segundo, poderia fazer o mesmo para atualizar o nome dos bichos na tela =P

se conseguir atualizar posta plz.. eu sei como deve ser feito mas nao sei fazer isso.

Obrigado..
 
Last edited:
OP
Scarlet Ayleid

Scarlet Ayleid

Intermediate OT User
Joined
Jul 7, 2007
Messages
4,057
Reaction score
232
Honestly, having it like this doesn't bother me since I use a method similar to what I wrote above to prevent this from happening to me, but I'll check it out :)
Could you write a link to that Guildwar System?

Sinceramente, ter isto assim não me incomoda porque eu uso isto de uma maneira semelhante ao que escrevi em cima para prevenir que isso me aconteça, mas eu vou ver :)
Podes escrever um link para o Guildwar System?
 

lucas123

Member
Joined
Jun 6, 2010
Messages
85
Reaction score
4
tipo, eu não posso passar um link pois seria banido a OTLand pois isso é para premium, mas se você olhar o tfs 0.4 ou aquele 6053 eles vão ter as função do tipo updateWar, que seria parecida a que você tem que fazer.

você é br?

type, I can not get a link because it would be banned because it is the OTLand for premium, but if you look at the 6053 tfs 0.4 or that they will have the function of the type updateWar, which would be similar to what you have to do. [google translate]
 
OP
Scarlet Ayleid

Scarlet Ayleid

Intermediate OT User
Joined
Jul 7, 2007
Messages
4,057
Reaction score
232
Okay then, I'll check it out when I have the time then :)

ok, eu vou ver isso quando tiver tempo :)
não sou br, sou pt, se quiseres adicionar-me ao MSN, estas a vontade, o meu email está no meu perfil e na minha assinatura:)
 

spiderspr

New Member
Joined
Oct 1, 2008
Messages
6
Reaction score
0
Inglish:
I used 0.3.6 pl1 ts and made changes so he could be compiled, but when I put the function to run on the server nothing happens, or send an error in the console. I wanted you to help me be able to use this function.

Portuguese:
Eu usei o ts 0.3.6 pl1 e fiz alterações para que podesse ser compilado, mas quando coloco para executar a função no server não acontece nada, nem envia um erro no console. Queria que você me ajudasse a conseguir usar esta função.

The Script
Code:
function onCastSpell(cid, var)
if #getCreatureSummons(cid) <= 0 then
local playerpos = getPlayerPosition(cid)
local Bunshin = doCreateMonster("Bunshin", playerpos)
setCreatureName(Bunshin, "Dran", "a Bunshin" )
doCreatureSay(cid,"Bunshin no Jutsu!", 1) 
end
end
 
OP
Scarlet Ayleid

Scarlet Ayleid

Intermediate OT User
Joined
Jul 7, 2007
Messages
4,057
Reaction score
232
Portuguese
Isso não funciona por causa de uma limitação do cliente Tibia(ve o primeiro post) e eu não quis evitar isso nas sources porque ficava mais pesado

faz assim:
Code:
function onCastSpell(cid, var)
   if #getCreatureSummons(cid) <= 0 then
      local farAwayPos = {x = 100, y = 100, z = 7} --Muda isto/Change This!!
      local Bunshin = doCreateMonster("Bunshin", farAwayPos)
      setCreatureName(Bunshin, "Dran", "a Bunshin")
      doTeleportThing(Bunshin, getPlayerPosition(cid))
      doCreatureSay(cid,"Bunshin no Jutsu!", 1) 
   end
end
assim já vai funcionar :)
não se esqueça de mudar a variavel farAwayPos para um sitio no mapa que tenha a certeza que não tenha ninguem (faz um quadrado 3x3 num canto do mapa e mete as coordenadas dele)

Rep+ se ajudei :)
Se ainda não funcionar, adiciona-me no MSN(ve email na assinatura) e ajudo-te :)
-----------------------------------------------------------------------------------
English
This wont work because of what I said in the first post and I didnt fixed it in sources because its much faster this way

do it like this:
(CHECK CODE ABOVE)

Now, it'll work :)
dont forget to change the farAwayPos to a place where you know no one can go, like for example creating a 3x3 square on a corner of the map and writing its coords

Rep+ if I helped
If it still doesnt work, add me to MSN, my email is on my signature and I'll help you :)
 

spiderspr

New Member
Joined
Oct 1, 2008
Messages
6
Reaction score
0
English:
It worked perfectly, thank you.
One more thing, as I am new to forum was wondering how I can give you + REP.
Portuguese:
Funcionou perfeitamente, muito obrigado.
Mais uma coisa, como sou novo no forum queria saber como posso te dar +REP.
 

Strack

Member
Joined
May 15, 2009
Messages
198
Reaction score
14
after adapting the code...i get this error on protocolgame.cpp
2068 C:\Users\...\protocolgame.cpp [Warning] comparison is always false due to limited range of data type

Code:
if(type > MAGIC_EFFECT_LAST || !canSee(pos))
i'vent touched protocolgame.cpp :S


EDIT:
solved, runs perfectly, and as u said, the client stores last name, but if they logout-login they see new name =)
much thanks!
 
Last edited:
OP
Scarlet Ayleid

Scarlet Ayleid

Intermediate OT User
Joined
Jul 7, 2007
Messages
4,057
Reaction score
232
@Up

if you the script I posted a couple posts above, it'll create a creature in a far away place, change its name there and then teleport it to you, that way you'd never see the real name and the client would always register the new name :)

EDIT:
Added an example function on first post
 
Last edited:

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,168
Reaction score
1,008
Location
Germany :O
You can also edit the "reloadMonster" function so it reloads an existing monster with another name has the same effect and you can just create the monster then.
 
OP
Scarlet Ayleid

Scarlet Ayleid

Intermediate OT User
Joined
Jul 7, 2007
Messages
4,057
Reaction score
232
I can't seem to find a reloadMonster function in 0.4 sources, mind pointing out where it is?
 

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,168
Reaction score
1,008
Location
Germany :O
Monsters::loadMonster
Parameters: file, name, reload
You can add another parameter like "createnew" and then like:

if(createnew)
mType->name = monsterName;
else if(readXMLString(root, "name", strValue))
mType->name = strValue;
else
monsterLoad = false;

and add a new function doCreateNewMonster(name, file) and call like this in there:
g_monsters.loadMonster(file, name, false, true);

It's just another method which I think is easier.

example (for using the completed function):
doCreateNewMonster("Brown Bear", "Bears/bear.xml")
doCreateMonster("Brown Bear", pos)
 
OP
Scarlet Ayleid

Scarlet Ayleid

Intermediate OT User
Joined
Jul 7, 2007
Messages
4,057
Reaction score
232
uhm, I think I'm getting where your going with this, its already 2:30 AM here, so I'm going to bed for now, but tomorrow I'll take a look into it, I believe I already have a good idea on how to do this :)

Thanks :p
 

Strack

Member
Joined
May 15, 2009
Messages
198
Reaction score
14
:O thanks, i'vnt thought on creating it far away and tping it after created xD
 

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
97
Location
Brazil
Lol nice dude, xD
i done it at once but i send the packet to a single player to change a single creature, nice ^^

to change player name is a bit hard. in your code you just change the vars and the serouce do the rest, in player you have to do anything (including the bytes)

Verry nice, i am impressed. Not aways some one do things like this.
 
OP
Scarlet Ayleid

Scarlet Ayleid

Intermediate OT User
Joined
Jul 7, 2007
Messages
4,057
Reaction score
232
Thanks Mock :D

Yeah, from what I've looked at, changing the player name wouldnt be very hard, but wouldnt that maybe generate problems when saving the player to the db(like for example changing the player name to an already existing player name)?
 
Top