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

OTClient createWidget is it possible to display text on x,y,z

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
1,051
Solutions
5
Reaction score
62
Hello is it possible to display without any source changes or stuff like that to display text trough otclient on x,y,z with createWidget? Basically a tile widgets i heard that its unique system and not really possible without writing a custom shit for it
 
Best way to work with these widgets is to integrate them on the server so they are persistent and easier to manage.
Yea you probably right, doing it only trough client side is not the way. Could you drop an example of server side? so it would guide me a correct way
 
Yea managed to do it, the shit is hella glitched up it needs floor check and etc weird behaviour my code is just to trash
Maybe I'm wrong. I did not check OTCv8 code, but it makes sense, that you have to check in your Lua code floor and position, and check 'onWalk', if position is on player screen. How could it work to attach some widget to Tile ex. x=12345, y=12345, z=15, if player does not see given Tile on his screen? Given Tile (C++ object) is not defined in RAM at all.
Of course it could (by checking it all in C++ [onWalk]), but then - for other users -, it would waste CPU/RAM. Right now it probably removes Tile and it's attached widget when player moves XX tiles away from it.
Yea you probably right, doing it only trough client side is not the way. Could you drop an example of server side? so it would guide me a correct way
I think he meant C++ changes in OTS and OTC, to transfer extra information (ex. text), when new tile appears on player screen (protocolgame.cpp, protocolgameparse.cpp).
On new OTS engines, you can execute onMove Lua event on server side to detect new tiles appearing on screen and send extra texts attached to them, but it would be a huge waste of CPU. Code on server side would be the same as you do on client side (check floor and position), just waste server CPU, not client CPU.

If positions and texts are static and you use client updater (you can update them later), then use Lua script on client side to detect floors/positions and do not waste server CPU for it.
 
Maybe I'm wrong. I did not check OTCv8 code, but it makes sense, that you have to check in your Lua code floor and position, and check 'onWalk', if position is on player screen. How could it work to attach some widget to Tile ex. x=12345, y=12345, z=15, if player does not see given Tile on his screen? Given Tile (C++ object) is not defined in RAM at all.
Of course it could (by checking it all in C++ [onWalk]), but then - for other users -, it would waste CPU/RAM. Right now it probably removes Tile and it's attached widget when player moves XX tiles away from it.

I think he meant C++ changes in OTS and OTC, to transfer extra information (ex. text), when new tile appears on player screen (protocolgame.cpp, protocolgameparse.cpp).
On new OTS engines, you can execute onMove Lua event on server side to detect new tiles appearing on screen and send extra texts attached to them, but it would be a huge waste of CPU. Code on server side would be the same as you do on client side (check floor and position), just waste server CPU, not client CPU.

If positions and texts are static and you use client updater (you can update them later), then use Lua script on client side to detect floors/positions and do not waste server CPU for it.
Did I understand you correctly that using the server side isn’t the best option for performance, and that for better efficiency, I could address the issue through the client side instead? However, as Oen mentioned, server-side handling makes the data persistent and easier to manage. And to save CPU and RAM, what if instead of loading all extra information on player login and deleting it when the tile is off-screen, we keep the information loaded persistently, even if the player moves away? I assume this would not consume a noticeable amount of RAM or CPU since the data is static and doesn't need frequent update or am I wrong in thinking that? So basically its like that information is static part of the map
 
Did I understand you correctly that using the server side isn’t the best option for performance, and that for better efficiency, I could address the issue through the client side instead?
Yes.
However, as Oen mentioned, server-side handling makes the data persistent and easier to manage
Yes.

It's easier to manage on server side, so if you change texts on Tiles multiple times a day (ex. want to show current boss name over teleport and boss name changes few times a day), you should do it server side.

If you just want to put some texts over depot/temple teleports like "Bosses"/"Quests" than use client side.

There is also possibility to combine both systems, but it would be most complicated system. It would reduce CPU usage on server side and make positions and texts load dynamically from server into client C++/Lua code.

And to save CPU and RAM, what if instead of loading all extra information on player login and deleting it when the tile is off-screen, we keep the information loaded persistently, even if the player moves away?
There is no magic. Tibia streams Tiles from server to client as player walks around.
Client does not store in RAM Tiles that are not visible on screen.
Server stores all Tiles in RAM, but sends them to client only when players make steps in game that makes them visible.

One side will have to calculate what Tiles players sees on screen. It can be done 100% on client side (with onWalk event and own module to calculate texts to show on given Tile position/floor) or with some calculation on client side and most of calculation on server side (OTC can just add/remove tile texts and server can calculate it all).

As server has just 1 CPU and players CPUs count grows with players count (1 player = 1 CPU, 1000 players = 1000 CPUs), I would put all I don't have to calculate on server on client side.

I assume this would not consume a noticeable amount of RAM or CPU since the data is static and doesn't need frequent update or am I wrong in thinking that?
For sure it's not noticeable with 1-10 players online, but when you get 500-1000 online, every extra 'IF' is noticeable. You should not assign extra IFs to walking on server side. Popular evo OTSes execute 5k steps per second - it's extra XX tiles (15-23) visible on player screen per second per player. Now imagine that your Lua onMove script takes 1k CPU cycles (of 5kkk total CPU cycles on top dedicated server CPU) per Tile to execute. You can waste FEW percent of server CPU just to implement 'text widget' on server side!
 
Last edited:
Yes.

Yes.

It's easier to manage on server side, so if you change texts on Tiles multiple times a day (ex. want to show current boss name over teleport and boss name changes few times a day), you should do it server side.

If you just want to put some texts over depot/temple teleports like "Bosses"/"Quests" than use client side.

There is also possibility to combine both systems, but it would be most complicated system. It would reduce CPU usage on server side and make positions and texts load dynamically from server into client C++/Lua code.


There is no magic. Tibia streams Tiles from server to client as player walks around.
Client does not store in RAM Tiles that are not visible on screen.
Server stores all Tiles in RAM, but sends them to client only when players make steps in game that makes them visible.

One side will have to calculate what Tiles players sees on screen. It can be done 100% on client side (with onWalk event and own module to calculate texts to show on given Tile position/floor) or with some calculation on client side and most of calculation on server side (OTC can just add/remove tile texts and server can calculate it all).

As server has just 1 CPU and players CPUs count grows with players count (1 player = 1 CPU, 1000 players = 1000 CPUs), I would put all I don't have to calculate on server on client side.


For sure it's not noticeable with 1-10 players online, but when you get 500-1000 online, every extra 'IF' is noticeable. You should not assign extra IFs to walking on server side. Popular evo OTSes execute 5k steps per second - it's extra XX tiles (15-23) visible on player screen per second per player. Now imagine that your Lua onMove script takes 1k CPU cycles (of 5kkk total CPU cycles on top dedicated server CPU) per Tile to execute. You can waste FEW percent of server CPU just to implement 'text widget' on server side!
So you say use OnMove doesnt it means that OnMove will be executed every step inside client aswell? So it hits client performance like a truck aswell by using OnMove
 
So you say use OnMove doesnt it means that OnMove will be executed every step inside client aswell?
Code on both sides is 100% the same.
You can hit 1000 CPUs of 1000 players making them get 199 FPS, not 200 FPS.
Or you can make it all calculate on server side, making server CPU goes from 0.1% to 100% with 1000 online and make everyone on OTS lag in game. You can easily waste 100% CPU of your server on - badly written - script like this ("tile texts").
 
Code on both sides is 100% the same.
You can hit 1000 CPUs of 1000 players making them get 199 FPS, not 200 FPS.
Or you can make it all calculate on server side, making server CPU goes from 0.1% to 100% with 1000 online and make everyone on OTS lag in game. You can easily waste 100% CPU of your server on - badly written - script like this ("tile texts").
Well thanks that confirms that i need to use client side only
 
Having it on the server side is better for the performance than having it hardcoded on the client (the more widgets you need the more CPU/RAM you will consume, depending if its O(n) or O(1)).
Just check if the tile that you are currently sending to the player (in ProtocolGame) has widget data and then send it.
C++:
    if (tile && tile->hasFlag(TILESTATE_WIDGET)) {
        const TileWidget& widget = tile->getWidget();
        NetworkMessage msg;
        msg.addByte(60);
        msg.addPosition(pos);
        msg.addString(widget.text);

        writeToOutputBuffer(msg);
    }

Create onStartup script and tile:setWidget(yourWidgetData) on any tile you want.
 
Back
Top