PHP Code:
new const g_iRequiredKillsPerLevel[ ] =
{
16,
32,
64,
128,
256
};
new g_iLevel[ 33 ]; //Players current level
new g_iKills[ 33 ]; //Players current # kills
new g_iRequiredKills[ 33 ]; //# kills needed for next level
//Example current kill#
g_iKills[ id ] = 37;
//Keep looping while the kills are >= each kill level (range from 16-256). With each
//iteration, g_iLevel increases by 1 to change the required kill level we are checking.
//This loop would exit on the 3rd condition check leaving vals at:
// g_iKills=37, g_iLevel=1, g_iRequiredKillsPerLevel=32
while( g_iKills[ id ] >= g_iRequiredKillsPerLevel[ g_iLevel[ id ] ] )
{
/*Iterations
1. g_iKills=37, g_iLevel=0, g_iRequiredKillsPerLevel=16
2. g_iKills=37, g_iLevel=1, g_iRequiredKillsPerLevel=32 (loop exits here since 37 < 64)
3. g_iKills=37, g_iLevel=2, g_iRequiredKillsPerLevel=64 */
g_iLevel[ id ]++;
}
//Here we determine the # kills needed for next level with these values:
// g_iLevel[ id ] = 1
// g_iLevel[ id ] + 1 = 2
// g_iRequiredKillsPerLevel[ 2 ] = 64
// g_iKills[ id ] = 37
// 27 = 64 - 37
g_iRequiredKills[ id ] = g_iRequiredKillsPerLevel[ g_iLevel[ id ] + 1 ] - g_iKills[ id ];
__________________