Dynamic mSelection
#1

For my freeroam server, I figured i'd add a small map editor. When you do /search wall for example, it should load all objects with the word "wall" in them. Instead, it loads skins. What am I missing?

pawn Код:
CMD:search(playerid, params[])
{
    new search[50], string1[60], string2[900];
    if(sscanf(params, "s[50]", search)) return UsageMessage(pid, "/search [query]");
    for(new i; i<MAX_OBJECTS; i++)
    {
        if(strfind(allObjects[i][arname], search))
        {
            format(string1, sizeof(string1), "%d\n", allObjects[i][arid]);
        }
    }
    format(string2, sizeof(string2), "%s, {%s}", string2, string1);
    ShowModelSelectionMenuEx(playerid, string2, 105, "Search Results", Search);
    return 1;
}
And the array is from some pastebin I found via ******.

pawn Код:
enum ARRAY_FORMAT_ALL_OBJECTS
{
        arid,
        arname[24],
        arids[12],
        arcategory[34],
        arcategory_id
}
//Beach and Sea
new allObjects[][ARRAY_FORMAT_ALL_OBJECTS] = {
        { 902, "Starfish", "[902]", "General Beach and Sea", 0 },
        { 903, "seaweed", "[903]", "General Beach and Sea", 0 },...
For anyone else looking to do something similar, Here is the pastebin link. http://pastebin.com/LM2xuuJT
Reply
#2

??
Reply
#3

:3
Reply
#4

You've entered the wrong data into your ShowModelSelectionMenuEx function.
The string2 needs to be an ITEM array, as it's explained here: https://sampforum.blast.hk/showthread.php?tid=407045

Also, instead of using string1 and string2, you could use strcat to put strings together.
Reply
#5

You are concatenating strings and new lines together, the "ShowModelSelectionMenuEx" works by looping through integers in each index - so try this:

pawn Код:
CMD:search(playerid, params[])
{
    new
        items,
        string[128],
        arrSearch[100]
    ;
    if (isnull(params))
        return UsageMessage(pid, "/search [query]");

    for (new i = 0; i != MAX_OBJECTS && items < sizeof(arrSearch); i ++)
    {
        if (strfind(allObjects[i][arname], params, true) != -1)
        {
            arrSearch[items++] = allObjects[i][arid];
        }
    }
    ShowModelSelectionMenuEx(playerid, arrSearch, items, "Search Results", Search);
    return 1;
}
Reply
#6

That kinda works, but it's only showing a few objects, for example, I search "Wall" and only one thing returns, I know my include has 0.3e objects in it
Reply
#7

Quote:
Originally Posted by Mattakil
Посмотреть сообщение
That kinda works, but it's only showing a few objects, for example, I search "Wall" and only one thing returns, I know my include has 0.3e objects in it
Must be a problem with the enumeration array, you might have to show the "create object" code.
Reply
#8

what create object code :S
Reply
#9

if you mean how the object spawns, I haven't got that far yet :3
Reply
#10

Bump c:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)