Raised This Month: $ Target: $400
 0% 

problem formatting large strings on multiple lines


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
djh
Member
Join Date: Nov 2004
Old 04-14-2007 , 05:51   problem formatting large strings on multiple lines
Reply With Quote #1

my problem is with strings composed of multiple lines, and it's a problem somewhat because I don't know the codes pawn recognises as carriage returns, tabs etcetera
"this is the first line
and then we have another
and here's the third
so anyway here it ends"

I want to be able to print that out to a player or several players, with

client_print(id,print_chat,"[line %d] : %s",lineNumber,firstLineOfText)

problem is even if firstLineOfText is 1024 or more characters long hlds won't display more than 256(or so i've noticed)

and ingame I get something similar to this
"this is the first line
and then we have another
and he"

I want to know how I can make it appear like this(for example ofc)
[line 1] : this is the first line
[line 2] : and then we have another
etc.

NOTE: it felt important to mention that it's not a file to just read line by line, but a mysql memo table field.
also, I was wondering how can I make the text displayed with client_print()
green or blue or another color. I've seen some plugins do it, just don't remember wich ones.
thank you for reading

Note: sorry for posting in the wrong forum last night, i was very tired. thanks for understanding.
djh is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 04-14-2007 , 06:04   Re: problem formatting large strings on multiple lines
Reply With Quote #2

Well one way you could accomplish this is:

Code:
stock explode( output[][], input[], delimiter) //Ben 'Promethus' {     new nIdx = 0     new iStringSize     while ( input[iStringSize] )         iStringSize++     new nLen = (1 + copyc( output[nIdx], iStringSize-1, input, delimiter ))         while( nLen < strlen(input) )         nLen += (1 + copyc( output[++nIdx], iStringSize-1, input[nLen], delimiter ))     return nIdx + 1 } #define MAX_LINES 10 #define MAX_LENGTH 128 #define MESSAGE_MAX_SIZE (MAX_LINES*MAX_LENGTH) public read_text(id) {     new whole_message[MESSAGE_MAX_SIZE] //read the memo from the sql into this var         new line_output[MAX_LINES][MAX_LENGTH] //The var all the lines will be stored in     new total_lines = explode(line_output,whole_message,'^n') //returns how many occurances found and split         for(new i = 0; i < total_lines; i++) //careful, you don't want to flood the client if it's alot of info     {         client_print(id,print_chat,"[line %i] : %s",i,line_output[i])     } }
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
djh
Member
Join Date: Nov 2004
Old 04-14-2007 , 19:56   Re: problem formatting large strings on multiple lines
Reply With Quote #3

thanx so much
djh is offline
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

Forum Jump


All times are GMT -4. The time now is 06:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode