AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   variable (https://forums.alliedmods.net/showthread.php?t=242518)

grs4 06-20-2014 16:08

variable
 
can we create a variable which have a multi types?
I mean something like:
Code:

new variable[3]
 
variable[0]=5
Float:variable[1]=3.14
variable[2]='@'


Flick3rR 06-20-2014 16:12

Re: variable
 
As far as I know, this is not possible, since you can save only integer values in one cell of variable. For string you must have more cells, and for floats I think you have to use float() tag instead of Float:, because this is used when you create new variable.

Black Rose 06-20-2014 16:15

Re: variable
 
Explain what you want to do and why.

grs4 06-20-2014 16:31

Re: variable
 
I want have in one variable in this same time float and integer, like first post. Then i dont want to check that something variable is Float or Integer, i want to simple e.c use
Code:

set_task(variable[VALUE_OF_CVAR_TASK], "... )

cs_set_user_money(id, variable[VALUE_OF_OTHER_TASK])

i dont want to using enums

Black Rose 06-20-2014 16:33

Re: variable
 
For what good reason?
If you make it a float you can assign integers to it by using float() or just * 1.0 or vice versa with floatround() since money doesn't really have to be that exact.

grs4 06-20-2014 16:39

Re: variable
 
money is only example
What when i want to have specify float ? Like 1.5 :) Floatround will make to 1.0 or 2.0, dont know specialyy

Black Rose 06-20-2014 16:59

Re: variable
 
It depends. You can floor it, ceil it or round it. By default it's rounding, so that would be 2. Another option is to multiply it by, say 10, and then divide it by 10 on the other end. That way you don't lose information if you have to pass it through an array of some sort.

grs4 06-21-2014 16:33

Re: variable
 
Thats good idea,thanks for help ;)

GuskiS 06-21-2014 16:42

Re: variable
 
Why not use enums with different type?

grs4 06-21-2014 20:07

Re: variable
 
because i have a gCvarInfo where are a returns of CvarRegister (cvar_util)
and someone from cvars is float so i cant enum float to CvarRegister xD
and i must create a new enum tabel with value (integer or float)

sry for my english


All times are GMT -4. The time now is 21:07.

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