Raised This Month: $51 Target: $400
 12% 

nvault double dimonsional array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-17-2021 , 13:21   nvault double dimonsional array
Reply With Quote #1

how should i save an double-dimensional array ?

like i have

skinCT[33][33]

PHP Code:
public cmdSave(id){
    
formatexvaultdatacharsmax(vaultdata), "%d#%d#%d#%d#%d#%d#%d#%d"checkT[0][id], checkT[1][id], checkT[2][id], checkT[3][id],
 
checkCT[0][id], checkCT[1][id], checkCT[2][id], checkCT[3][id], hudon[id] )
    
nvault_set(nVaultg_szAuthIDid ], vaultdata)
}

public 
cmdGet(id){
    new 
checkps[10], checkt[10], checkct[10], hud[10]
    
nvault_get(nVaultg_szAuthIDid ], vaultdatacharsmax(vaultdata))
    
replace_all(vaultdatacharsmax(vaultdata), "#"" ")
    
parse(vaultdatacheckpscharsmax(checkps), checktcharsmax(checkt), checkctcharsmax(checkct), hudcharsmax(hud))
    
checkPS[id] = str_to_num(checkps)
    
checkT[id] = str_to_num(checkt)
    
checkCT[id] = str_to_num(checkct)
    
hudon[id] = str_to_num(hud)    

this is what i tried but idk how to get it
lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-17-2021 , 13:25   Re: nvault double dimonsional array
Reply With Quote #2

It will be alot easier to explain what's that thing you're trying to achieve!
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-17-2021 at 13:26.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-17-2021 , 13:35   Re: nvault double dimonsional array
Reply With Quote #3

i m trying to create a shop menu where you can buy csgo agents. i want to do 2 things:

https://imgur.com/a/92F9j9Z

in this menu, when i already have that skin, show me ON/OFF
when i don't have that skin show me [PRICE: 2000$] or something like this.
also, i want to save that things.

so i was trying this
skinCT[0][id] (first skin from counter-terrorists list) = 0 means you didn t bought it
skinCT[0][id] = 1 you have bought that skin
skinCT[0][id] = 2 you selected that skin

when i select another skin (skinCT[1][id] -> second one) the new value of skinCT[0][id] will become 1

I don't know if it's correct, I thought while writing and I don't even know how to use double-dimensional array
lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-17-2021 , 14:36   Re: nvault double dimonsional array
Reply With Quote #4

why don't you work with bits it will be much easier.

here's an example

Code:
============>
menu format will be like.
============>
SKINS menu

1. Default Skin ( Selected )
2. GSG9 Killer ( Bought )
3. FBI Agent Killer ( Price 3000$ )
4. SAS Killer ( Bought )

===========>

enum (*=2)
{
     GSG9_KILLER = 1, // (1<<0)
     FBI_KILLER, // (1<<1)
     SAS_KILLER // (1<<2)
}


// meaning that user will have access to GSG9_KILLER skin and the SAS_KILLEr
g_PlayerSkins[ id ] = GSG9_KILLER|SAS_KILLER;

Save(id)
{
     new szData[32]; formatex(szData, charsmax(szData), "%d %d", g_iPlayerSelectedSkin[id], g_PlayerSkins[id]);
     nvault_set(nVault, g_szAuthID[ id ], szData)
}

Retrieve(id)
{
     new szData[32], szSelection[4];
     nvault_get(nVault, g_szAuthID[ id ], szData, charsmax(szData))
     strbreak(szData, szSelection, charsmax(szSelection), szData, charsmax(szData));
     g_iPlayerSelectedSkin[id] = str_to_num(szSelection);
     g_PlayerSkins[id] = str_to_num(szData);
}

Edit: Altho you will be limited for 32 skins which i think it will be more than enough
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-17-2021 at 15:07.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-17-2021 , 14:59   Re: nvault double dimonsional array
Reply With Quote #5

can i do this

PHP Code:
new psprice[][] = {
    
"1500",
    
"3000",
    
"4500",
    
"6000"
}

public 
MENU(id)
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r2.\w ISIS Killer - [%s$]"psprice[0]) 
lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-17-2021 , 15:04   Re: nvault double dimonsional array
Reply With Quote #6

how's this related to your first issue i don't get it?
__________________
@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
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-18-2021 , 02:38   Re: nvault double dimonsional array
Reply With Quote #7

i made this topic for dd array, i can t do what u told me i have to use dd array.
lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-18-2021 , 02:40   Re: nvault double dimonsional array
Reply With Quote #8

Quote:
Originally Posted by lexzor View Post
i made this topic for dd array, i can t do what u told me i have to use dd array.
And why is that ?

I've simply shown you how to deal with bits way .

The proper solution would be using the bits since it's more easy and less complicated.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-18-2021 at 02:52.
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 , 08:02   Re: nvault double dimonsional array
Reply With Quote #9

I misunderstood the problem.
It looks like the first column of the skinCT variable represent the index of the models and second one the index of the players, and you want to save the values of the first column by player authid. If that's the case, the code you provided already does the job, otherwise you need to be more specific.

As for the menu, something like this

Code:
#include <amxmodx>

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

new const Models[][ModelData] = {
	{"Name to show in menu here", "folder name inside cstrike/models/player", 2000},
	{"Another model", "folder name inside cstrike/models/player", 3000},
	{"Another model", "folder name inside cstrike/models/player", 4000}
	// 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)

		// Precache model T.mdl
		formatex(buf, charsmax(buf), "models/player/%s/%sT.mdl", Models[i][MODEL], Models[i][MODEL])
		if (file_exists(buf))
			precache_generic(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)

	// do something with model_index

	return PLUGIN_HANDLED
}
__________________









Last edited by CrazY.; 01-18-2021 at 08:23.
CrazY. is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-18-2021 , 10:42   Re: nvault double dimonsional array
Reply With Quote #10

i will try later, thanks!
lexzor is offline
Reply



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 01:25.


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