Raised This Month: $51 Target: $400
 12% 

[Solved]Array natives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 10-31-2014 , 02:02   [Solved]Array natives
Reply With Quote #1

Can someone explain to me with an example how does ArraySetCell and ArrayDeleteItem respond to an array with integers ?

I made a code (private code), and it uses ArrayDeleteItem on an integer array and ArraySetCell too, but instead of deleting and setting the cell value of the item either of them are creating an extra entry and replacing the last one with 0 (On using amx_load_setting_int_arr) :/, i just need good examples. thank you.
__________________
You will find everything u need :-

Last edited by Catastrophe; 10-31-2014 at 07:31.
Catastrophe is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-31-2014 , 07:25   Re: Array natives
Reply With Quote #2

They don't do that. Show us code or we can't help you. We don't need the whole code, just a working example that exhibits the same behavior that you are seeing.
__________________
In Flames we trust!
Nextra is offline
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 10-31-2014 , 07:31   Re: Array natives
Reply With Quote #3

Well thanks for trying to help man, i just fixed it, it was just me being dumb ;) thnx again , But ill still tell where i was wrong in case any1 wants to know i was using ArrayPushCell instead of ArraySetCell
__________________
You will find everything u need :-

Last edited by Catastrophe; 10-31-2014 at 07:33.
Catastrophe is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-31-2014 , 07:38   Re: [Solved]Array natives
Reply With Quote #4

By the way: ArrayDeleteItem removes an item from the array entirely. It doesn't just remove the content of the item. It works like this:

Code:
new Array:a = ArrayCreate(); ArrayPushCell(a, 1); // Content: {1} ArrayPushCell(a, 0); // Content: {1,0} new Array:b = ArrayClone(a); // Content: {1,0} ArrayDeleteItem(b, 0); // Content: {0} ArrayGetCell(b, 0); // It looks like item 0 now contains 0, because the old item 1 shifts down new Array:c = ArrayClone(a); // Content: {1,0} ArrayDeleteItem(c, 1); // Content: {1} ArraySetCell(c, 1, 1); // Error: 1 is not a valid item
__________________
In Flames we trust!

Last edited by Nextra; 10-31-2014 at 07:38.
Nextra is offline
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 11-01-2014 , 05:09   Re: [Solved]Array natives
Reply With Quote #5

hmmm... ok now i unerstood it properly... thnx mate ;)
__________________
You will find everything u need :-
Catastrophe 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 02:18.


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