Jump to content

Bug related to deleting arrays in @storage


rikstar

Recommended Posts

I encountered this bug in MDscript, while I was working on a project myself. I needed to delete all my saved variable in @storage to start with a clean blank. So I did this:

 

 

@vo = mds_storage("SECRET CODE NOT ACTUAL CODE","aoau");

@storage[@vo] = 0;

 

And I got the following warnings:

 

Warning: Cannot use a scalar value as an array in /home/magicdue/public_html/dlg/dlg.rpcqdocread.php(183) : eval()'d code on line 19

Warning: Cannot use a scalar value as an array in /home/magicdue/public_html/dlg/dlg.rpcqdocread.php(183) : eval()'d code on line 24

Warning: Cannot use a scalar value as an array in /home/magicdue/public_html/dlg/dlg.rpcqdocread.php(183) : eval()'d code on line 30

 

I was too lazy to use the good way to do it. The good way is too look how many object are in the array that is in @storage[@vo] and then delete every object in the array. What I did was deleting the whole array right now.

 

I think that this gave those errors/ warning, because mds_storage() give a certain @storage[] object free to use for the player. This is used, so that you can only edit your own array. Or atleast the arrays that you have created or that you know the name of. But I just deleted the array that I got acces to, and the game gives me acces to that array. So nothing exist there and thus I get an error.

 

Hopefully this is helpful in any way, else just ask away.

 

EDIT: WARNING this is irreversible, if this is done you can't ever use that word as a storage ID.

^^This is not true read edit 2.

 

EDIT2:

Did some more research on this and came to a different conclusion. This isn't a bug, but there is something different going on.

 

@vo = mds_storage("SECRET CODE NOT ACTUAL CODE","aoau");

@storage[@vo]= 0;
@storage[@vo] = array("name"=>uv("name"), "stage"=>0);
 
 
echo @storage[@vo][name];

 

So basically when you try this code you/ I mainly use it for this:

 

@vo = mds_storage("SECRET CODE NOT ACTUAL CODE","aoau");

@storage[@vo][uv("name")] = 0;

 The above code is used to store data in an array and every player has it's own set of variabes in this array.

 

But what I did in the first code is changing @storage[@vo] from an array to a normal variable. So to undo this you only have to change @storage[@vo] into an array again. Do this with the following code:

 

 

@vo = mds_storage("SECRET CODE NOT ACTUAL CODE","aoau");

@storage[@vo] = array();

 

This will change @storage[@vo] into an array again.

 

Conclusion:

This isn't a bug so sorry for putting it in the bug list. But it is something to watch out for. Now that when you are creating a new @storage["ID"] that it always is an array.

This topic should be moved to the general MD script page.

Edited by rikstar
Link to comment
Share on other sites

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Forum Statistics

    17.5k
    Total Topics
    182.5k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...