AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to Avoid this in Statsx? (https://forums.alliedmods.net/showthread.php?t=299397)

xExperienced 07-13-2017 10:48

How to Avoid this in Statsx?
 
As you know statsx shows "Best Score" in HUD only..

I wanted "Best Score (of round)" function of Statsx to be printed in chat also..

I added some code but it is printing same line 3-4 times even after new round starts..


The Code which I added is in bold :

Code:

// Get and format best score.
add_best_score(id, sBuffer[MAX_BUFFER_LENGTH + 1])
{
        new iPlayer, iMaxKillsId, iMaxKills, iMaxHeadShots

        iMaxKillsId = 0
        iMaxKills = 0
        iMaxHeadShots = 0

        // Find player
        for (iPlayer = 1; iPlayer <= MaxClients; iPlayer++)
        {
                if (g_izUserRndStats[iPlayer][STATS_KILLS] >= iMaxKills && (g_izUserRndStats[iPlayer][STATS_KILLS] > iMaxKills || g_izUserRndStats[iPlayer][STATS_HS] > iMaxHeadShots))
                {
                        iMaxKillsId = iPlayer
                        iMaxKills = g_izUserRndStats[iPlayer][STATS_KILLS]
                        iMaxHeadShots = g_izUserRndStats[iPlayer][STATS_HS]
                }
        }

        // Format statistics.
        if (iMaxKillsId)
        {
                iPlayer = iMaxKillsId

                new Float:fGameEff = effec(g_izUserGameStats[iPlayer])
                new Float:fRndAcc = accuracy(g_izUserRndStats[iPlayer])

                {
                formatex(t_sText, charsmax(t_sText), "%L: %s^n%d %L / %d hs -- %0.2f%% %L / %0.2f%% %L^n", id, "BEST_SCORE", g_izUserRndName[iPlayer],
                                iMaxKills, id, "KILL_S", iMaxHeadShots, fGameEff, id, "EFF", fRndAcc, id, "ACC")
                add(sBuffer, charsmax(sBuffer), t_sText)
                }
               
                {
                colorchat(0, "^x04Round's Best Score : ^x03%s ^x01- ^x04%d ^x03%L ^x01| ^x04%d ^x03Headshot(s) ^x01| ^x04 %0.2f%% ^x03%L ^x01| ^x04 %0.2f%% ^x03%L", g_izUserRndName[iPlayer],
                                iMaxKills, id, "KILL_S", iMaxHeadShots, fGameEff, id, "EFF", fRndAcc, id, "ACC")
                }
               
        }

        return iMaxKillsId
}



See this I wanna Avoid it.. It shud print once only...

https://preview.ibb.co/jVc3Nv/10_scr...18234413_1.jpg


All times are GMT -4. The time now is 22:44.

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