Raised This Month: $51 Target: $400
 12% 

Better option for this?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 07-12-2016 , 13:22   Better option for this?
Reply With Quote #1

Hi, I just wondered if there is better option for this?

PHP Code:
switch( g_iLeveliPlayer ] )
{
    case 
2iGains 3;
    case 
4iGains 6;
    case 
6iGains 9;
    case 
8iGains 12;
    case 
10iGains 15;

As you see every second level iGains should be raised by 3, if there would be more than 200 it would not be that optimal. So I want you to suggest something more optimal.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-12-2016 , 13:59   Re: Better option for this?
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=284917
__________________
Depresie is offline
Old 07-12-2016, 14:45
gabuch2
This message has been deleted by gabuch2. Reason: quick edit
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 07-12-2016 , 14:48   Re: Better option for this?
Reply With Quote #3

PHP Code:
if(float(g_iLevel[iPlayer]/2.0) == floatround(float(g_iLevel[iPlayer]/2.0),floatround_ceil))
{
    
iGains 3*(g_iLevel[iPlayer])

This is what I could come up with, but I'm sure there are more proper ways to do it.
__________________

Last edited by gabuch2; 07-12-2016 at 14:49.
gabuch2 is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 07-12-2016 , 14:50   Re: Better option for this?
Reply With Quote #4

Quote:
Originally Posted by Depresie View Post
Thanks, found some information which will help me

Quote:
Originally Posted by Shattered Heart Lynx View Post
PHP Code:
if(float(g_iLevel[iPlayer]/2.0) == floatround(float(g_iLevel[iPlayer]/2.0),floatround_ceil))
{
    
iGains 3*(g_iLevel[iPlayer])

This is what I could come up with, but I'm sure there are more proper ways to do it.
but what if I want to raise iGains every third, fifth, tenth level?

Last edited by ~Ice*shOt; 07-12-2016 at 14:51.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Old 07-12-2016, 14:57
gabuch2
This message has been deleted by gabuch2. Reason: it doesnt work
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 07-12-2016 , 15:00   Re: Better option for this?
Reply With Quote #5

Quote:
Originally Posted by ~Ice*shOt View Post
but what if I want to raise iGains every third, fifth, tenth level?
PHP Code:
new Float:increment 2.0 //change this
if(float(g_iLevel[iPlayer]/increment) == floatround(float(g_iLevel[iPlayer]/increment),floatround_ceil))
{
    
iGains 3*(g_iLevel[iPlayer])

Not sure if it'll work.

Like I said I'm sure there are better ways to do it.
__________________
gabuch2 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-12-2016 , 15:10   Re: Better option for this?
Reply With Quote #6

With integer division.
PHP Code:
const LEVELS_BETWEEN_INC 2// Level gap between increments
const GAINS_PER_INC 3// Gains per increment

iGains = (g_iLevel[iPlayer] / LEVELS_BETWEEN_INC) * GAINS_PER_INC
klippy is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 07-12-2016 , 16:24   Re: Better option for this?
Reply With Quote #7

Thanks, it seems simple, but i still couldn't find out that.. Thanks again
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
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 19:16.


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