[Library] ChatBreaker include - Updated to v1.3. - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Releases (https://forum.open.mp/forumdisplay.php?fid=13) ---- Forum: Libraries (https://forum.open.mp/forumdisplay.php?fid=31) ---- Thread: [Library] ChatBreaker include - Updated to v1.3. (/showthread.php?tid=748) |
ChatBreaker include - Updated to v1.3. - Logan - 2019-08-09 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.
RE: ChatBreaker include - simple implementation - RogueDrifter - 2019-08-16 Ziggi had made something similar to this before i wonder if it still exists RE: ChatBreaker include - simple implementation - Y_Less - 2019-08-19 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. RE: ChatBreaker include - simple implementation - Logan - 2019-08-19 (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. 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. RE: ChatBreaker include - simple implementation - fusez - 2019-08-23 Does it break embedded colors in half? RE: ChatBreaker include - simple implementation - Logan - 2019-08-26 (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. ?? RE: ChatBreaker include - simple implementation - Tama - 2019-10-01 Basically, it same like this: PHP Code: new lol[65]; But with complex mode, i'm right? RE: ChatBreaker include - simple implementation - Logan - 2020-08-02 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. RE: ChatBreaker include - Updated to v1.1. - Logan - 2021-03-27 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! |