AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with percentage (https://forums.alliedmods.net/showthread.php?t=241571)

Lucho. 06-05-2014 19:49

help with percentage
 
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.

fysiks 06-05-2014 22:06

Re: help with percentage
 
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.


All times are GMT -4. The time now is 09:35.

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