Hello,
I'd like to get the Top5 Player IDs of the Map using this code.
PHP Code:
public calculate_places()
{
new iFrags, iFrags1, iFrags2, iFrags3, iFrags4, iFrags5
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], pnum, tempid
get_players(players, pnum)
for( new i; i<pnum; i++ )
{
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_RED, HUD_LEFT_GREEN, HUD_LEFT_BLUE, HUD_LEFT_X, HUD_LEFT_Y, 0, _, HUD_FREQ, _, _, 2)
new players[32], pnum, tempid
get_players(players, pnum, "a")
new szNameO[64]
new szName1[64], szName2[64], szName3[64], szName4[64], szName5[64]
if(g_iFirstPlace != 0)
get_user_name(g_iFirstPlace, szName1, charsmax(szName1))
else
formatex(szName1, charsmax(szName1), "-")
if(g_iSecondPlace != 0)
get_user_name(g_iSecondPlace, szName2, charsmax(szName2))
else
formatex(szName2, charsmax(szName2), "-")
if(g_iThirdPlace != 0)
get_user_name(g_iThirdPlace, szName3, charsmax(szName3))
else
formatex(szName3, charsmax(szName3), "-")
if(g_iFourthPlace != 0)
get_user_name(g_iFourthPlace, szName4, charsmax(szName4))
else
formatex(szName4, charsmax(szName4), "-")
if(g_iFifthPlace != 0)
get_user_name(g_iFifthPlace, szName5, charsmax(szName5))
else
formatex(szName5, charsmax(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 i; i<pnum; i++ )
{
tempid = players[i]
get_user_name(tempid, szNameO, charsmax(szNameO))
ShowSyncHudMsg(tempid, SyncObj_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.
__________________