SA-MP Forums Archive
TextDrawSetString automatic update question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: General (https://sampforum.blast.hk/forumdisplay.php?fid=13)
+--- Thread: TextDrawSetString automatic update question (/showthread.php?tid=158664)

Pages: 1 2


TextDrawSetString automatic update question - ғαιιοцт - 10.07.2010

TextDrawSetString automaticly updates the textdraw for everyone that got it showed.

this is what happens now, with the new version of sa-mp
but in the older versions, the textdraw didn't update for all players when you changed it's string..

the problem is that now it isn't possible anymore to use just 1 textdraw to show many different text's to many players (for every player a different text, with the same textdraw)


is it possible to change it back how it was? because now I need to create 200 different textdraws (if I have 200 players) instead of just 1 ...


Re: TextDrawSetString automatic update question - zallomallo - 10.07.2010

I need this too. Like a prison TD, so each player can see their time.


Re: TextDrawSetString automatic update question - ғαιιοцт - 10.07.2010

Can this please be changed back in any further version?

and if people want to refresh their textdraw, they can just do TextdrawShowForPlayer again


Re: TextDrawSetString automatic update question - Grim_ - 10.07.2010

Just create a textdraw for each player?


Re: TextDrawSetString automatic update question - Maggi - 11.07.2010

AutoUpdating textdraws is not good feature... but there can be a flag, that indicates autoupdating - it will be good!

SetTextdrawAutoUpdate(Text:text, bool:auto)

Go and do it, kye!! GO!! xD

P.S: sorry for my bad english)


Re: TextDrawSetString automatic update question - Simon - 11.07.2010

I thought it was always like this. It's a good feature and it makes it easier to update textdraws -- they're global, per-player textdraws are a different feature (e.g. global objects vs per player objects).


Re: TextDrawSetString automatic update question - Maggi - 11.07.2010

The main idea is the formatted template of textdraw... - wich is global


Re: TextDrawSetString automatic update question - Grim_ - 11.07.2010

Maggi, if you want to have different text for each player, just create per-player textdraws, as Simon said.


Re: TextDrawSetString automatic update question - ғαιιοцт - 11.07.2010

Quote:
Originally Posted by Grim_
View Post
Just create a textdraw for each player?
max textdraws = 2048
if you have 200 players on a server:

2048/200= 10 textdraws ... and that's it
isn't that a little stupid? creating every textdraw 200 times, just because they changed the way TextdrawSetString works?

IMO they should change it back the way it was, no automatic update
and if people really want them to autoupdate, they can simply add something like this:

Code:
TextdrawSetStringEx(Text:Textdraw, String)
{
    TextdrawSetString ..
    TextdrawHideForAll....
    TextdrawShowForAll..
}


if you don't understand what I mean with "you can use just 1 textdraw to display a textdraw for every player with a different string":
example:
when I set the string of a textdraw, for playerid 0 to: "Your score: 110"
and then I set the string of that same textdraw (for playerid 1) to: "Your score: 596" and I update it for playerid 1

the score for the first player (id 0) won't change because, for that player, the textdraw isn't updated



-> As long as I don't update the textdraw for a player, it won't change, even if the string has been changed for another player
So you could just use 1 simple textdraw instead of 200 textdraws (1 for every player)




Please Kye or any other developer, have a little thought about this and please change it back the way it was


Re: TextDrawSetString automatic update question - WackoX - 11.07.2010

Yes, 10 totally different Textdraw's for 200 players IF you reach 200 players, that's just a SA:MP limit.
What's wrong with that? that's enough.


Re: TextDrawSetString automatic update question - Grim_ - 11.07.2010

Well, I don't know why you would really need more than 10 textdraws for each player, but if that's your problem, just try reducing the amount you use.


Re: TextDrawSetString automatic update question - ғαιιοцт - 11.07.2010

Quote:
Originally Posted by WackoX
View Post
Yes, 10 totally different Textdraw's for 200 players IF you reach 200 players, that's just a SA:MP limit.
What's wrong with that? that's enough.
isn't it better to create 2048 textdraws instead of 10?

Quote:
Originally Posted by Grim_
View Post
Well, I don't know why you would really need more than 10 textdraws for each player, but if that's your problem, just try reducing the amount you use.
well you might have enough with just 10 textdraws per player but I use Way much more then 10...
it depends on what kind of gamemode you are making


Re: TextDrawSetString automatic update question - Grim_ - 11.07.2010

What kind of things do you possibly fit 10 textdraws into :P

And have you tried deleting some at certain times while they're not being used (instead of hiding) ?


Re: TextDrawSetString automatic update question - ғαιιοцт - 11.07.2010

the main character selection menu uses already 8 textdraws that are different for every player, like showing how many players there are in a team, showing the name of the character you are selection, name of team, score, all names of the players in the team, name of the spawnpoint, the weapon loadout, ...
and that's just the main screen... in-game there are also many more textdraws on the screen like score, kills, deaths, (can be in 1 textdraw), text messages (also different for every player) ...

and there are many more.. so I definitely need more then 10 textdraws


Re: TextDrawSetString automatic update question - Maggi - 11.07.2010

Huh

There is idea:

Panel system, wich is abstraction of higher lvl than textdraws:

1) textdrawCreateTemplate(.....font, color,..x,y, size...) returns template ID
2) textdrawShowForPlayer(templateid, playerid, text[])
3) textdrawShowForPlayerEx(templateid, playerid, text[], x, y, ... or size)
4) destroy.. set flags...etc...

already created for our gamemode... but autoupdating makes a lot of problems =((


Re: TextDrawSetString automatic update question - Simon - 11.07.2010

You can destroy textdraws, that's the reason why there's TextDrawDestroy. 10 text draws on a screen at once for every player is a lot. The real problem seems to be coding efficiently within the limits..

Showing how many players there are in a team - global, destroy when nobody is viewing the team. Update with TextDrawSetString.
Showing the name of the character you are selection - global, show to all players viewing the class, destroy when not in use.
Name of team - global, destroy when nobody is viewing the team.
Score - Team Score? global. If not teamscore then +1 per player textdraw.
All names of the players in the team - global, destroy when nobody is viewing the class, update when a player is added using TextDrawSetString.
Name of the spawnpoint - global, destroy when nobody is viewing the class
The weapon loadout - global, destroy when nobody is viewing the class

Lets say you have 32 teams and 200 players in the server, that means the maximum amount of text draws ever for your class selection is 224 or 392 (6*32+200 if per-player score, 7*32 if teamscore)... if you wanted to be even more efficient then you'd use the textdraw character limit (1024) to your advantage (e.g. One textdraw = "Name: <Name>~n~Players: <Players>~n~TeamScore: <TeamScore>~n~"

Your ingame textdraws max limit would be 2*200 (400, textmessages as 1, score-kills-deaths as 1), so assuming worse case scenario above you would have a maximum of 400 textdraws created!


Re: TextDrawSetString automatic update question - Maggi - 11.07.2010

Simon, your method is not correct....There is a memory usage problem too... Ex: heavy loaded RPG server 450 players with 30 or more textdraws (speedo, duel, messaging system, race status, clan wars, territory wars, job panel (mechanics...carjacker.. etc....) GPS... and lot of things... and each panel has its format and has its position slot in screen....



TextDraws like chat messages..except coords...Do you ceate chat for every player?? NO. You just send message with color to player...


Re: TextDrawSetString automatic update question - ғαιιοцт - 11.07.2010

Simon,
for you it might be so easy, but in my gamemode I use a lot of textdraws, and there are moments when there Have to be more then 10 textdraws shown on 1 screen at the time.. so I can't destroy any of them....

and about this:
"Name: <Name>~n~Players: <Players>~n~TeamScore: <TeamScore>~n~"
that's possible when all text's are lined out right beneath eachother, but they are all over the screen.
there are some at the left middle, some at the right top, some at ...

and why are you all making such a problem of it? it's very easy for kye to change it back how it was.. and there are no disadvantages for anyone


Re: TextDrawSetString automatic update question - Simon - 11.07.2010

Per-player text draws should be the solution or at least a TextDrawSetStringForPlayer. There is no playerid parameter in TextDrawSetString because it is intended to be global, you guys were taking advantage of a bug.

The reason people are making a big "problem" out of it is because your simple change can effect already working scripts. It also creates an inconsistent and non-logical side effect for the scripting API (i.e. per player updates on a global text on a function which doesn't state so).

Will have to see what Kye sees them as, I may have just been mislead into what these functions are. I've always used them based on the assumption they're supposed to be global texts.


Re: TextDrawSetString automatic update question - ғαιιοцт - 11.07.2010

I totally agree with the TextdrawSetStringForPlayer
- TextdrawSetStringFor should change a GLOBAL textdraw's string, and update it for ALL players
- TextdrawSetStringForPlayer should change a GLOBAL textdraw's string, and update it for the given playerid (-> and when using this, we can take advantage of the fact that we can use only 1 textdraw for all players; this would solve my problem)