Raised This Month: $ Target: $400
 0% 

variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 06-20-2014 , 16:08   variable
Reply With Quote #1

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]='@'
grs4 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-20-2014 , 16:12   Re: variable
Reply With Quote #2

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.
__________________

Last edited by Flick3rR; 06-20-2014 at 16:12.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Old 06-21-2014, 02:10
HamletEagle
This message has been deleted by HamletEagle. Reason: Wrong theard.
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-20-2014 , 16:15   Re: variable
Reply With Quote #4

Explain what you want to do and why.
__________________

Last edited by Black Rose; 06-20-2014 at 16:19.
Black Rose is offline
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 06-20-2014 , 16:31   Re: variable
Reply With Quote #5

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
grs4 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-20-2014 , 16:33   Re: variable
Reply With Quote #6

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.
__________________

Last edited by Black Rose; 06-20-2014 at 16:36.
Black Rose is offline
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 06-20-2014 , 16:39   Re: variable
Reply With Quote #7

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
grs4 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-20-2014 , 16:59   Re: variable
Reply With Quote #8

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.
__________________

Last edited by Black Rose; 06-21-2014 at 16:39. Reason: Damn autocorrect
Black Rose is offline
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 06-21-2014 , 16:33   Re: variable
Reply With Quote #9

Thats good idea,thanks for help ;)
grs4 is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 06-21-2014 , 16:42   Re: variable
Reply With Quote #10

Why not use enums with different type?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Reply



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 21:07.


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