OnDialogResponse Help
#1

I'm trying to select the objects ID from this Dialog so I can edit the object. The only problem is no matter what object I select in the list it always selects object id 0..

pawn Код:
if(strcmp(cmd, "/houseinvent", true) == 0)
        {
            for(new i = 0; i < sizeof(HouseInfo); i++)
            {
                if (PlayerToPoint(200.0, playerid,HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
                {
                    if(GetPlayerVirtualWorld(playerid) == HouseInfo[i][EnterWorld])
                    {
                        if(PlayerInfo[playerid][pHouse1] == i || PlayerInfo[playerid][pHouse2] == i)
                        {
                            new info[256];
                            for(new object = 0; object < sizeof(ObjectInfo); object++)
                            {
                                if(ObjectInfo[object][oCreated] == 1 && ObjectInfo[object][oVW] == HouseInfo[i][EnterWorld])
                                {
                                    format(info, sizeof(info), "%s Object ID %d\n", info, object);
                                }
                            }
                            ShowPlayerDialog(playerid,520,DIALOG_STYLE_LIST,"Furniture Inventory:", info, "Select","Cancel");
                            return 1;
                        }
                    }
                }
            }
        }
Here's my response for the dialog

pawn Код:
if(dialogid == 520)
    {
        if(!response)
        {
            SendClientMessage(playerid, 0x42F3F198, "You canceled the dialog.");
            return 1;
        }
        if(response)
        {
            new id;
            sscanf(inputtext[4], "d", id);
            DestroyDynamicObject(ObjectInfo[id][oObject]);
            ObjectInfo[id][oObject] = CreateObject(ObjectInfo[id][oModel],ObjectInfo[id][oX],ObjectInfo[id][oY],ObjectInfo[id][oZ],ObjectInfo[id][oRX],ObjectInfo[id][oRY],ObjectInfo[id][oRZ]);
            EditObject(playerid, ObjectInfo[id][oObject]);
            SendClientMessage(playerid, COLOR_ORANGE, "You're now editing the object.");
            EditingObject[playerid] = id;
            return 1;
        }
    }
Reply
#2

Change:
pawn Код:
sscanf(inputtext[4], "d", id);
to:
pawn Код:
sscanf(inputtext[11], "d", id);
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Change:
pawn Код:
sscanf(inputtext[4], "d", id);
to:
pawn Код:
sscanf(inputtext[11], "d", id);
Thanks but could I ask why I should change that to 11, what is 11 defining here? I haven't really used much of this so I'd like to know how to use it
Reply
#4

Because the inputtext will be (an example): " Object ID 55". So using inputtext[4] will give:
pawn Код:
ect ID 55
and sscanf will fail. However, if you do it with 11, it will return only the ID value.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Because the inputtext will be (an example): " Object ID 55". So using inputtext[4] will give:
pawn Код:
ect ID 55
and sscanf will fail. However, if you do it with 11, it will return only the ID value.
So 11 stands for the last %example in any list item? Sorry I just want to get a better understanding as I'm very un sure.

Lets say for example I changed it to

%s Object ID %d Name %s

What would it have to be then? 11 still or something else for the ID?
Reply
#6

It's the characters before the ID. The inputtext will hold the line you chose so it will start with a space: " Object ID "
That's 11 characters and the next will be the ID.
Reply
#7

I understand now completely thank you very much for explaining that to me!

EDIT: I would +Rep but I already did in the last 24 hours x(
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)