• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Library] TextDraw Streamer* - No more textdraw limits!
#1
TextDraw Streamer* - No more textdraw limits!



[Image: sampctl-samp--td--streamer-2f2f2f.svg?st...-the-badge]



This library removes the limits on how many textdraws can be created at the same time (2048 global and 256 per-player textdraws as of 0.3.7 and 0.3.DL). The library works by only creating the textdraws when they are visible for anyone. This is a rewrite of the PlayerTextDrawStreamer include, originally created by theYiin and later maintained by me. Some benefits over the old include:


  • Support for global textdraws.

  • No limits at all - the old include used static arrays meaning that the limits were still there, they were just higher. This library uses PawnPlus for dynamic containers and dynamically allocated strings, meaning that

  • Smaller footprint on the binary size - Again, static arrays are replaced with dynamic memory, the old include increased the binary size by several megabytes and also increased the compilation time drastically, compared to this the footprint of this library is almost non-existent.


* - Technically, this library does not do any streaming. However, in the SA-MP community, the name ?streamer? is often associated with something that removes hardcoded limits from something, therefore this name is used to help people find the library.



Installation



Simply install to your project:



Code:
sampctl package install kristoisberg/samp-td-streamer



To use the streamer for global textdraws, include the following file:



PHP Code:
#include <td-streamer-global> 



To use the streamer for per-player textdraws, include the following file:



PHP Code:
#include <td-streamer-player> 



If you wish to use it for both, you can either include both of the previous files or simply include:



PHP Code:
#include <td-streamer> 



Notes: This library must be the first one to hook any textdraw-related functions, otherwise a compile time error will be thrown. Neither should any textdraw-related functions or callbacks be used before the inclusion of this library. If YSF or SKY are used, they must be included before this library.



Usage



The include is completely plug & play, after being installed properly it should automatically do its job.



Functions



The following functions are either modified or added by this library:



td-streamer-global.inc



PHP Code:
Text:TextDrawCreate(Float:xFloat:y, const text[]);

Text:TextDrawCreate_s(Float:xFloat:yString:text);

IsValidTextDraw(Text:text);

TextDrawDestroy(Text:text);

TextDrawShowForPlayer(playeridText:text);

TextDrawHideForPlayer(playeridText:text);

TextDrawShowForAll(Text:text);

TextDrawHideForAll(Text:text);

IsTextDrawVisibleForPlayer(playeridText:text);

TextDrawSetString(Text:text, const string[]);

TextDrawGetString(Text:textstring[], len sizeof(string));

TextDrawSetString_s(Text:textString:string);

String:TextDrawGetString_s(Text:text);

TextDrawSetPos(Text:textFloat:xFloat:y); // TextDrawSetPosition also works if SKY is included

TextDrawGetPos(Text:text, &Float:x, &Float:y);

TextDrawLetterSize(Text:textFloat:xFloat:y);

TextDrawGetLetterSize(Text:text, &Float:x, &Float:y);

TextDrawTextSize(Text:textFloat:xFloat:y);

TextDrawGetTextSize(Text:text, &Float:x, &Float:y);

TextDrawColor(Text:textcolor);

TextDrawGetColor(Text:text);

TextDrawBoxColor(Text:textcolor);

TextDrawGetBoxColor(Text:text);

TextDrawBackgroundColor(Text:textcolor);

TextDrawGetBackgroundColor(Text:text);

TextDrawSetShadow(Text:textsize);

TextDrawGetShadow(Text:text);

TextDrawSetOutline(Text:textsize);

TextDrawGetOutline(Text:text);

TextDrawFont(Text:textfont);

TextDrawGetFont(Text:text);

TextDrawUseBox(Text:text, use);

TextDrawIsBox(Text:text);

TextDrawSetProportional(Text:textset);

TextDrawIsProportional(Text:text);

TextDrawSetSelectable(Text:textset);

TextDrawIsSelectable(Text:text);

TextDrawAlignment(Text:textalignment);

TextDrawGetAlignment(Text:text);

TextDrawSetPreviewModel(Text:textmodel);

TextDrawGetPreviewModel(Text:text);

TextDrawSetPreviewRot(Text:textFloat:xFloat:yFloat:zFloat:zoom 1.0);

TextDrawGetPreviewRot(Text:text, &Float:x, &Float:y, &Float:z, &Float:zoom);

TextDrawSetPreviewVehCol(Text:textcolor1color2);

TextDrawGetPreviewVehCol(Text:text, &color1, &color2);

TextDrawSetExtraID(Text:textextra1extra2 INVALID_TEXTDRAW_EXTRA_ID);

TextDrawGetExtraID(Text:text, &extra1, &extra2 INVALID_TEXTDRAW_EXTRA_ID); 



td-streamer-player.inc



PHP Code:
PlayerText:CreatePlayerTextDraw(playeridFloat:xFloat:y, const text[]);

PlayerText:CreatePlayerTextDraw_s(playeridFloat:xFloat:yString:text);

PlayerTextDrawDestroy(playeridPlayerText:text);

PlayerTextDrawShow(playeridPlayerText:text);

PlayerTextDrawHide(playeridPlayerText:text);

IsPlayerTextDrawVisible(playeridPlayerText:text);

PlayerTextDrawSetString(playeridPlayerText:text, const string[]);

PlayerTextDrawGetString(playeridPlayerText:textstring[], len sizeof(string));

PlayerTextDrawSetString_s(playeridPlayerText:textString:string);

String:PlayerTextDrawGetString_s(playeridPlayerText:text);

PlayerTextDrawSetPos(playeridPlayerText:textFloat:xFloat:y); // PlayerTextDrawSetPosition also works if SKY is included

PlayerTextDrawGetPos(playeridPlayerText:text, &Float:x, &Float:y);

PlayerTextDrawLetterSize(playeridPlayerText:textFloat:xFloat:y);

PlayerTextDrawGetLetterSize(playeridPlayerText:text, &Float:x, &Float:y);

PlayerTextDrawTextSize(playeridPlayerText:textFloat:xFloat:y);

PlayerTextDrawGetTextSize(playeridPlayerText:text, &Float:x, &Float:y);

PlayerTextDrawColor(playeridPlayerText:textcolor);

PlayerTextDrawGetColor(playeridPlayerText:text);

PlayerTextDrawBoxColor(playeridPlayerText:textcolor);

PlayerTextDrawGetBoxColor(playeridPlayerText:text);

PlayerTextDrawBackgroundColor(playeridPlayerText:textcolor);

PlayerTextDrawGetBackgroundColor(playeridPlayerText:text);

PlayerTextDrawSetShadow(playeridPlayerText:textsize);

PlayerTextDrawGetShadow(playeridPlayerText:text);

PlayerTextDrawSetOutline(playeridPlayerText:textsize);

PlayerTextDrawGetOutline(playeridPlayerText:text);

PlayerTextDrawFont(playeridPlayerText:textfont);

PlayerTextDrawGetFont(playeridPlayerText:text);

PlayerTextDrawUseBox(playeridPlayerText:text, use);

PlayerTextDrawIsBox(playeridPlayerText:text);

PlayerTextDrawSetProportional(playeridPlayerText:textset);

PlayerTextDrawIsProportional(playeridPlayerText:text);

PlayerTextDrawSetSelectable(playeridPlayerText:textset);

PlayerTextDrawIsSelectable(playeridPlayerText:text);

PlayerTextDrawAlignment(playeridPlayerText:textalignment);

PlayerTextDrawGetAlignment(playeridPlayerText:text);

PlayerTextDrawSetPreviewModel(playeridPlayerText:textmodel);

PlayerTextDrawGetPreviewModel(playeridPlayerText:text);

PlayerTextDrawSetPreviewRot(playeridPlayerText:textFloat:xFloat:yFloat:zFloat:zoom 1.0);

PlayerTextDrawGetPreviewRot(playeridPlayerText:text, &Float:x, &Float:y, &Float:z, &Float:zoom);

PlayerTextDrawSetPreviewVehCol(playeridPlayerText:textcolor1color2);

PlayerTextDrawGetPreviewVehCol(playeridPlayerText:text, &color1, &color2);

PlayerTextDrawSetExtraID(playeridPlayerText:textextra1extra2 INVALID_TEXTDRAW_EXTRA_ID);

PlayerTextDrawGetExtraID(playeridPlayerText:text, &extra1, &extra2 INVALID_TEXTDRAW_EXTRA_ID); 



Testing



The test.pwn file contains automated tests and a test script using MSelect by Open-GTO. To test, simply run the package:



Code:
sampctl package run
  Reply


Messages In This Thread
TextDraw Streamer* - No more textdraw limits! - by kristo - 2019-04-13, 11:05 PM

Forum Jump: