• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Show resets onlook - PLS HELP ITS IMPORTANT

Vesgo

Member
Joined
Dec 4, 2009
Messages
356
Solutions
1
Reaction score
15
Location
Brasil
Hello dear friends,

i´ve tried to search all opentibia foruns but could not find what i need. Lets c if anyone can help me out!

I need some instructions to compile my ot with a new function. I already tried to use a creature script but did not worked as i wanted to.

Is there any way to compile the ot (TFS 0.3.6) including a modification on onlook function?

All i want is: You see Vesgo. He is an elite knight. [1 resets].

Thank you for your time!
 
Last edited:
I'm not quite sure what you want... You want the onLook to count how many times that person has been "onLooked" or?...

And what do you mean by "Reset"?
 
Onlook edited with how many REBORNS i have!

Sorry if i did not make myself clear.

Reset is the same as reborn. When a player reaches lvl 350, he can reborn in lvl 8 keeping all his attributes like skills, and so on.

So, when someone take a look on this player, it shows in his description how many times he was reborned. ("reseted").

I do have a creature script in use, but it does not work unless both players look each other, got that? If i look to a player that has not taken a look at me, i dont know how many times he has reborned, until he looks at me, then the script works.

Thank you for your time, i hope someone can help me out!
 
It can be done by this way:
New column in players table called "Resets"
When player uses reset, it will add one point to his resets table
onLook script checks how many resets that player has in "resets" table.

Very easy to do, but I don't have time, sry :)
 
Sure and thank you for your time!

This is my creaturescripts.xml:

PHP:
<event type="look" name="Look" event="script" value="reset.lua"/>

And here goes the reset.lua:

PHP:
function onLook(cid, thing, position, lookDistance)
        if isPlayer(thing.uid) == false then
                return true
        end
		
        local name = getCreatureName(cid)
        
		function getPlayerReset()
 local Query = db.getResult("SELECT `resets` FROM `players` WHERE `players`.`name` = '"..name.."';")
return Query:getDataInt("resets")
  
   
   end

player = getPlayerReset()
      	doPlayerSetSpecialDescription(cid, "  -  Resets: ["..(player).."]")
        return true
end

Thank you again dear friend!


EDIT: Thank you Sonical! But thats exactly what i have, the system works perfectly, but i just would like to know if i can inclued the function into the tfs 0.3.6 source as part of onLook function (to reduce lag) and to get it working perfectly too, because as i said, the creature script gives me tha little bug! Thank you again for you time dude!!!
 
@up
As cyko said, Storage value is the best way to do it, theirs no need for SQL.

Im not sure why you're having the onLook bug if 2 players dont look at each other first, I'm using the following on 0.4 (adapted from my old 0.3.6 script) which works 100%

Code:
doPlayerSetSpecialDescription(cid, "\n"..(getPlayerSex(cid) == PLAYERSEX_FEMALE and "She" or "He") .. " has been reborn " .. (rebirthCount(cid) or 0) .. (rebirthCount(cid) == 1 and " time" or " times"))
 
You must "return FALSE" on an onLook if you wish to use a custom "onLook Text" when looking at an object, or it will simply show the normal "You see Player (Lv. 1). He is a Sorcerer."
You also shouldn't put a function in the middle of another function, makes the scripting engine confused.
And thirdly, I don't know much about "doPlayerSetSpecialDescription" but I suggest you build an onLook sentence from scratch instead.

And like Cykotitan said; Why not use a storage value instead? An SQL query on each and every player-onLook is bound to cause MySQL lag. At the very least you can use a storage value that's updated everytime the player logs in and/or everytime he "resets"/"rebirths". This should decrease the SQL lag.

As for the script, this should hopefully do the trick:

PHP:
function getPlayerReset(cid)
		local name = getCreatureName(cid)
		local Query = db.getResult("SELECT `resets` FROM `players` WHERE `name` = '"..name.."';")
		return Query:getDataInt("resets")
end

function onLook(cid, thing, position, lookDistance)
	if !isPlayer(thing.uid) then
		return true
	end
		
	local name = getCreatureName(thing.uid)
	local level = getPlayerLevel(thing.uid)
	local sex = getPlayerSex(thing.uid)
	local vocation = getPlayerVocationName(thing.uid)
	local resets = getPlayerReset(thing.uid)
	local gmsg = ""
	if sex==0 then sex="She" else sex="He" end
	local msg = "You see "..name.." (Level "..level.."). "..sex.." is a "..vocation..". ["..resets.." resets]."
	if getPlayerGuildId(thing.uid) > 0 then
		local gname = getPlayerGuildName(thing.uid)
		local grank = getPlayerGuildRank(thing.uid)
		local gnick = getPlayerGuildNick(thing.uid)
		gmsg = " "..sex.." is "..grank.." of the "..gname.." ("..gnick..")."
	end
	local echo = msg .. gmsg
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, echo)
	
	return false
end

I haven't tested it, so it if throws up any errors please let me know and I'll see if I can correct it.
 
@up I dont think you would need a onLook function at all, I used my previous code when the player logged in and after his rebirth count changed only.
 
Well, i can only thank very much to all of you!

First: Cykotitan -> I will think about that, maybe that the best way to handle this little problem! Thank you for your attention!

Second: devianceone -> Thank you dear friend, i took a look at your script line and as always i learnt a little bit more!

Third: Rexxar -> OMG! I just could not express myself other way. Im amazed with all this knowledge! I can only thank you dear fellow, i really appreciate your time! I used your script, just changed a little bit and SHAZAM it worked like a charm! Here´s how it looks now:

PHP:
function getPlayerReset(cid) 
        local name = getCreatureName(cid) 
        local Query = db.getResult("SELECT `resets` FROM `players` WHERE `name` = '"..name.."';") 
        return Query:getDataInt("resets") 
end 

function onLook(cid, thing, position, lookDistance) 
    if isPlayer(thing.uid) == false then 
        return true 
    end 
         
    local name = getCreatureName(thing.uid) 
    local level = getPlayerLevel(thing.uid) 
    local sex = getPlayerSex(thing.uid) 
    local vocation = getPlayerVocationName(thing.uid) 
    local resets = getPlayerReset(thing.uid) 
    local gmsg = "" 
    if sex==0 then sex="She" else sex="He" end 
    local msg = "You see "..name.." (Level "..level.."). "..sex.." is a "..vocation..". ["..resets.." resets]." 
    if getPlayerGuildId(thing.uid) > 0 then 
        local gname = getPlayerGuildName(thing.uid) 
        local grank = getPlayerGuildRank(thing.uid) 
        local gnick = getPlayerGuildNick(thing.uid) 
        gmsg = " "..sex.." is "..grank.." of the "..gname.." ("..gnick..")." 
    end 
    local echo = msg .. gmsg 
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, echo) 
     
    return false 
end

Thank you for all that advice!


Well dear friends, and must say that all of you really ROCK at this OpenTibia World! Tell me if i can ever do anything to all of you!

Best wishes,

Vesgo!


SOLVED - PLEASE CLOSE!
 
Last edited:
I use reset function in talkaction. When player says "/reset" he is disconnected, reseted and then login (I won't give datails now).

So, with your great function, I added this code in data\creaturescripts\scripts\login.lua.
When the player login, his description appears automatically.

Code:
resets = db.getResult("SELECT `resets` FROM `players` WHERE `id` = " ..getPlayerGUID(cid).. ""):getDataInt("resets")
doPlayerSetSpecialDescription(cid, ". Has ".. resets .." reset(s)")

I hope it helps you.

^_^
 
Back
Top