Skip to content
View in the app

A better way to browse. Learn more.

Zloplay community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED] How to get dvars into an array?

Just curious on how to get dvars into an array.

 

I'm trying to get 'camera_thirdPersonOffset' into 3 different variables.

I've tried:

self.val = getDvar( "camera_thirdPersonOffset" );
self iPrintLn( self.val[0] );

 

but that only seems to print 1 character '-' which is at the start (-120) or something. then I tried:

 

self.val = getDvar( "camera_thirdPersonOffset" );
self iPrintLn( self.val[0] + self.val[1] + self.val[2] + self.val[3] );

 

That worked, but I was look for a simpler way of doing it. :S Any help?

 

EDIT:

Usage:

val = getDvarVector( "camera_thirdPersonOffset" );
self iPrintLn( "Value: " + val[0] );

Featured Replies

Just curious on how to get dvars into an array.

 

I'm trying to get 'camera_thirdPersonOffset' into 3 different variables.

I've tried:

self.val = getDvar( "camera_thirdPersonOffset" );
self iPrintLn( self.val[0] );

 

but that only seems to print 1 character '-' which is at the start (-120) or something. then I tried:

 

self.val = getDvar( "camera_thirdPersonOffset" );
self iPrintLn( self.val[0] + self.val[1] + self.val[2] + self.val[3] );

i think this is the easyest way:D

 

That worked, but I was look for a simpler way of doing it. :S Any help?

You are creating a variable with a string, then you are accessing the string variable as an array. The result is that you get single chars from the string (pretty logic).

 

Try this:

self.val = [];
self.val[0] = getDvar( "camera_thirdPersonOffset" );

  • Author
You are creating a variable with a string, then you are accessing the string variable as an array. The result is that you get single chars from the string (pretty logic).

 

Try this:

self.val = [];
self.val[0] = getDvar( "camera_thirdPersonOffset" );

 

If I put 'self iPrintLn( "Debug: " + self.val[0] );' It returns -120 0 4, I want separate values. :S This works with velocity. :S

This is one of the pitfalls of no types in gsc. You are calling getDvar which returns a string when you want it as a vector (which lets you access its members as an array or by var.X, var.Y, var.Z) use "getdvarvector" instead of "getdvar".

  • Author
This is one of the pitfalls of no types in gsc. You are calling getDvar which returns a string when you want it as a vector (which lets you access its members as an array or by var.X, var.Y, var.Z) use "getdvarvector" instead of "getdvar".

 

Thank you Sir. :3 <3 Your help is muchly appreciated. :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.