Raised This Month: $ Target: $400
 0% 

AMXX: Saving data over mapchange?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TJA
Junior Member
Join Date: May 2005
Old 04-16-2009 , 08:16   AMXX: Saving data over mapchange?
Reply With Quote #1

Hello,
it seems, my AMXX variables (of a plugin) get reset at mapchange ...

I would like to save data for a plugin between mapchanges.

Is my configuration broken?

Is that possible to do such at all?
How?



Thanx for any advice!
TJA is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 04-16-2009 , 08:25   Re: AMXX: Saving data over mapchange?
Reply With Quote #2

You can create a plugin that will save in a text file the info that you would like and retrive it after map change ;).
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
TJA
Junior Member
Join Date: May 2005
Old 04-16-2009 , 08:33   Re: AMXX: Saving data over mapchange?
Reply With Quote #3

OK, if that is the only way, i need to go that road

Any advice or example of that - f.e. here in the forum?
TJA is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 04-16-2009 , 08:36   Re: AMXX: Saving data over mapchange?
Reply With Quote #4

Just a moment, I will come with an edit!
Edit: Here is my plugin that works with settings saved in a file. Take a look at the code ;).
http://forums.alliedmods.net/showthread.php?p=651444
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 04-16-2009 at 08:45.
ot_207 is offline
TJA
Junior Member
Join Date: May 2005
Old 04-16-2009 , 08:46   Re: AMXX: Saving data over mapchange?
Reply With Quote #5

Wowuahahauah!

OK, that will take some time to read

Thanx!
TJA is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 04-16-2009 , 09:01   Re: AMXX: Saving data over mapchange?
Reply With Quote #6

No it will not. Here are the lines that are important, I edited them so you can understand them better:

PHP Code:
new const CFG_FILE_NAME[] = "flash_remote_control.cfg"
new CFG_FILE[300
PHP Code:
    // Config file
    
new config[200]
    
// This function gives the location of the config dir from amxmodx
    
get_configsdir(config,199)
    
format(CFG_FILE,299,"%s/%s",config,CFG_FILE_NAME)
    
// Execute the cvars from the cfg
    
exec_cfg() 
PHP Code:
// Cfg save system
public exec_cfg()
{
    if(
file_exists(CFG_FILE))
        
server_cmd("exec %s",CFG_FILE)
}

public 
save_cfg()
{
    new 
file[2000]
    
format(file,1999,"echo [Flashbang Remote Control] Executing config file ...^n")
    
format(file,1999,"mp_friendlyfire 1^n")
    
format(file,1999,"%secho [Flashbang Remote Control] Settings loaded from config file",file)
    
    
delete_file(CFG_FILE)
    
write_file(CFG_FILE,file)

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 04-16-2009 at 09:03.
ot_207 is offline
TJA
Junior Member
Join Date: May 2005
Old 04-16-2009 , 09:54   Re: AMXX: Saving data over mapchange?
Reply With Quote #7

Ah.
I understand.

Thanx a real bunch for the work!


It is required to write out data in a format that allows HL to read it in again - as list of CVARs.

But when i just use CVARs, for me i do not even need to write them to a file - CVARs stay set between mapchanges, as long as they are not changed in a plugin or a cfg-file.

I was searching a way to save my pluginīs variables, which are nto CVARS - just "tk_count[MAXPLAYERS]" for example.

If i understand you correctly, there is no way to do this - beside creating 32 CVARs that allow to save the values between mapchanges: ta_count_1, ..., ta_count_32

Ufff

:-O
TJA is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-16-2009 , 11:54   Re: AMXX: Saving data over mapchange?
Reply With Quote #8

You could save the data in nVault, this is the simplest way IMO.

You can use the players STEAMID\IP as the save\lookup key and save the appropriate variable info as the data.

Example, on map change (client_disconnect) save the below key to vault.

new szKey[256];
formatex( szKey , 255 , "%d %d %d %d" , g_TK[id] , g_HS[id] , g_Kills[id] , g_Deaths[id] )

//The entry to vault will look like this: 44 0 123 3434
nvault_set( g_Vault , szAuthID , szKey )

On client_putinserver, read these values, parse them, and assign to appropriate variables.

new szKey[256];
//44 0 123 3434
nvault_get( g_Vault , szAuthID , szKey , 255 )
__________________

Last edited by Bugsy; 04-16-2009 at 11:59.
Bugsy is offline
TJA
Junior Member
Join Date: May 2005
Old 04-16-2009 , 12:17   Re: AMXX: Saving data over mapchange?
Reply With Quote #9

Ahhh!

Thatīs what i was looking for!

Thanx a real bunch - i start to code
TJA 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 02:19.


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