This site is a testing version, but all data is shared with the live forum.


Raised This Month: $12 Target: $400
 3% 

SAVE MONEY + SCORE + weapons and items purchased before disconnect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kounterboy
Junior Member
Join Date: May 2022
Location: LIMA-PERU
Old 07-24-2023 , 16:30   SAVE MONEY + SCORE + weapons and items purchased before disconnect
Reply With Quote #1

Good day , I would like you to help me. I have this plugin which allows you to save the score and the money in case the player disconnects from the game and when he re-enters, he can obtain the same amount of money when he left the server and the score too.
I have no problem with that but I have realized that for example if I have bought a rifle and I keep $3800, for example, having my weapon with vest and ammunition when the player hangs up or disconnects, he re-enters as I mentioned before with $3800 and his score, but loses the rifle, vest and ammunition.

Is there a way to edit the .sma in which you reconnect with everything you had before disconnecting, your rifle or weapon that you have had, if you have bought a vest or ammunition ????
. Sorry for the translation, thank you very much.

example
PHP Code:
https://youtu.be/9-xvlGGkVIw 

PHP Code:
#include <amxmodx>
#include <reapi>

enum _:DATA Float:KILLSDEATHMONEY };

new 
g_szTempData[MAX_CLIENTS 1][DATA];
new 
g_szAuthID[MAX_CLIENTS 1][32];

new 
Trie:g_tPlayerScore;

new 
HookChain:hRestartRoundPre;

public 
plugin_end() {
    
TrieDestroy(g_tPlayerScore);
}

public 
plugin_init() {
    
register_plugin("Save score & money""1.3.7""Minni Mouse");

    
RegisterHookChain(RG_RoundEnd"refwd_RoundEnd_Post", .post true);

    
DisableHookChain((hRestartRoundPre 
        
RegisterHookChain(RG_CSGameRules_RestartRound"refwd_RestartRound_Pre", .post false))
    );

    
g_tPlayerScore TrieCreate();
}

public 
client_disconnected(pPlayer) {
    if(
is_user_hltv(pPlayer) || is_user_bot(pPlayer)) {
        return;
    }

    if(
g_szAuthID[pPlayer][0]) {
        
g_szTempData[pPlayer][KILLS] = Float:get_entvar(pPlayervar_frags);
        
g_szTempData[pPlayer][DEATH] = get_member(pPlayerm_iDeaths);
        
g_szTempData[pPlayer][MONEY] = get_member(pPlayerm_iAccount);

        
TrieSetArray(g_tPlayerScoreg_szAuthID[pPlayer], g_szTempData[pPlayer], DATA);
    }
}

public 
client_putinserver(pPlayer) {
    if(
is_user_hltv(pPlayer) || is_user_bot(pPlayer)) {
        return;
    }

    
get_user_authid(pPlayerg_szAuthID[pPlayer], charsmax(g_szAuthID[]));

    if(
TrieGetArray(g_tPlayerScoreg_szAuthID[pPlayer], g_szTempData[pPlayer], DATA)) {
        
set_entvar(pPlayervar_fragsg_szTempData[pPlayer][KILLS]);
        
set_member(pPlayerm_iDeathsg_szTempData[pPlayer][DEATH]);
        
rg_add_account(pPlayerg_szTempData[pPlayer][MONEY], AS_SETfalse);
    }
    else {
        
arrayset(_:g_szTempData[pPlayer], _:0.0sizeof(g_szTempData[]));
    }
}

public 
refwd_RestartRound_Pre() {
    
DisableHookChain(hRestartRoundPre);

    
TrieClear(g_tPlayerScore);
}

public 
refwd_RoundEnd_Post(WinStatus:statusScenarioEventEndRound:eventFloat:tmDelay) {
    if(
event == ROUND_GAME_COMMENCE || event == ROUND_GAME_RESTART) {
        
EnableHookChain(hRestartRoundPre);
    }


Last edited by kounterboy; 07-24-2023 at 16:31.
kounterboy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-25-2023 , 16:58   Re: SAVE MONEY + SCORE + weapons and items purchased before disconnect
Reply With Quote #2

I started it for you but cannot finish right now, maybe someone else can or I can later.

PHP Code:
#include <amxmodx>
#include <reapi>

enum _:DATA 

    
Float:KILLS
    
DEATH
    
MONEY ,
    
PrimaryWeapon,
    
PrimaryClip,
    
PrimaryBPAmmo,
    
SecondaryWeapon,
    
SecondaryClip,
    
SecondaryBPAmmo,
    
ArmorType:atArmorType,
    
ArmorAmount
};

new 
g_szTempData[MAX_CLIENTS 1][DATA];
new 
g_szAuthID[MAX_CLIENTS 1][32];

new 
Trie:g_tPlayerScore;

new 
HookChain:hRestartRoundPre;

public 
plugin_end() {
    
TrieDestroy(g_tPlayerScore);
}

public 
plugin_init() {
    
register_plugin("Save score & money""1.3.7""Minni Mouse");

    
RegisterHookChain(RG_RoundEnd"refwd_RoundEnd_Post", .post true);

    
DisableHookChain((hRestartRoundPre 
        
RegisterHookChain(RG_CSGameRules_RestartRound"refwd_RestartRound_Pre", .post false))
    );

    
g_tPlayerScore TrieCreate();
}

public 
client_disconnected(pPlayer) {
    if(
is_user_hltv(pPlayer) || is_user_bot(pPlayer)) {
        return;
    }

    if(
g_szAuthID[pPlayer][0]) 
    {
        new 
ArmorType:atType;
        
        
g_szTempData[pPlayer][KILLS] = Float:get_entvar(pPlayervar_frags);
        
g_szTempData[pPlayer][DEATH] = get_member(pPlayerm_iDeaths);
        
g_szTempData[pPlayer][MONEY] = get_member(pPlayerm_iAccount);
        
        if ( 
get_member(pPlayerm_bHasPrimary) )
        {
            
g_szTempData[pPlayer][PrimaryWeapon]  = 
            
g_szTempData[pPlayer][PrimaryClip]  = 
            
g_szTempData[pPlayer][PrimaryBPAmmo]  = 
        }
        
        
g_szTempData[pPlayer][SecondaryWeapon]  = 
        
g_szTempData[pPlayer][SecondaryClip]  = 
        
g_szTempData[pPlayer][SecondaryBPAmmo]  = 
        
        if ( ( 
g_szTempData[pPlayer][ArmorAmount]  = rg_get_user_armorpPlayer atType) ) )
            
g_szTempData[pPlayer][atArmorType]  = atType;
        
        
TrieSetArray(g_tPlayerScoreg_szAuthID[pPlayer], g_szTempData[pPlayer], DATA);
    }
}

public 
client_putinserver(pPlayer) {
    if(
is_user_hltv(pPlayer) || is_user_bot(pPlayer)) {
        return;
    }

    
get_user_authid(pPlayerg_szAuthID[pPlayer], charsmax(g_szAuthID[]));

    if(
TrieGetArray(g_tPlayerScoreg_szAuthID[pPlayer], g_szTempData[pPlayer], DATA)) 
    {
        
set_entvar(pPlayervar_fragsg_szTempData[pPlayer][KILLS]);
        
set_member(pPlayerm_iDeathsg_szTempData[pPlayer][DEATH]);
        
rg_add_account(pPlayerg_szTempData[pPlayer][MONEY], AS_SETfalse);
    }
    else {
        
arrayset(_:g_szTempData[pPlayer], _:0.0sizeof(g_szTempData[]));
    }
}

public 
refwd_RestartRound_Pre() {
    
DisableHookChain(hRestartRoundPre);

    
TrieClear(g_tPlayerScore);
}

public 
refwd_RoundEnd_Post(WinStatus:statusScenarioEventEndRound:eventFloat:tmDelay) {
    if(
event == ROUND_GAME_COMMENCE || event == ROUND_GAME_RESTART) {
        
EnableHookChain(hRestartRoundPre);
    }

__________________

Last edited by Bugsy; 07-25-2023 at 16:58.
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-26-2023 , 07:58   Re: SAVE MONEY + SCORE + weapons and items purchased before disconnect
Reply With Quote #3

There's no such thing is called 'SecondaryBPAmmo' the phrase should be changed to BPAmmo[MAX_WEAPONS]

Since player can hold ammo for multiple weapons. ( i think its the same for weapons ) just like in half life.
__________________
@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 07-27-2023 , 21:58   Re: SAVE MONEY + SCORE + weapons and items purchased before disconnect
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
There's no such thing is called 'SecondaryBPAmmo' the phrase should be changed to BPAmmo[MAX_WEAPONS]

Since player can hold ammo for multiple weapons. ( i think its the same for weapons ) just like in half life.
I quickly built that enum based on the request, but agreed, the code needs tweaks. Maybe this weekend I'll have time.
__________________
Bugsy is offline
kounterboy
Junior Member
Join Date: May 2022
Location: LIMA-PERU
Old 07-31-2023 , 10:20   Re: SAVE MONEY + SCORE + weapons and items purchased before disconnect
Reply With Quote #5


I would appreciate. almost always at night we play MIX sometimes someone disconnects for "x" reasons, for the moment the plugin that I have saves the score and money, but with reference to what I already commented previously for the moment we pause the game and before it returns to connect amx_cvar mp_startmoney "x", to compensate the money before leaving the game, and we have to tell the player to send a screenshot to see if it really is the exact money he says ¬¬ xD, but hey thank you very much I await your response with the code =( I would appreciate it kisses


Quote:
Originally Posted by Bugsy View Post
I quickly built that enum based on the request, but agreed, the code needs tweaks. Maybe this weekend I'll have time.
kounterboy is offline
kounterboy
Junior Member
Join Date: May 2022
Location: LIMA-PERU
Old 08-10-2023 , 15:43   Re: SAVE MONEY + SCORE + weapons and items purchased before disconnect
Reply With Quote #6

I wanted to test what you had edited thinking that maybe some items from the purchase would grab but I get an error when compiling =(


Quote:
kounterboy 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 23:02.


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