Weird string overwriting
#1

I think images and code speak by themselves.


(It's a dialog showing a list of possibile options. "Lavori" means "Jobs" in Italian)

pawn Код:
if(response)
{
    print(inputtext);
    format(string, sizeof(string), "Guide/%s.info", inputtext);
    print(string);
    ...


I'm not getting it. Why does the point mess up this string formatting?
Reply
#2

Quote:
Originally Posted by DarkSlyder
Посмотреть сообщение
I think images and code speak by themselves.


(It's a dialog showing a list of possibile options. "Lavori" means "Jobs" in Italian)

pawn Код:
if(response)
{
    print(inputtext);
    format(string, sizeof(string), "Guide/%s.info", inputtext);
    print(string);
    ...


I'm not getting it. Why does the point mess up this string formatting?
As i know, the listed dialogs doesnt return a text.
Reply
#3

No, they do. They return the text of the line you clicked. As you can see I've already tested that ("print(inputtext);").
Reply
#4

dude i gues there is an string so use printf();
Reply
#5

sorry, misread

Can you show more code? Where you declared 'new string'?
Reply
#6

I don't need to print that string, I need to open a file with that name (scriptfiles/Guide/Lavori.info).
The string is declared at the first line of OnDialogResponse. I use it for every dialog, instead of declaring a new string for every "case". I've already checked that the string is empty before formatting it.
I've also tried to "create" the path string with "strcat" or by copying words one by one, but it didn't succeed.
Reply
#7

But does it actually format it correctly? Try like someone above said with printf just for a debug to see what it prints.
pawn Код:
printf("Guide/%s.info", inputtext);
Reply
#8

Just tested, same result.
Reply
#9

It's something wrong on your side. I tested it and it works fine.

PS: I just use an include for includes, but it still should work with the normal way.
pawn Код:
#define FILTERSCRIPT

#include < a_samp >
#include < easydialog >
#include < zcmd >

CMD:test( playerid, params[ ] )
{
    ShowDialog( playerid, Show:Test, DIALOG_STYLE_LIST, "Test", "Lavori\nNegozi di abbigliamento\nLuoghi comuni\nDistributori di benzina\nBar\nRistoranti\nCasino", "Select", "Cancel" );
    return 1;
}

Dialog:Test( playerid, response, listitem, inputtext[ ] )
{
    if( response )
    {
        print( inputtext );
        printf( "Guide/%s.info", inputtext );
    }
    return 1;
}
Quote:

[20:38:52] Lavori
[20:38:52] Guide/Lavori.info

Reply
#10

You're right, just tested on a blank gamemode and your code worked good.
It must be something related to the creation of the dialog.
pawn Код:
COMMAND:guidatest(playerid, params[])
{
    new File: file = fopen("Guide/Guide_Main.info", io_read),
        string[64], longstring[600];
    if(file)
    {
        while(fread(file, string))
        {
            strcat(longstring, string);
            strcat(longstring, "\n");
        }
        fclose(file);
        ShowPlayerDialog(playerid, 999, DIALOG_STYLE_LIST, "Guida", longstring, "Seleziona", "Annulla");
    }
    return 1;
}
I've tested this on the same filterscript and the commands (/test, /guidatest) printed two different results with the same dialog list.
Reply
#11

Bump.
Reply
#12

is that string global ?

Also u can debug it by making a custom print function and fallowing where inputs are coming from
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)