Dynamic mSelection -
Mattakil - 09.01.2014
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
Re: Dynamic mSelection -
Mattakil - 09.01.2014

??
Re: Dynamic mSelection -
Mattakil - 11.01.2014
:3
Re: Dynamic mSelection -
BlackBank - 11.01.2014
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.
Re: Dynamic mSelection - Emmet_ - 11.01.2014
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;
}
Re: Dynamic mSelection -
Mattakil - 11.01.2014
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
Re: Dynamic mSelection - Emmet_ - 11.01.2014
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.
Re: Dynamic mSelection -
Mattakil - 11.01.2014
what create object code :S
Re: Dynamic mSelection -
Mattakil - 11.01.2014
if you mean how the object spawns, I haven't got that far yet :3
Re: Dynamic mSelection -
Mattakil - 11.01.2014
Bump c: