Raised This Month: $ Target: $400
 0% 

Optimize Code


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 01-24-2020 , 10:24   Re: Optimize Code
Reply With Quote #9

Wanted to make it better but then I remembered you could just add this line in your addons/amxmodx/configs/stats.ini file and have the same functionality so I dropped it:
PHP Code:
SpecRankInfo             ;SpecRank Info 
PHP Code:
#include <amxmodx>
#include <csstats>
#include <fakemeta>
#include <hamsandwich>

// Cvaruri
new g_iIDPCVarHudEnable;

public 
plugin_init()
{
    
register_plugin("Hud Info""1.1""")
    
register_dictionary("statscfg.txt")
    
    
// Register Cvars
    
g_iIDPCVarHudEnable register_cvar("credits_hudstats""1");
    
    
RegisterHam(Ham_Spawn"player""fwHamSpawnPlayer"1)
    
RegisterHam(Ham_Killed"player""fwHamKilledPlayer"1)
}

public 
client_putinserver(iID)
{
    
set_task(1.0"fwTaskShowHud"iID, .flags "b")
}

public 
fwHamSpawnPlayer(const iID)
{
    if (!
is_user_alive(iID))
        return;
    
    
remove_task(iID)
}

public 
fwHamKilledPlayer(const iID)
{
    
set_task(1.0"fwTaskShowHud"iID, .flags "b")
}

#if AMXX_VERSION_NUM <= 182
public client_disconnect(iID)
#else
public client_disconnected(iID)
#endif
{
    
remove_task(iID)
}

public 
fwTaskShowHud(const iID)
{
    if (!
get_pcvar_num(g_iIDPCVarHudEnable))
        return;
    
    
// AMXX 182 and lower have issues and client disconnect forwards don't trigger for
    // all the cases so we need to "manually" check if client is still connected too
    #if AMXX_VERSION_NUM <= 182
    
if (!is_user_connected(iID))
    {
        
remove_task(iID)
        
        return;
    }
    
#endif
    
    
new iIDSpec pev(iIDpev_iuser2);
    
    if(!
iIDSpec || iIDSpec == iID)
        return;
    
    
// Player max name length is 31
    
new szName[31];
    
get_user_name(iIDszNamecharsmax(szName))
    
    new 
iTemp[8], iRankSpec;
    
iRankSpec get_user_stats(iIDSpeciTempiTemp);
    
    
iTemp[0] = get_statsnum();
    
    
// Avoid using automatic channel and/or hud sync because they create hud flicker issues
    
set_hudmessage(0100250, -1.00.7800.01.050.00.02)
    
show_hudmessage(iIDSpec"[ %L ^"%s^": %d/%d ]"iID"ST_SPEC_RANK"szNameiRankSpeciTemp[0])

__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
 



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:44.


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