Jump to content

Recommended Posts

  • Root Admin
Posted

array mds_get_resource_count()

Returns an associative array with the resources a user has in their inventory and the count.

The returned format is:

array(42) {
  'Aromatic herbs' =>
  int(98)
  'Basic Iron Ingot' =>
  int(4)
  'Bones' =>
  int(2)
  'Branches' =>
  int(109)
  'Bushies' =>
  int(50)
  'Clay' =>
  int(18)
}

If the user has no resources this will return an empty array. The keys are the resource name and the value is the number of resources.

 

Posted

A quick example how to loop through the associative array and get all the values displayed

 


@vb = mds_get_resource_count();

//@vb is the associative array you get from the function
//in the foreach loop we go through @vb
//with @vk we assign the k.ey of @vb so in this case the name of the resource
//@vv is the va.lue to @vk


foreach (@vb as @vk => @vv) {
    echo "Resource: @vk, Amount: @vv<br>";
}

 

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.1k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...