Raised This Month: $ Target: $400
 0% 

help with percentage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lucho.
Member
Join Date: Jul 2012
Location: Buenos Aires, Argentina
Old 06-05-2014 , 19:49   help with percentage
Reply With Quote #1

Hi, I have a problem with the percentage, the first level of range I'm doing well, but cuand Otengo range "C", etc, does not start from 0, so I would like to help me fix it and Begin 0 pls ..

PHP Code:
new g_rango[33
enum _:Rangos_Hm 

    
Nombre_Rango[20], //Para El HUD 
    
Exp_Requerida// Experiencia Requerida Para El Proximo Rango 
    
Vida


enum _:MAX_RANGOS {
    
0,
    
D,
    
C,
    
B,
    
A,
    
S

PHP Code:
new const gRangosHumanos[MAX_RANGOS][Rangos_Hm] = 

    { 
"E"0110 }, 
    { 
"D"10120 }, 
    { 
"C"20130 }, 
    { 
"B"40140 }, 
    { 
"A"150150 }, 
    { 
"S"200160 }
   

PHP Code:
public porciento_nivel(id

    new 
Float:numero 
    numero 
= (g_frags[id] * 100.0) / gRangosHumanos[g_rango[id]][Exp_Requerida]
    
    return 
numero  0.0

Thanks.

Last edited by Lucho.; 06-05-2014 at 19:50.
Lucho. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-05-2014 , 22:06   Re: help with percentage
Reply With Quote #2

There are several things that I notice.
  • E, D, C, B, A, S should not be in the gRangosHumanos array.
  • gRangosHumanos is not a floating point variable so you either need to declare it as such or use the float() function when you use it in your code.
  • porciento_nivel() should be declared as a floating point function.
  • Your return line is wrong. It should simply be the keywork return and the value being returned.
__________________

Last edited by fysiks; 06-05-2014 at 22:06.
fysiks 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 09:35.


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