Jump to content

Temporary data storage


Recommended Posts

Hi all! As i know MTA has two main ways for temporarily storing data. First: elementData. Second: server's table. Ok, i want create something big (gamemode with inventory, etc), but elementData is slow and very expensive for CPU and i don't want use this way. Ok, temporarily server's table is fastest than elementData and not so expensive. But how i can get value from server's table in client-side script (for GUI, etc)? Is in this situation third way if i can't? Sorry for my grammar mistakes if they're.

Link to comment

You've got the table in the server.

Then when a client opens the GUI, you trigger a server event where you select the values u want from the table and then trigger a client event to return the info.

And yes, it would be better than elementData, it'd save CPU and bandwith.

Simply, why would a player need to know the inventory of every player on the server? - It's unnessesary.

Link to comment
myTable  = { 
addCommandHandler("test", function() 
for k,v in ipairs(getElementsByType("player")) do 
triggerClientEvent(resourceRoot, "sendTable", resourceRoot, myTable) 


addEventHandler("sendTable", root, function(table) 
      for k,v in ipairs(table) do 

Use test. It will output all table containts. This was just a example how to trigger a table to client side and loop it.

I suggest you to do like this.

Link to comment

Anubhav, thanks for answer. I already made and use this scheme. But my table is empty when server start and only when player log in it generate subtables look like "items", "properties", etc. And result of #MyTable always is 0. It have fields, i get values from those fields but when i want get length of table, i get 0. Why?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...