Raised This Month: $32 Target: $400
 8% 

nvault double dimonsional array


Post New Thread Reply   
 
Thread Tools Display Modes
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 01-18-2021 , 12:03   Re: nvault double dimonsional array
Reply With Quote #11

Added to @CrazY code, after cost you can add Team and check for specified team, not precache multiple times, i think this is better

something like this

Code:
#include <amxmodx>
#include <fun>

#define TEAM_T	1
#define TEAM_CT	2

enum _:ModelData
{
	NAME[32],
	MODEL[32],
	COST,
	TEAM
}

new const Models[][ModelData] = {
	{"Name to show in menu here", "folder name inside cstrike/models/player", 2000, TEAM_T},
	{"Another model", "folder name inside cstrike/models/player", 3000, TEAM_CT},
	{"Another model", "folder name inside cstrike/models/player", 4000, TEAM_CT|TEAM_T}
	// add more models
}

public plugin_init()
{
	register_plugin("Plugin", "Version", "Author")
	register_clcmd("say /models", "CommandSayModels")
}

public plugin_precache()
{
	for (new i = 0, buf[128]; i < sizeof Models; i++)
	{
		formatex(buf, charsmax(buf), "models/player/%s/%s.mdl", Models[i][MODEL], Models[i][MODEL])
		precache_model(buf)
	}
}

public CommandSayModels(index)
{
	ShowModelsMenu(index)
	return PLUGIN_HANDLED
}

ShowModelsMenu(index, page=0)
{
	new menu = menu_create("Models Menu", "HandleModelsMenu")

	for (new i = 0, buf[56], len, info[3]; i < sizeof Models; i++)
	{
		len = copy(buf, charsmax(buf), Models[i][NAME])

		// if the player doesn't have that skin, add the cost
		if (has_skin == false)
			len += formatex(buf[len], charsmax(buf) - len, " \y%d$", Models[i][COST])

		num_to_str(i, info, charsmax(info))
		menu_additem(menu, buf, info)
	}

	menu_display(index, menu, clamp(page, 0, menu_pages(menu) - 1))
}

public HandleModelsMenu(index, menu, item)
{
	if (item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}

	new info[3]
	menu_item_getinfo(menu, item, _, info, charsmax(info))
	menu_destroy(menu)

	new model_index = str_to_num(info)

	if(Models[item][TEAM] != get_user_team(index))	return 1;

	// do something with model_index

	return PLUGIN_HANDLED
}
__________________

Last edited by LondoN; 01-18-2021 at 12:07.
LondoN is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-18-2021 , 12:19   Re: nvault double dimonsional array
Reply With Quote #12

how's this related to the problem ?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-18-2021 , 13:06   Re: nvault double dimonsional array
Reply With Quote #13

I think you misunderstood the meaning of T.mdl
It's not a "team" model. "T.mdl" is a packed texture used by the main .mdl.
In most models, the texture is compressed along with the main .mdl so there's no T.mdl to precache, but in the case the file exists, you must precache it. That part of the code you deleted does check if the file_exists before precaching it, not sure why you deleted it.

Anyway, this is completely off topic and irrelevant to the main issue, which honestly I don't understand until now.
__________________









Last edited by CrazY.; 01-18-2021 at 13:08.
CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-20-2021 , 22:00   Re: nvault double dimonsional array
Reply With Quote #14

Use nVault Array with an enum-size array
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode