Raised This Month: $ Target: $400
 0% 

Getting Top5 Players of Map


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 08-25-2013 , 09:26   Getting Top5 Players of Map
Reply With Quote #1

Hello,

I'd like to get the Top5 Player IDs of the Map using this code.

PHP Code:
public calculate_places()
{
    new 
iFragsiFrags1iFrags2iFrags3iFrags4iFrags5
    
    
if(g_iFirstPlace == 0)
        
iFrags1 0
    
else
        
iFrags1 get_user_frags(g_iFirstPlace)
        
    if(
g_iSecondPlace == 0)
        
iFrags2 0
    
else
        
iFrags2 get_user_frags(g_iSecondPlace)
        
    if(
g_iThirdPlace == 0)
        
iFrags3 0
    
else
        
iFrags3 get_user_frags(g_iThirdPlace)
        
    if(
g_iFourthPlace == 0)
        
iFrags4 0
    
else
        
iFrags4 get_user_frags(g_iFourthPlace)
        
    if(
g_iFifthPlace == 0)
        
iFrags5 0
    
else
        
iFrags5 get_user_frags(g_iFifthPlace)
    
    new 
players[32], pnumtempid
    get_players
(playerspnum)
    
    for( new 
ii<pnumi++ ) 
    {
        
tempid players[i]
        
        
iFrags get_user_frags(tempid)
        
        if(
iFrags iFrags1)
        {
            
g_iFirstPlace tempid
            
return PLUGIN_HANDLED
        
}
        
        if(
iFrags iFrags2)
        {
            
g_iSecondPlace tempid
            
return PLUGIN_HANDLED
        
}
        
        if(
iFrags iFrags3)
        {
            
g_iThirdPlace tempid
            
return PLUGIN_HANDLED
        
}
        
        if(
iFrags iFrags4)
        {
            
g_iFourthPlace tempid
            
return PLUGIN_HANDLED
        
}
        
        if(
iFrags iFrags5)
        {
            
g_iFifthPlace tempid
            
return PLUGIN_HANDLED
        
}
        
    }
    return 
PLUGIN_HANDLED

But as you can see in the Picture it always shows me on all places, even when others have frags too.


Code for HUD below :

PHP Code:
// ===============================================================================
//     Left HUD
// ===============================================================================

public func_HUDLeft()
{    
    if(!
g_bGameHasStarted)
        return 
PLUGIN_HANDLED
    
    set_hudmessage
(HUD_LEFT_REDHUD_LEFT_GREENHUD_LEFT_BLUEHUD_LEFT_XHUD_LEFT_Y0_HUD_FREQ__2)
    
    new 
players[32], pnumtempid
    get_players
(playerspnum"a")
    
    new 
szNameO[64]
    new 
szName1[64], szName2[64], szName3[64], szName4[64], szName5[64]
    
    if(
g_iFirstPlace != 0)
        
get_user_name(g_iFirstPlace,     szName1charsmax(szName1))
    else
        
formatex(szName1charsmax(szName1), "-")
    
    if(
g_iSecondPlace != 0)
        
get_user_name(g_iSecondPlace,     szName2charsmax(szName2))
    else
        
formatex(szName2charsmax(szName2), "-")
    
    if(
g_iThirdPlace != 0)
        
get_user_name(g_iThirdPlace,     szName3charsmax(szName3))
    else
        
formatex(szName3charsmax(szName3), "-")
    
    if(
g_iFourthPlace != 0)
        
get_user_name(g_iFourthPlace,     szName4charsmax(szName4))
    else
        
formatex(szName4charsmax(szName4), "-")
    
    if(
g_iFifthPlace != 0)
        
get_user_name(g_iFifthPlace,     szName5charsmax(szName5))
    else
        
formatex(szName5charsmax(szName5), "-")
        
    
/* Scoreboard Style :

    (HUD) 1st [Kills] Name
    (HUD) 2nd [Kills] Name
    (HUD) 3rd [Kills] Name
    (HUD) 4th [Kills] Name
    (HUD) 5th [Kills] Name
    ^n
    (HUD) >> [Kills] Own Name */
    
    
for( new ii<pnumi++ ) 
    {
        
tempid players[i]
        
get_user_name(tempidszNameOcharsmax(szNameO))
        
        
ShowSyncHudMsg(tempidSyncObj_Left"1st [%i] %s ^n 2nd [%i] %s ^n 3rd [%i] %s ^n 4th [%i] %s ^n 5th [%i] %s ^n^n >> [%i] %s",
        
get_user_frags(g_iFirstPlace), szName1,
        
get_user_frags(g_iSecondPlace), szName2,
        
get_user_frags(g_iThirdPlace), szName3,
        
get_user_frags(g_iFourthPlace), szName4,
        
get_user_frags(g_iFifthPlace), szName5,
        
get_user_frags(tempid), szNameO)
    }    
    
    return 
PLUGIN_HANDLED

I'm quite sure my code is bad, so, if anyone could help me, that would be great.
__________________
Kia is offline
 



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 19:00.


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