AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Trouble with Floats (https://forums.alliedmods.net/showthread.php?t=62587)

Infest 10-30-2007 20:32

Trouble with Floats
 
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?

Arkshine 10-30-2007 20:40

Re: Trouble with Floats
 
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 }


All times are GMT -4. The time now is 01:20.

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