Raised This Month: $ Target: $400
 0% 

save on/off


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
anakonda001
Member
Join Date: Jul 2020
Old 08-25-2020 , 14:55   save on/off
Reply With Quote #1

Hi, how do I save the on/off values in the menu after changing the map? when the map changes, the on/off menu changes

in the sounds plugin I use this
new g_hVault = INVALID_HANDLE;
new bool:g_bDisabled[MAX_PLAYERS + 1];

on/off sounds are saved but the labels themselves are not in the menu, you need to save them in the menu too after changing the map

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

#pragma tabsize 0

#define PLUGIN  "Menu"
#define VERSION "2.0"
#define AUTHOR  "lol ;D"

new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_0

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_menu("Menu 1", keys, "func_menu") 
	register_clcmd("menu", "server_menu" )

}

public client_authorized(id)
{
    client_cmd(id, "bind ^"F3^" ^"menu^"")
}

public server_menu(id)
{
     new name[32]
     get_user_name(id, name, 31)
     static menu[650], iLen
     iLen = 0
     iLen = formatex(menu[iLen], charsmax(menu) - iLen, "\yMenu players (1\2)^n\yHello, \w%s^n^n", name)

     if(Music[id])
     {
          iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r1. \wsound grenade: \rOff^n")
          keys |= MENU_KEY_1
     }
     else
     {
          iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r1. \wsound grenade: \yOn^n")
          keys |= MENU_KEY_1
     }

     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r2. \wfurther^n")
     keys |= MENU_KEY_2

     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r0. \wexit^n^n")
     keys |= MENU_KEY_0

     show_menu(id, keys, menu, -1, "Menu 1")
     return PLUGIN_HANDLED
}

public func_menu(id, key)
{
     switch(key)
     {
          case 0:
          {
               if(!g_Disabled[id])
               {
                    client_cmd(id, "say /gsound")
                    g_Disabled[id] = true
               }
               else
               {
                    client_cmd(id, "say /gsound")
                    g_Disabled[id] = false
               }
               server_menu(id)
          }
     }
     return PLUGIN_HANDLED
}

stock GetAliveCt()
{
	new CountCt, i
	for(i = 1; i <= get_maxplayers(); i++)
		if(is_user_alive(i) && is_user_connected(i) && get_user_team(i) == 2)
			CountCt++
	return CountCt
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
anakonda001 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-25-2020 , 22:08   Re: save on/off
Reply With Quote #2

If you want data to be preserved between maps, you need to save the data and re-load it on the next map. Since this is per-user data, you need to save their SteamID along with the data of interest. Then, in plugin_init(), you can load the file into the plugin (using a Trie would be the most efficient but an array would be more straight forward). Then, in client_authorized(), you would look in that data to find the SteamID and then set that value to your array for that player.

There are several ways to save the data. A plain text file and nVault are two ways to do this.

Also note that forcing a bind or other setting on a player is called "slowhacking" and is not supported here. Please remove it from your code.
__________________

Last edited by fysiks; 08-25-2020 at 22:13.
fysiks is offline
anakonda001
Member
Join Date: Jul 2020
Old 08-26-2020 , 03:17   Re: save on/off
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
If you want data to be preserved between maps, you need to save the data and re-load it on the next map. Since this is per-user data, you need to save their SteamID along with the data of interest. Then, in plugin_init(), you can load the file into the plugin (using a Trie would be the most efficient but an array would be more straight forward). Then, in client_authorized(), you would look in that data to find the SteamID and then set that value to your array for that player.

There are several ways to save the data. A plain text file and nVault are two ways to do this.

Also note that forcing a bind or other setting on a player is called "slowhacking" and is not supported here. Please remove it from your code.
I have a sound plugin connected to nVault, can you do what I want here?
anakonda001 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-26-2020 , 05:48   Re: save on/off
Reply With Quote #4

Quote:
Originally Posted by anakonda001 View Post
I have a sound plugin connected to nVault, can you do what I want here?
This is the scripting HELP section, not "do it for me section", so no, he can not do what you want. But he(or someone else) can HELP you do it yourself.
Start by trying to code it yourself, and if you get stuck or have specific questions, ask here(you should also show what you tried in terms of code).
__________________
HamletEagle is offline
anakonda001
Member
Join Date: Jul 2020
Old 08-26-2020 , 08:35   Re: save on/off
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
This is the scripting HELP section, not "do it for me section", so no, he can not do what you want. But he(or someone else) can HELP you do it yourself.
Start by trying to code it yourself, and if you get stuck or have specific questions, ask here(you should also show what you tried in terms of code).
I don’t understand anything in scripting, if I could, I would try it myself, but I don’t understand how to do it
anakonda001 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 13:48.


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