SA-MP Forums Archive
[Include] All models array - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] All models array (/showthread.php?tid=589352)



All models array - Gammix - 18.09.2015

Models Array - 0.3.7+ Only
This is not completly mine, most of the array code was designed and written by Slice, but i have been adding vehicles, pickups, skins name so far and i think it would be useful for some of you.
You will get any of these types, defined in the include:
pawn Код:
#define MODEL_TYPE_NONE (0)
#define MODEL_TYPE_OBJECT (1)
#define MODEL_TYPE_VEHICLE (2)
#define MODEL_TYPE_SKIN (3)
#define MODEL_TYPE_WEAPON (4)
The most useful stock of this include, used for searching a match to the keyword in search of models.
pawn Код:
SearchModel(result[], const search[], type = -1, size = sizeof(result));
Here is an example:
pawn Код:
new
    result[10]
;
print("Match foud for the keyword 'm4'");
for (new i = 0, j = SearchModel(result, "m4"); i < j; i++) {
    printf("%i. %s", i, result[i]);
}
Where to use?
Mostly this is for map editors, in case anyone want all models included in one array, this will be probably handy.

Also, maybe you want to use this include for making a model searcher.

Download
Here is the GITHUB repo:

https://github.com/Gammix/Models-Array


Re: All models array - Pottus - 18.09.2015

The maximum number of models supported is 20,000 why not just use that instead of looping over an indeterminate array? Then also change up your enum to support model types.

Код:
#define MODEL_TYPE_NONE 0
#define MODEL_TYPE_PED 1
#define MODEL_TYPE_VEHICLE 2
#define MODEL_TYPE_MODEL 3

enum e_MODEL_NAMES {
	e_modelType,
	e_modelName[24 char]
};



Re: All models array - Gammix - 19.09.2015

Thanks for the suggestion, Pottus.

Update:


Re: All models array - Pottus - 19.09.2015

I think you misunderstood what I was trying to suggest the array indexes should align to the model id and model type be defined as well.

Код:
new const g_ModelNames[MAX_MODELS][e_MODEL_NAMES] = {
Fill in any unused with {0, "Unused" },


Re: All models array - Gammix - 19.09.2015

Quote:
Originally Posted by Pottus
Посмотреть сообщение
I think you misunderstood what I was trying to suggest the array indexes should align to the model id and model type be defined as well.

Код:
new const g_ModelNames[MAX_MODELS][e_MODEL_NAMES] = {
Fill in any unused with {0, "Unused" },
Actually i appended the array using SAMP file functions. Something like this:
pawn Код:
#include <a_samp>

new VehicleNames[212][] = {
{"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},
{"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},
{"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},{"Washington"},
{"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},
{"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},
{"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
{"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},
{"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},
{"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
{"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},
{"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},
{"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},{"FBI Rancher"},{"Virgo"},{"Greenwood"},
{"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},
{"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},
{"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},
{"Tanker"}, {"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},
{"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},
{"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},
{"Blade"},{"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},
{"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},
{"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},
{"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},
{"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},
{"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},
{"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
{"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},
{"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},{"Alpha"},{"Phoenix"},{"Glendale"},
{"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},
{"Utility Trailer"}
};

main() {
    new File:h = fopen("varray.ini", io_append);
    new str[128];
    new line;
    for (new i = 400; i <= 611; i++) {
        if (line >= 6) {
            format(str, sizeof(str), "{%i, !\"%s\"},\n", i, VehicleNames[i - 400]);
           
            line = 0;
        }
        else {
            format(str, sizeof(str), "{%i, !\"%s\"}, ", i, VehicleNames[i - 400]);
        }
        fwrite(h, str);
       
        line += 1;
    }
}
And it would be really a hard work for me to re edit. Though it will be the fastest method to search using modelids.

But if you look practically, we search modelids using characters, so it won't be useful to locate matches.


Re: All models array - DoDler - 19.09.2015

Exactly what I was looking for, thank you so much for this.

Код HTML:
stock IsValidObjectModel(modelid)
{
    if (modelid < 611) return 0;
    for (new i = 0; i < MAX_MODELS; i++)
	{
		  if(modelid == g_ModelNames[i][e_modelId])
		  {
			  return 1;
		  }
	}
	return 0;
}



Re: All models array - Gammix - 24.09.2015

Quote:
Originally Posted by DoDler
Посмотреть сообщение
Код HTML:
stock IsValidObjectModel(modelid)
{
    if (modelid < 611) return 0;
    for (new i = 0; i < MAX_MODELS; i++)
	{
		  if(modelid == g_ModelNames[i][e_modelId])
		  {
			  return 1;
		  }
	}
	return 0;
}
Actually weapon models (331,..333,..358,...) are also objects.
https://sampwiki.blast.hk/wiki/Weapons