AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   problem formatting large strings on multiple lines (https://forums.alliedmods.net/showthread.php?t=53955)

djh 04-14-2007 05:51

problem formatting large strings on multiple lines
 
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.

mysticssjgoku4 04-14-2007 06:04

Re: problem formatting large strings on multiple lines
 
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])     } }

djh 04-14-2007 19:56

Re: problem formatting large strings on multiple lines
 
thanx so much :)


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

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