Loop +rep
#1

Well i have made a system,and i was making a last command for it,when i write that command it shows me all of the objects that have id 980,i knew how to detect it and it worked but i want to make a dialog to show me the id of all of the objects that have id 980,i looped them all as:
pawn Код:
for(new i = 0; i < MAX_OBJECTS; a++) //looping the objects
            {
                if(Object[a][ObjectModel] == 980) // for detecting...and this one works
                {
                    new string[1536];
                    format(string, sizeof(string), "%s\n%d",finalstring, a);
                    ShowPlayerDialog(playerid,DIALOG_OBJECTS,DIALOG_STYLE_LIST,"objects", string,"Choose","Cancel");
                }
            }
but it doesnt show me the dialog,because the format is wrong,What should i put to make this format work?what to edit in this:
pawn Код:
format(string, sizeof(string), "%s\n%d",finalstring, a);
because it's the problem
Reply
#2

pawn Код:
new string[1536];
for(new i = 0; i < MAX_OBJECTS; a++) //looping the objects
    if(Object[a][ObjectModel] == 980) // for detecting...and this one works
        format(string, sizeof(string), "%s%d\n",finalstring, a);

if(string[0] != EOS)
    ShowPlayerDialog(playerid,DIALOG_OBJECTS,DIALOG_STYLE_LIST,"objects", string,"Choose","Cancel");
else{
    // not found
}
Reply
#3

pawn Код:
new string[500],num[10];
for(new i = 0; i < MAX_OBJECTS; a++) //looping the objects
            {
                if(Object[a][ObjectModel] == 980) // for detecting...and this one works
                {
                   
                    format(num,10,"%i", a);
                    strcat(string, num);
                     strcat(string, "\n");
                   
                }
            }
ShowPlayerDialog(playerid,DIALOG_OBJECTS,DIALOG_STYLE_LIST,"objects", string,"Choose","Cancel");
dialog showing needs to be out of loop no inside + some changes see them
Reply
#4

thanks,but one more question,How can i know which listitem in the OnPlayerDialogResponse the player clicked on?like if i have 5 objects with model 980,like object id 1 and 5 and 9 and 11 and 14,how to know if player clicked on 11 for example?
Reply
#5

new ID = strval(inputtext);
Reply
#6

it's a list dialog,i need to detect if he clicked on object id 11,read my previous reply
Reply
#7

if(ID == 11) // clicked 11 xd
else // other number
Reply
#8

not like that,in dialog list it uses listitem
Reply
#9

like this see the changs in code
pawn Код:
new oblist[MAX_OBJECTS];//on top


new string[500],num[10];
new var = 0;//added this
for(new i = 0; i < MAX_OBJECTS; a++) //looping the objects
            {
                if(Object[a][ObjectModel] == 980) // for detecting...and this one works
                {
                    oblist[var]=a;//added this
                    format(num,10,"%i", a);
                    strcat(string, num);
                     strcat(string, "\n");
                      var++;//add this
                   
                }
            }
ShowPlayerDialog(playerid,DIALOG_OBJECTS,DIALOG_STYLE_LIST,"objects", string,"Choose","Cancel");


//on diloag resonse
oblist[listitem]//this contains object id  !! :D
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)