Splitting string issue
#1

Hi all,

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

Code:
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.:

Code:
[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
Reply
#2

pawn Code:
fullName(playerid, false), EMBED_WHITESMOKE, text);
double time

+

you can modify

https://sampforum.blast.hk/showthread.php?tid=606021&page=3
Reply
#3

You are re-writing on the spited string variables which causes this.

Corrected code:
pawn 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);
Reply
#4

Yeah thanks guys, noticed my mistake earlier, should have rplied. Thanks for the help, repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)