Raised This Month: $ Target: $400
 0% 

buy meny


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 03-13-2013 , 11:20   buy meny
Reply With Quote #1

How can i change i menu if someone buy something?

Exemple if my menu look like this
Knife Skin [NOT BOUGHT]

And when someone buy it. I want it to look like this
Knife Skin [BOUGHT]


How can i do that?


and im using nvault... so i want to save.
so if someone buy a knife and it changes map i want it to stay as [BOUGHT]
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.

Last edited by ironskillz1; 03-13-2013 at 11:33.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Torge
Veteran Member
Join Date: Oct 2011
Old 03-13-2013 , 11:59   Re: buy meny
Reply With Quote #2

With a boolean or booleans but depends how many items you add for each boolean. ;D

Example:
PHP Code:
// Bought?
if (g_bBoughtAK47[id])
   
menu_additem(hMenu"AK47 [BOUGHT]""1");
// Not bought?
else
   
menu_additem(hMenu"AK47 [NOT BOUGHT]""1"); 

Last edited by Torge; 03-13-2013 at 12:01.
Torge is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 03-13-2013 , 13:49   Re: buy meny
Reply With Quote #3

Quote:
Originally Posted by Torge View Post
With a boolean or booleans but depends how many items you add for each boolean. ;D

Example:
PHP Code:
// Bought?
if (g_bBoughtAK47[id])
   
menu_additem(hMenu"AK47 [BOUGHT]""1");
// Not bought?
else
   
menu_additem(hMenu"AK47 [NOT BOUGHT]""1"); 


yeah i got like 5 items but im going to add more
but how can i save booleans on nvault?
if not how should i do then?
Code:
stock save_item( index )
{
 gVault = nvault_open( "Nvault" )
 
 if( gVault == INVALID_HANDLE )
 {
  set_fail_state( "[Nvault] nValut ERROR: =-> Invalid-Handle" )
 }
 
 get_user_name( index, gSteamID, charsmax( gSteamID ) )
 
 formatex( vKey, charsmax( vKey ), "%sItems", gSteamID )
 formatex( vData, charsmax( vData ), "%d", gItems[ index ])
 nvault_set( gVault, vKey, vData )
 nvault_close( gVault )
}
stock load_item( index )
{
 gVault = nvault_open( "Nvault" )
 
 if( gVault == INVALID_HANDLE )
 {
  set_fail_state( "[Nvault] nValut ERROR: =-> Invalid-Handle" )
 }
 
 get_user_name(  index, gSteamID, charsmax( gSteamID ) )
 
 formatex( vKey, charsmax( vKey ), "%sItems", gSteamID )
 gItems[ index ] = nvault_get( gVault, vKey )
 nvault_close( gVault )
}
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.

Last edited by ironskillz1; 03-13-2013 at 13:49.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Torge
Veteran Member
Join Date: Oct 2011
Old 03-13-2013 , 13:59   Re: buy meny
Reply With Quote #4

Perhaps like this?

http://forums.alliedmods.net/showthread.php?t=191406
Torge is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 03-13-2013 , 14:46   Re: buy meny
Reply With Quote #5

oh sorry i mean like this

Becuse i save my Knife models like this
Code:
SaveKnife(id)
{
new authid[32]
get_user_authid(id, authid, 31)
new vaultkey[64]
new vaultdata[64]
format(vaultkey, 64, "KNIFE2_%s", authid)
format(vaultdata, 64, "%d", knife_model[id])
set_vaultdata(vaultkey, vaultdata)
}
LoadKnife(id) 
{ 
new authid[32]
get_user_authid(id,authid,31)
new vaultkey[64], vaultdata[64]
format(vaultkey, 64, "KNIFE2_%s", authid)
get_vaultdata(vaultkey, vaultdata, 64)
knife_model[id] = str_to_num(vaultdata)
}

and they Saves in vault.ini
like this (this is knife model 1)
Code:
; Don't modify!
server_language en
KNIFE2_STEAM_0:0:38415370 1
but when i buy another knife model it looks like this
Code:
; Don't modify!
server_language en
KNIFE2_STEAM_0:0:38415370 2
i want it to show that i own 2 knife models like this
Code:
; Don't modify!
server_language en
KNIFE2_STEAM_0:0:38415370 1
KNIFE2_STEAM_0:0:38415370 2
Can i some how do that?
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 03-14-2013 , 07:25   Re: buy meny
Reply With Quote #6

It's because your saving over the same key. You should save all of your skin indexes under the one vault key, it would be more efficient. Also, your going from vault to nvault over different posts ... pick one.

Last edited by hornet; 03-14-2013 at 07:26.
hornet is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 03-15-2013 , 06:03   Re: buy meny
Reply With Quote #7

Quote:
Originally Posted by Torge View Post
With a boolean or booleans but depends how many items you add for each boolean. ;D

Example:
PHP Code:
// Bought?
if (g_bBoughtAK47[id])
   
menu_additem(hMenu"AK47 [BOUGHT]""1");
// Not bought?
else
   
menu_additem(hMenu"AK47 [NOT BOUGHT]""1"); 
better method for menu..

example:
PHP Code:

new Temp[101];

formatex(Temp100"AK47 [%s]"g_bBoughtAK47[id] ? "BOUGHT" "NOT BOUGHT")
menu_additem(hMenuTemp"1"); 
Blizzard_87 is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 03-15-2013 , 08:45   Re: buy meny
Reply With Quote #8

Quote:
Originally Posted by Blizzard_87 View Post
better method for menu..

example:
PHP Code:

new Temp[101];

formatex(Temp100"AK47 [%s]"g_bBoughtAK47[id] ? "BOUGHT" "NOT BOUGHT")
menu_additem(hMenuTemp"1"); 
That's right, but it really makes no much difference.
Torge is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 03-15-2013 , 10:40   Re: buy meny
Reply With Quote #9

Quote:
Originally Posted by hornet View Post
You should save all of your skin indexes under the one vault key.
How can i do that ?
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 03-16-2013 , 05:16   Re: buy meny
Reply With Quote #10

Quote:
Originally Posted by ironskillz1 View Post
How can i do that ?
Well you need to start by scrapping your AK47 array, and make one that can be used for all skins:
Code:
#define MAX_SKINS        5 new bool:g_bBoughtSkin[ 33 ][ MAX_SKINS ];

Your new data functions look like this:

Code:
public SaveData( id ) {     new szData[ 64 ], szKey[ 32 ];     get_user_authid( id, szKey, charsmax( szKey ) );     format( szKey, charsmax( szKey ), "%s-SKINS", szKey );         for( new i ; i < MAX_SKINS ; i ++ )         if( g_bBoughtSkin[ id ][ i ] )             format( szData, charsmax( szData ), "%s%i-", szData, i );         set_vaultdata( szKey, szData ); } public LoadData( id ) {     new szData[ 64 ], szKey[ 32 ], szPiece[ 32 ];         get_user_authid( id, szKey, charsmax( szKey ) );     format( szKey, charsmax( szKey ), "%s-SKINS", szKey );         get_vaultdata( szKey, szData, charsmax( szData ) );         while( contain( szData, "-" ) >= 0 )     {               strtok( szData, szPiece, charsmax( szPiece ), szData, charsmax( szData ), '-' );                       g_bBoughtSkin[ id ][ str_to_num( szPiece ) ] = true;     } }

And now you need to go and rebuild your menu create code accordingly to the new skins array.
hornet 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 21:46.


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