SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/07/2016, 09:33 PM   #1
Jonesy96
Huge Clucker
 
Join Date: Jun 2011
Posts: 232
Reputation: 18
Default Splitting string issue

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
Jonesy96 is offline   Reply With Quote
Old 05/07/2016, 10:06 PM   #2
Jefff
Banned
 
Join Date: Dec 2007
Posts: 2,593
Reputation: 326
Default Re: Splitting string issue

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

+

you can modify

http://forum.sa-mp.com/showthread.php?t=606021&page=3
Jefff is offline   Reply With Quote
Old 05/07/2016, 10:17 PM   #3
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Re: Splitting string issue

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);
__________________

Follow me on Github: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 05/07/2016, 10:39 PM   #4
Jonesy96
Huge Clucker
 
Join Date: Jun 2011
Posts: 232
Reputation: 18
Default Re: Splitting string issue

Yeah thanks guys, noticed my mistake earlier, should have rplied. Thanks for the help, repped
Jonesy96 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: Splitting a string? Jantjuh Everything and Nothing 3 17/11/2013 05:58 PM
SSCANF is not splitting string to Variables Admigo Scripting Help 2 18/06/2013 07:11 PM
Splitting a string into two parts, and then combining them again 2KY Scripting Help 2 14/03/2013 08:58 PM
sscanf string splitting bug. Kaaajmak Scripting Help 6 16/02/2013 12:46 PM
Splitting string after length Norn Help Archive 2 02/09/2009 10:12 PM


All times are GMT. The time now is 11:03 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.