Jump to content


Photo

Quick script question


  • Please log in to reply
8 replies to this topic

#1 gorinds

gorinds

    GMC Member

  • GMC Member
  • 148 posts

Posted 14 January 2012 - 04:12 PM

So lets get right into it, can I do this?

Player event:
script(2)

Script:
global.something+argument0=3

So can I kind of add the number to the name of the variable?
So it would look like this:
global.something2=3

Or do I have to use string or something else?

Edited by gorinds, 15 January 2012 - 11:13 AM.

  • 0

#2 ean

ean

    GMC Member

  • New Member
  • 190 posts
  • Version:GM8

Posted 14 January 2012 - 04:20 PM

So lets get right into it, can I do this?

Player event:

script(2)

Script:
global.something+argument0=3

So can I kind of add the number to the name of the variable?
So it would look like this:
global.something2=3

Or do I have to use string or something else?

variable_global_set(name,value) Sets the global variable with the given name (a string) to the given value.

Edited by ean, 14 January 2012 - 04:21 PM.

  • 0

#3 gorinds

gorinds

    GMC Member

  • GMC Member
  • 148 posts

Posted 14 January 2012 - 04:24 PM

So string it is. :D thnks
  • 0

#4 Davve

Davve

    Procrastinator

  • GMC Member
  • 3665 posts
  • Version:GM8.1

Posted 14 January 2012 - 04:32 PM

I would use arrays if I were you (something[2] instead of something2).
  • 0

#5 gorinds

gorinds

    GMC Member

  • GMC Member
  • 148 posts

Posted 14 January 2012 - 04:38 PM

Uh... "global.something+argument0=3" gave me an error.

and no arrays are not an option. :P just need to get the name changed
is this even possible?
Assignment operator expected

Or yes its an option, but it would mean a lot of renaming for me... ALOT

Edited by gorinds, 14 January 2012 - 04:39 PM.

  • 0

#6 Davve

Davve

    Procrastinator

  • GMC Member
  • 3665 posts
  • Version:GM8.1

Posted 14 January 2012 - 05:05 PM

variable_global_set ("something" + argument0, 3)

or

global.something[argument0] = 3

Edited by Davve, 14 January 2012 - 05:05 PM.

  • 0

#7 gorinds

gorinds

    GMC Member

  • GMC Member
  • 148 posts

Posted 14 January 2012 - 05:20 PM

Not even this works? wtf.
argument0=2


aa=variable_global_get(global.something+string(argument0))

error:
aa=variable_global_get(global.something+string(argument0))
                                          ^
at position 41: Wrong type of arguments to +.

  • 0

#8 Davve

Davve

    Procrastinator

  • GMC Member
  • 3665 posts
  • Version:GM8.1

Posted 14 January 2012 - 10:24 PM

aa=variable_global_get("global.something"+string(argument0))

  • 0

#9 gorinds

gorinds

    GMC Member

  • GMC Member
  • 148 posts

Posted 14 January 2012 - 10:59 PM

Well now I got it, it was:
aa=variable_global_get("something"+argument0)
Thanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users