• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Library] ChatBreaker include - Updated to v1.3.
#1
Greetings dear Burgershot members.



Intro



I made this simple, yet effective?include a few months ago for server I was scripting, so since it's very simple to implement and since you don't have to touch your code to break your SendClientMessage/SendClientMessageToAll chat lines in two lines, I decided to share it with you. I hope you like it!



How to install it/implement it?



It depends if you're using modular/non-modular style of coding on your gamemode. If you're using modular, just #include it into your main gamemode file. Else, just paste it somewhere on top of your script where you defined public functions/stocks/etc.?



How it works/what does it do?



Very simple. It breaks strings passed into SCM/SCMToAll longer than 100 chars. You can find out the rest by looking at the code. "Uniqueness" of it is that it never breaks string in the middle of the word, always before/after, or as you can say it, space is the signal for breaking.



Download:




Updates:



08/2020 - v1.1. - Added support for breaking/passing embedded colors in next chat line/row.

03/2021 - v1.3 - Reduced memory consumption and implemented y_va.?Now on github & supported as a sampctl package, repository created.

Best regards, Logan.
  Reply
#2
Ziggi had made something similar to this before i wonder if it still exists
  Reply
#3
While using spaces is not at all a unique way of splitting strings, it's a good effort. However, there are many ways it can be improved. You don't need to copy the strings around at all, simply inserting a null character will end a string so you can send part, then put the original character back. This method is infinitely extendable so you aren't limited to 2 lines only.



You've also not considered what happens if someone types a very long line with no spaces. Most systems will also opt to split mid word if it is a long word and the lines would otherwise be extremely unbalanced.
  Reply
#4
(2019-08-19, 05:38 AM)Y_Less Wrote: While using spaces is not at all a unique way of splitting strings, it's a good effort. However, there are many ways it can be improved. You don't need to copy the strings around at all, simply inserting a null character will end a string so you can send part, then put the original character back. This method is infinitely extendable so you aren't limited to 2 lines only.



You've also not considered what happens if someone types a very long line with no spaces. Most systems will also opt to split mid word if it is a long word and the lines would otherwise be extremely unbalanced.

Thanks, didn't know that actually. But my goal was breaking in max TWO lines, because of aestethics, and I didn't want to pile up my chatbox more than it is



I've considered second option - if broken bool stays false after the loop, it sends the line as it is, unbroken. That's why it seeks space from 60th char, and it breaks after 90, just so it can find "optimal" space for breaking. Neary?any word exists that?has more than 30 chars in one piece without space, so I've used that to break.
  Reply
#5
Does it break embedded colors in half?
  Reply
#6
(2019-08-23, 08:02 PM)fusez Wrote: Does it break embedded colors in half?

Since it only breaks on empty space, you can safely use it with embedded colors. ??
  Reply
#7
Basically, it same like this:

PHP Code:
new lol[65];



format(lol65"%.64s"text);

SendClientMessage(playeridCOLOR_WHATEVERlol);



format(lol65"...%s"text[64]);

SendClientMessage(playeridCOLOR_WHATEVERlol); 



But with complex mode, i'm right?
???? ???? ????? ?? ???????? ???? ?????, ?? ???? ???? ?? ?????? ?? ??? ???? ???? ???? ?? ??? ???? ??? ???? ??? ?? ?? ?????? ??????





  Reply
#8
Mini update:

08/2020 - v1.1. - Added support for breaking/passing embedded colors in next chat line/row

Also I updated pastebin link to v1.1.



Been using it for a while now, no known bugs or problems occured. If you have a suggestion, I'll look into it and try to come up with something.
  Reply
#9
Update - now available as a sampctl package and repository on: https://github.com/ZanderOperator/ChatBreaker
Star the repository and support my developing journey by following me. Thank you!
  Reply


Forum Jump: