Doing it this way will reduce the amount of code because you will not need any if-statements and each native function is only used once. Just make sure that the g_PlayerLevel[] for any given player is greater than 0 and NOT greater than NumLevels. If players do have a level 0, just replace the first element (with 0 , 0.0 , 0.0 values ) in the the below g_lpLevelPowers array with level 0 values. Let me know if you have any questions.
PHP Code:
enum LevelPowers
{
LP_Health,
Float:LP_MaxSpeed,
Float:LP_Gravity
}
//Set this variable to the number of levels you have
const NumLevels = 3;
/*Add each level powers exactly as they are below. The
order is { health , maxspeed , gravity }. Make sure you always
have the number of powers equal to NumLevels variable; the
plugin will not compile if NumLevels is not equal to the levels
defined in this array. I assumed there is no level 0 so I left all
powers at 0.*/
new const g_lpLevelPowers[ NumLevels + 1 ][ LevelPowers ] =
{
{ 0 , 0.0 , 0.00 }, //Level 0 (add powers if needed)
{ 120 , 245.0 , 0.95 }, //Level 1
{ 140 , 250.0 , 0.90 }, //Level 2
{ 160 , 255.0 , 0.85 } //Level 3
}
public Sethpspdgr(id)
{
set_user_health( id , g_lpLevelPowers[ g_PlayerLevel[ id ] ][ LP_Health ] )
set_pev( id , pev_maxspeed, g_lpLevelPowers[ g_PlayerLevel[ id ] ][ LP_MaxSpeed ] )
set_user_gravity( id , g_lpLevelPowers[ g_PlayerLevel[ id ] ][ LP_Gravity ] )
}
__________________