Raised This Month: $32 Target: $400
 8% 

Converting 1D array into 2D


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 12-12-2017 , 13:31   Converting 1D array into 2D
Reply With Quote #1

So guys I know how to use both 1D and 2D arrays.
But in one of private plugins I found that 1D array was converted to 2D.

It was like this ---
Code:
new g_iPlayerType[33] new var1 = g_iPlayerType[iPlayer] var1 = var1[0][0] | 4

And all around the sma the variable was used as g_iPlayerType[0][0] .

My Questions ---

1. If I use the above method will I be able to convert 1D array into 2D ??
If no, then whats the way of converting 1D array into 2D ??

2. I know the uses of logocal operators, but can anyone tell me how is the bitwise or | works ?
How is the code executed with bitwise or ??
Abhinash is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 12-12-2017 , 13:47   Re: Converting 1D array into 2D
Reply With Quote #2

can`t tell you about arrays, but there are great tutorials on bitsum operators here: https://forums.alliedmods.net/showthread.php?t=90507 and here: https://forums.alliedmods.net/showthread.php?t=139916
__________________
retired chump
DjSoftero is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 12-12-2017 , 14:49   Re: Converting 1D array into 2D
Reply With Quote #3

Thanks DjSoftero for the links of the Bitwise threads.
But can anyone help me with my first question ??
Abhinash is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-12-2017 , 21:48   Re: Converting 1D array into 2D
Reply With Quote #4

I'm not sure how that would work at all unless it's some unique trick in the Pawn programming language.

As far as converting a 1D array to an 2D array, it really depends on what you are actually trying to do. In the use case you posted about, it's likely not converting anything. It's likely changing the interpretation of the same memory space.

You should attach the plugin's source code so that we can see how it's actually being used.
__________________
fysiks is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-12-2017 , 22:03   Re: Converting 1D array into 2D
Reply With Quote #5

Basically you cant convert 1d array into 2d array, you only can add that 1d array into the 2d array

And the code you provided is wrong,and might cause a compiling error
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 12-13-2017 , 00:51   Re: Converting 1D array into 2D
Reply With Quote #6

So, whats the right way to convert a 1D array into 2D ?
Can you tell me fysiks ?

Fysiks, if do thr same way above then the interpretation of memory space is converted from 1D into 2D.
Will it work if I do the same way as above in my own plugin ?

Last edited by Abhinash; 12-13-2017 at 00:54. Reason: Added one more question ��
Abhinash is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-13-2017 , 09:27   Re: Converting 1D array into 2D
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
As far as converting a 1D array to an 2D array, it really depends on what you are actually trying to do.
In general, you would have to create the 2D array and then add the contents of the 1D array into the new 2D array.
__________________

Last edited by fysiks; 12-13-2017 at 09:28.
fysiks is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 12-13-2017 , 15:50   Re: Converting 1D array into 2D
Reply With Quote #8

I am just talking about the reverse thing.
If I do this , will it work ???

Code:
new var[33] var = var[0][0]

Since I am not creating any rows and columns, will it work ?
Abhinash is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-13-2017 , 16:03   Re: Converting 1D array into 2D
Reply With Quote #9

Quote:
Originally Posted by Abhinash View Post
I am just talking about the reverse thing.
If I do this , will it work ???

Code:
new var[33] var = var[0][0]

Since I am not creating any rows and columns, will it work ?
No it wont
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 12-14-2017 , 06:36   Re: Converting 1D array into 2D
Reply With Quote #10

So, can you tell me the correct way of converting 1D array into 2D ?
Abhinash 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 17:14.


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