AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   AMXX: Saving data over mapchange? (https://forums.alliedmods.net/showthread.php?t=90288)

TJA 04-16-2009 08:16

AMXX: Saving data over mapchange?
 
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!

ot_207 04-16-2009 08:25

Re: AMXX: Saving data over mapchange?
 
You can create a plugin that will save in a text file the info that you would like and retrive it after map change ;).

TJA 04-16-2009 08:33

Re: AMXX: Saving data over mapchange?
 
OK, if that is the only way, i need to go that road :D

Any advice or example of that - f.e. here in the forum?
:)

ot_207 04-16-2009 08:36

Re: AMXX: Saving data over mapchange?
 
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

TJA 04-16-2009 08:46

Re: AMXX: Saving data over mapchange?
 
Wowuahahauah!

OK, that will take some time to read :D

Thanx!

ot_207 04-16-2009 09:01

Re: AMXX: Saving data over mapchange?
 
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)



TJA 04-16-2009 09:54

Re: AMXX: Saving data over mapchange?
 
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

Bugsy 04-16-2009 11:54

Re: AMXX: Saving data over mapchange?
 
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 )

TJA 04-16-2009 12:17

Re: AMXX: Saving data over mapchange?
 
Ahhh!

Thatīs what i was looking for!

Thanx a real bunch - i start to code :)


All times are GMT -4. The time now is 02:19.

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