I'm stuck at this...totally
#1

So, I'm working on a script of mine, let's say, we add 3 items in my dialog.

Item1
Item2
Item3

Let's say I delete Item2, then my dialog becomes:

Item1
Item3

I can select Item1, but when I select item3 it won't select.

A good example is exactly what I need is in Zamaroht's textdraw editor, where you can delete and select created textdraws with ease.. I'm really stuck at this, I almost did like what Zamaroht did but I simply can't make it work! I just won't select the next textdraw.

Here is some pieces of code that might help you guys help me?


This code I use when selecting my textdraw.
pawn Код:
new id;
for(new t=-1; t < MAX_TEXTDRAWS; t ++)
{
    if(td_i[t][created])
    {
        if(id == listitem)
        {
            td_editing = t;
            SendClientMessageEx(playerid, -1, "Selected sprite id {FF0000}%d{FFFFFF}.", td_editing);
            break;
        }
    }
}

And this is the code I have when deleting a textdraw.

pawn Код:
if(!response)
    return OnPlayerCommandText(playerid, #/txd);

OnPlayerCommandText(playerid, "/txd");
TextDrawHideForAll(td_i[td_editing][td]);

td_i[td_editing][created] = 0;
td_i[td_editing][td_y] = 0.0;
td_i[td_editing][td_x] = 0.0;
td_i[td_editing][td_height] = 0.0;
td_i[td_editing][td_width] = 0.0;
td_i[td_editing][td_color] = RGB(HexToInt(#FF), HexToInt(#FF), HexToInt(#FF), HexToInt(#FF));
format(td_i[td_editing][td_name],30, " ");
td_editing = -1;
Here's an image to explain better:

Maybe you understood me somehow
Reply
#2

You're selecting LD_OTB thingy which doesn't exist = in some point you have a bug that prevents the dialog listing from updating properly (and noticing that listitem id=1 is now intro1:intro1 not LD_OTB), that's the only thing I can think about now
Reply
#3

I see a bit of redundant code:

pawn Код:
new id;
for(new t=-1; t < MAX_TEXTDRAWS; t ++)
{
    if(td_i[t][created])
    {
        if(id == listitem)
        {
            td_editing = t;
            SendClientMessageEx(playerid, -1, "Selected sprite id {FF0000}%d{FFFFFF}.", td_editing);
            break;
        }
    }
}
What's the purpose of the "id" variable? You're creating it and not assigning a value to it, so basically what your if statement says is:

pawn Код:
if(0 == listitem)
Which is pretty redundant, that variable seems utterly pointless!
Reply
#4

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
I see a bit of redundant code:

pawn Код:
new id;
for(new t=-1; t < MAX_TEXTDRAWS; t ++)
{
    if(td_i[t][created])
    {
        if(id == listitem)
        {
            td_editing = t;
            SendClientMessageEx(playerid, -1, "Selected sprite id {FF0000}%d{FFFFFF}.", td_editing);
            break;
        }
    }
}
What's the purpose of the "id" variable? You're creating it and not assigning a value to it, so basically what your if statement says is:

pawn Код:
if(0 == listitem)
Which is pretty redundant, that variable seems utterly pointless!
While I decided to make a topic about this problem I've reversed my code back by pressing Ctrl+z, and didn't notice that id++; was missing.

It was like this:
pawn Код:
new id;
for(new t=-1; t < MAX_TEXTDRAWS; t ++)
{
    if(td_i[t][created])
    {
        if(id == listitem)
        {
            td_editing = t;
            SendClientMessageEx(playerid, -1, "Selected sprite id {FF0000}%d{FFFFFF}.", td_editing);
            break;
        }
        id++'
    }
}
I'm really stuck I have no idea how Zamaroht did it, I've tried to understand, but I can't actually..
He's a sort of a genius of the way he thought of scripting that textdraw editor!
Reply
#5

Every time you create a dynamic dialog list, you must cache its contents, like (pseudocode):

Код:
foreach Textdraw
    format(string, "%s textdraw %i\n",string, textdrawid);
    Cache[playerid][i] = textdrawid;
    i++

OnThatDialogResponse
    DoSomethingWithTextDraw(Cache[playerid][listitem])
Try that
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)