AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   STEAMID saving to name saving (https://forums.alliedmods.net/showthread.php?t=162808)

Change377 07-23-2011 07:47

STEAMID saving to name saving
 
Hey,
I edited plugin (deathrun shop). Points have been saving by authid, and i wanted saving by name. Original functions (save and load points):

PHP Code:

stock save_client_pointsindex )
{
    
/* --| Open the vault file */
    
gVault nvault_open"DeathrunShop_SavedPoints" );
    
    
/* --| If vault return -1, lets stop this shit */
    
if( gVault == INVALID_HANDLE )
    {
        
set_fail_state"[DrShop] nValut ERROR: =-> Invalid-Handle" );
    }
    
    
/* --| Get the player steamid */
    
get_user_authidindexgSteamIDcharsmaxgSteamID ) );
    
    
/* --| Setting stuff on vault file, and close the file */
    
formatexvKeycharsmaxvKey ), "%sPOINTS"gSteamID );
    
formatexvDatacharsmaxvData ), "%d"gKillerPointsindex ] );
    
nvault_setgVaultvKeyvData );
    
nvault_closegVault );
}

/* --| Loading client points */
stock load_client_pointsindex )
{
    
/* --| Open the vault file */
    
gVault nvault_open"DeathrunShop_SavedPoints" );
    
    
/* --| If vault return -1, lets stop this shit */
    
if( gVault == INVALID_HANDLE )
    {
        
set_fail_state"[DrShop] nValut ERROR: =-> Invalid-Handle" );
    }
    
    
/* --| Get the player steamid */
    
get_user_authidindexgSteamIDcharsmaxgSteamID ) );
    
    
/* --| Get the player points, then, close the nvault vile */
    
formatexvKeycharsmaxvKey ), "%sPOINTS"gSteamID );
    
gKillerPointsindex ] = nvault_getgVaultvKey );
    
nvault_closegVault );


and edited functions:
PHP Code:

stock save_client_pointsindex )
{
    
/* --| Open the vault file */
    
gVault nvault_open"DeathrunShop_SavedPoints" );
    
    
/* --| If vault return -1, lets stop this shit */
    
if( gVault == INVALID_HANDLE )
    {
        
set_fail_state"[DrShop] nValut ERROR: =-> Invalid-Handle" );
    }
    
    
/* --| Get the player steamid */
    
get_user_name(indexnamepointscharsmax(namepoints));
    
    
/* --| Setting stuff on vault file, and close the file */
    
formatexvKeycharsmaxvKey ), "%sPOINTS"namepoints);
    
formatexvDatacharsmaxvData ), "%d"gKillerPointsindex ] );
    
nvault_setgVaultvKeyvData );
    
nvault_closegVault );
}

/* --| Loading client points */
stock load_client_pointsindex )
{
    
/* --| Open the vault file */
    
gVault nvault_open"DeathrunShop_SavedPoints" );
    
    
/* --| If vault return -1, lets stop this shit */
    
if( gVault == INVALID_HANDLE )
    {
        
set_fail_state"[DrShop] nValut ERROR: =-> Invalid-Handle" );
    }
    
    
    
/* --| Get the player steamid */
    
get_user_name(indexnamepointscharsmax(namepoints));
    
    
/* --| Get the player points, then, close the nvault vile */
    
formatexvKeycharsmaxvKey ), "%sPOINTS"namepoints );
    
gKillerPointsindex ] = nvault_getgVaultvKey );
    
nvault_closegVault );


No errors/warnings, but saving is still by authid (after server restart, changing map etc, I can disconnect, change my name and reconnect, and my points have still the same value. Whats wrong?
Thanks

Diegorkable 07-23-2011 09:33

Re: STEAMID saving to name saving
 
That code looks too complicated to me(not cuz its messy, cuz i suck at knowing amx scripting functions), but i think saving by name will be a bit problematic, since ppl change their names. SteamID would be the best, the only place it wouldnt be good for is NonSteam servers.

Change377 07-23-2011 09:46

Re: STEAMID saving to name saving
 
Yeah, but I just prefer saving by nick, and please about correcting my code, not to recommend better option to choose :) I know that ppl change their names, and it's ok, no problem. So what can I change to make this code working?

fysiks 07-23-2011 16:07

Re: STEAMID saving to name saving
 
Just use SteamID.

P.S. You probably didn't compile it successfully or didn't replace the original .amxx.

Honors 07-23-2011 17:20

Re: STEAMID saving to name saving
 
Why using saving by name instead of SteamID ?!

No-Steam user ?!

Change377 07-23-2011 19:53

Re: STEAMID saving to name saving
 
Unfortunately I compiled and replaced original .amxx - I just compiled - new plugin has different name, so I couldn't to not replaced the original .amxx. Is this code correct? Should it work? Without deleting vault file? I think it should create new lines in file and work correctly, but it doesn't.. :(

Why I want by name? Because I have some other plugins which save things by name and I'd like this to be saving by name too.

Diegorkable 07-23-2011 19:56

Re: STEAMID saving to name saving
 
Well I bet its because something that involves NonSteam but that's really ok, still you could use steamids and then translate them to names for a putout or anything else if needed. Sorry if I make you mad for posting with not helping but these functions are way ahead of me and i don't know them, good luck getting it set.


All times are GMT -4. The time now is 01:09.

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