Raised This Month: $ Target: $400
 0% 

Help with float/int enum params


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Netsys
Senior Member
Join Date: Feb 2010
Old 12-15-2015 , 09:58   Help with float/int enum params
Reply With Quote #1

I have more stats, this is just an example. How it should be done so that the float parameters work well?

PHP Code:
#include <amxmodx>

enum _structStats
{
    
FloatstatDamage,
    
statKills
}

new 
g_iStats[structStats];
new 
g_iStatsRound[structStats];

public 
plugin_init()
{
    
register_concmd("float_test""commandTest")
}

public 
commandTestiPlayerID )
{
    
console_print(iPlayerID"[0] statDamage: %.2f - statKills: %d"g_iStats[statDamage], g_iStats[statKills]);

    new 
szStat[2], szValue[12];
    
read_argv(1szStatcharsmax(szStat));
    
read_argv(2szValuecharsmax(szValue));

    if (
str_to_num(szStat) == 0)
    {
        
UpdateStats(statDamagestr_to_float(szValue));
    }
    else
    {
        
UpdateStats(statKillsstr_to_num(szValue));
    }

    
console_print(iPlayerID"[1] statDamage: %.2f - statKills: %d"g_iStats[statDamage], g_iStats[statKills]);
}

UpdateStats( const iStatID, const {Float_}: iValue 1.0 )
{
    
g_iStats[iStatID]      += _iValue;
    
g_iStatsRound[iStatID] += _iValue;

Output:
PHP Code:
11:50:41 float_test 0 "12.1"
11:50:41 [0statDamage0.00 statKills0
         
[1statDamage12.10 statKills0
11
:50:43 float_test 0 "12.1"
11:50:44 [0statDamage12.10 statKills0
         
[1statDamage: -0.00 statKills0
11
:52:44 float_test 0 "12.1"
11:52:44 [0statDamage: -0.00 statKills0
         
[1statDamage: -393.60 statKills0
11
:55:54 float_test 1 "1"
11:55:54 [0statDamage: -393.60 statKills0
         
[1statDamage: -393.60 statKills1
11
:56:00 float_test 1 "3"
11:56:00 [0statDamage: -393.60 statKills1
         
[1statDamage: -393.60 statKills4
11
:56:03 float_test 1 "12.1"
11:56:04 [0statDamage: -393.60 statKills4
         
[1statDamage: -393.60 statKills16 
Netsys is offline
 


Thread Tools
Display Modes

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 17:51.


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