TextDrawSetString set only half of string.
#1

PHP код:
CMD:cmd(playeridparams[])
{
    
//TextDrawShowForPlayer(playerid, BOX1);
    
new string[256];
    new 
File:pos=fopen("something.txt"io_readwrite);
    while(
fread(posstring))
    {
    
format(stringsizeof(string), "%s"string);
    
SendClientMessage(playerid,0,string);
    
TextDrawSetString(BOX1string);
    
TextDrawShowForPlayer(playeridBOX1);
    }
    
fclose(pos);
    return 
1;

You can see, for testing i make this code to send client message and show him a textdraw which is all correct created, but ingame SendClientMessage is okay (show whole line from file) but in box of textdraw show only 2-3 words.

If anyone have solution for this, reply please.
Reply
#2

pawn Код:
CMD:cmd(playerid, params[])
{
    new string[100], fstr[1024];
    new File:pos = fopen("something.txt", io_readwrite);
    while(fread(pos, string))
    {
        strcat(fstr, string);
        SendClientMessage(playerid, -1, string);
    }
    fclose(pos);
    TextDrawSetString(BOX1, fstr);
    TextDrawShowForPlayer(playerid, BOX1);
    return 1;
}
Something tells me you won't need '1024' for your textdraw, so feel free to change that. Without seeing what you're trying to load, I can't put new lines in for you, so you'll have to do that yourself as well.

Basically one of the issues you were having was you used 'string' to store the line that was being read, then you used it to store the previous result which wouldn't work. Once it had finished reading a line, 'string' would just become the second line, so you would just be repeating the line twice. So you need an additional variable to store your current results and then concatenate the strings together.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)