Raised This Month: $ Target: $400
 0% 

Trouble with Floats


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Infest
Member
Join Date: Mar 2005
Old 10-30-2007 , 20:32   Trouble with Floats
Reply With Quote #1

I'm trying to make a math script, however I'm having some trouble with getting floats to work.

Take this example:
PHP Code:
register_cvar("number","0.01")

public 
mult(id)
{
new 
arg[32], value1value2

read_argv
(1,arg,31)

value1 str_to_num(arg)
value2 get_cvar_float("number")

new 
output value1*value2
client_print
(id,print_chat,"[AMXX] Your number is %i",output)
return 
PLUGIN_HANDLED

Whenever I use this example I get these huge numbers like "326743734", how do I get this to work properly?
Infest is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-30-2007 , 20:40   Re: Trouble with Floats
Reply With Quote #2

Don't forget to insert 'Float:' tag.

Code:
public mult(id) {     new arg[32], Float:value1, Float:value2     read_argv(1,arg,31)     value1 = str_to_float(arg)     value2 = get_cvar_float("number")     new Float:output = value1*value2     client_print(id,print_chat,"[AMXX] Your number is %f",output)     return PLUGIN_HANDLED }
__________________
Arkshine is offline
Reply


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 01:20.


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