Raised This Month: $ Target: $400
 0% 

[HELP] how optimize/change this code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-03-2010 , 09:01   Re: [HELP] how optimize/change this code?
Reply With Quote #1

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_lpLevelPowersNumLevels ][ LevelPowers ] = 
{
    {   
,    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_healthid g_lpLevelPowersg_PlayerLevelid ] ][ LP_Health ] )
    
set_pevid pev_maxspeedg_lpLevelPowersg_PlayerLevelid ] ][ LP_MaxSpeed ] )
    
set_user_gravityid g_lpLevelPowersg_PlayerLevelid ] ][ LP_Gravity ] )

__________________
Bugsy is offline
Reply



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 11:24.


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