Raised This Month: $ Target: $400
 0% 

nVault data switching


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 05-22-2020 , 13:58   nVault data switching
Reply With Quote #1

Hello,
I have a problem with nVault loading.
Code:
PHP Code:

public client_authorizedid )
{
    if(
g_bMapBanned)
        return 
PLUGIN_HANDLED

    
if ( !( g_BotOrHLTVid ] = bool:( is_user_botid ) || is_user_hltvid ) ) ) )
    {
        
get_user_authidid g_AuthIDid ] , charsmaxg_AuthID[ ] ) );
        
        
nvault_get_arrayg_Vault g_AuthIDid ] , pdDataid ][ PlayerData:] , sizeofpdData[  ] ) );
    }
    return 
PLUGIN_HANDLED
}

public 
client_disconnectedid )
{
    if(
g_bMapBanned)
        return 
PLUGIN_HANDLED

    
if ( !g_BotOrHLTVid ] )
    {
        
get_user_nameid pdDataid ][ PlayerName ] , charsmaxpdData[][ PlayerName ] ) );
        
        
nvault_set_arrayg_Vault g_AuthIDid ] , pdDataid ][ PlayerData:] , sizeofpdData[  ] ) );
    }
    return 
PLUGIN_HANDLED
}

public 
DeathMsg()
{
    if(
g_bMapBanned || !is_user_connected(id))
        return 
PLUGIN_HANDLED
    
    
new iKiller read_data);
    new 
iVictim read_data);

    
pdData[iVictim][Deaths]++;
    
pdData[iKiller][Kills]++;
    
pdData[iKiller][Headshot] += read_data);
    
    return 
PLUGIN_HANDLED

The problem is when a new player is joining the server, he receive +1 Death.
It worked for 3 maps, then it stored as I said above.

Registered events:
PHP Code:
register_event"DeathMsg" "DeathMsg" "a" "4=knife" "1>0" ); 
.
Anyone, any idea?
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 05-22-2020 at 18:05.
Shadows Adi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-22-2020 , 15:40   Re: nVault array switching
Reply With Quote #2

PHP Code:
public DeathMsg()
{
    if(
g_bMapBanned)
        return 
PLUGIN_HANDLED
    
    
new iKiller read_data);
    new 
iVictim read_data);
    
    
pdData[iVictim][Deaths]++;

    if(!(
iKiller != iVictim && (32 >= iKiller 0))) return PLUGIN_HANDLED;
    
pdData[iKiller][Kills]++;
    
pdData[iKiller][Headshot] += read_data);
    
    return 
PLUGIN_HANDLED

Param id is not presented in the function.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-22-2020 , 18:40   Re: nVault data switching
Reply With Quote #3

There's a possibility that the death(s) remain there from the previous player on that slot. nvault_get_array() only fills the array if the player has data stored. So the below sequence of events would cause a connecting player to have data from the previous player.

1. Player A on slot 1 had 4 deaths. They disconnect.
2. Player B connects on slot 1. They have no data stored in the vault so nvault_get_array() essentially does nothing.
3. Player B has Player A's data leftover in pdData array.

I would clear out the pdData[ SLOT ] on disconnect.
Code:
public client_disconnected( id ) {     if(g_bMapBanned)         return PLUGIN_HANDLED     if ( !g_BotOrHLTV[ id ] )     {         get_user_name( id , pdData[ id ][ PlayerName ] , charsmax( pdData[][ PlayerName ] ) );                 nvault_set_array( g_Vault , g_AuthID[ id ] , pdData[ id ][ PlayerData:0 ] , sizeof( pdData[  ] ) );         arrayset( pdData[ id ] , 0 , sizeof( pdData[] ) );     }     return PLUGIN_HANDLED }
__________________
Bugsy is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 05-22-2020 , 18:51   Re: nVault data switching
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
There's a possibility that the death(s) remain there from the previous player on that slot. nvault_get_array() only fills the array if the player has data stored. So the below sequence of events would cause a connecting player to have data from the previous player.

1. Player A on slot 1 had 4 deaths. They disconnect.
2. Player B connects on slot 1. They have no data stored in the vault so nvault_get_array() essentially does nothing.
3. Player B has Player A's data leftover in pdData array.
I had the same theory.
I will test your way.
You should apply this update at this tutorial:
https://forums.alliedmods.net/showthread.php?t=307518
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 05-22-2020 at 18:52. Reason: Some Grammar.
Shadows Adi is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-22-2020 , 19:42   Re: nVault data switching
Reply With Quote #5

I just tested the nvault module, nvault_get() clears the string variable if no record exists., I think a correction to the nVault Array include would be better for consistency. This should be fine from a backwards compatibility perspective.
__________________

Last edited by Bugsy; 05-22-2020 at 19:43.
Bugsy 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 17:15.


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