PDA

View Full Version : Splitting string issue


Jonesy96
05/07/2016, 09:33 PM
Hi all,

I'm scripting to make OnPlayerText go onto 2 lines. My code is below:


new str1[144], str2[144], max_str = 110;
strmid(str1, text, 0, max_str);
strmid(str2, text, max_str, strlen(text));

format(str1, sizeof(str1), "{%s}%s: {%s}%s...",EMBED_WHITE, fullName(playerid, false), EMBED_WHITESMOKE, text);
format(str2, sizeof(str2), "{%s}%s: {%s}...%s",EMBED_WHITE, fullName(playerid, false), EMBED_WHITESMOKE, text);

ProxDetector(15.0, playerid, str1);
ProxDetector(15.0, playerid, str2);


However, rather than str2 dipsplaying the second half of the message, it just redisplays the first part of the message. E.g.:


[22:22:07] {FFFFFF}Joe Bloggs: {F5F5FF}I am simply testing this script. It's supposed to put things on 2 lines. However, whether that actually happens

[22:22:07] {FFFFFF}Joe Bloggs: {F5F5FF}...I am simply testing this script. It's supposed to put things on 2 lines. However, whether that actually happe


Can anyone see my error?

Thanks

Jefff
05/07/2016, 10:06 PM
fullName(playerid, false), EMBED_WHITESMOKE, text);
double time

+

you can modify

http://forum.sa-mp.com/showthread.php?t=606021&page=3

Gammix
05/07/2016, 10:17 PM
You are re-writing on the spited string variables which causes this.

Corrected code:

format(str1, sizeof(str1), "{%s}%s: {%s}%s...",EMBED_WHITE, fullName(playerid, false), EMBED_WHITESMOKE, str1);
format(str2, sizeof(str2), "{%s}%s: {%s}...%s",EMBED_WHITE, fullName(playerid, false), EMBED_WHITESMOKE, str2);

Jonesy96
05/07/2016, 10:39 PM
Yeah thanks guys, noticed my mistake earlier, should have rplied. Thanks for the help, repped