AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved]Array natives (https://forums.alliedmods.net/showthread.php?t=250816)

Catastrophe 10-31-2014 02:02

[Solved]Array natives
 
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.

Nextra 10-31-2014 07:25

Re: Array natives
 
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.

Catastrophe 10-31-2014 07:31

Re: Array natives
 
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

Nextra 10-31-2014 07:38

Re: [Solved]Array natives
 
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

Catastrophe 11-01-2014 05:09

Re: [Solved]Array natives
 
hmmm... ok now i unerstood it properly... thnx mate ;)


All times are GMT -4. The time now is 17:45.

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