Jump to content

[Question] About 'setElementData'


#Kz

Recommended Posts

  • Administrators

I think MySQL is the best option, especially if you are working with large amounts of data.

You might want to use setElementData for things which you only need to keep during a single session (data which doesn't have any need to be stored/recorded), and for data which you'd like to be synced across the server and all clients.

Personally though I'd stick with MySQL and use events (triggerServerEvent/triggerClientEvent) to sync data between clients/server

Edited by LopSided_
  • Like 1
Link to comment

It's useful to sync data with the server by setElementData for easier and faster access while the player is online.

To actually answer your question perfectly, you'll have to give us more information about the environment in which your are trying  to use setElementData/dbQuery.

  • Like 1
Link to comment
3 hours ago, LopSided_ said:

I think MySQL is the best option, especially if you are working with large amounts of data.

You might want to use setElementData for things which you only need to keep during a single session (data which doesn't have any need to be stored/recorded), and for data which you'd like to be synced across the server and all clients.

Personally though I'd stick with MySQL and use events (triggerServerEvent/triggerClientEvent) to sync data between clients/server

Thank you!

3 hours ago, NeXuS™ said:

It's useful to sync data with the server by setElementData for easier and faster access while the player is online.

To actually answer your question perfectly, you'll have to give us more information about the environment in which your are trying  to use setElementData/dbQuery.

Helpful!

Thanks for it.

Link to comment

What does element data have to do with mysql? :o

If you are talking about caching the information, then you should use a server-side table instead of element data.

You load things like player stats etc. when they login, you save it when they quit.

 

  • Like 2
Link to comment

Buddy, can you tell me how do you want to transfer your table from that script to an another without exporting a function (makes more junk), or calling an event? NO WAY. So if you need ANYTHING from that table, you'll have to call an exported function (which has to be on the same side), or call an event, which then recalls an another even with that table inside.

And btw, you need to secure only the client sided setElementData, you can't call that function, if it's only written in a server-sided script.

Edited by NeXuS™
Link to comment
3 minutes ago, NeXuS™ said:

Buddy, can you tell me how do you want to transfer your table from that script to an another without exporting a function (makes more junk), or calling an event? NO WAY. So if you need ANYTHING from that table, you'll have to call an exported function (which has to be on the same side), or call an event, which then recalls an another even with that table inside.

And btw, you need to secure only the client sided setElementData, you can't call that function, if it's only written in a server-sided script.

You said it. Events. When you need the data, you request it. No reason to sync all possible data with all players on the server whenever it changes.

Most data won't be needed clientside anyway. If you want to output it to the chat, you can do it serverside.

  • Like 3
Link to comment

Can you tell me then, why no one uses your method, and everyone uses setElementData instead of it? Because much easier to use, and it's not an issue in "security" at all, as you tried to mention. That link is about not trusting any data coming from a client (ex. a trigger from a client, because it can be RIGGED), and not even close to server sided setElementDatas.

Link to comment
3 minutes ago, NeXuS™ said:

Can you tell me then, why no one uses your method, and everyone uses setElementData instead of it? Because much easier to use, and it's not an issue in "security" at all, as you tried to mention. That link is about not trusting any data coming from a client (ex. a trigger from a client, because it can be RIGGED), and not even close to server sided setElementDatas.

Maybe you should read again what element data is and how it works.

https://wiki.multitheftauto.com/wiki/SetElementData

 

  • Like 1
Link to comment
45 minutes ago, Bonsai said:

Maybe you should read again what element data is and how it works.

https://wiki.multitheftauto.com/wiki/SetElementData

 

He's true about elementData, it's not safe to use due to security issues. The data of the element is synched between the client side and serverside which makes it even easier to change things in the serverside of the scripts.I wouldn't use this if it's about something that will be saved on quit, more like something with no value to the server.

  • Like 3
Link to comment

I think you misunderstood the purpose of element data @NeXuS™

Element data should be only used to sync data between the server and players. Such as scoreboard columns data (a example)

Except the bad security, element data has a bad impact on the server performance, as it is synced to all players.

Using tables is a much better and faster way to store data.

  • Like 2
Link to comment

setElementData is used for "storing" little insignificant to the server data temporarily. An example: 

You want people to be able to buy a map only after they win one first. You set element data when they win and then check if it's true. If so they can buy a map. And when someone else wins you set the element data for theprevious winner to nil.

 

I don't care about security and I'm sure that there are a thousand better ways to do the above but for me if it works it's fine. Just a quick example.

 

And about sql idk anything but it's used for storing data like total wins, map starts, coins etc. Has similar effect to setAccountData and it's better on security but harder to use it. 

Edited by koragg
  • Like 1
Link to comment

Damn,

I've never noticed any lag with elementData's. Is there a proof of any lag or any security bypass ?

Maybe it's because I'm alone on my script server but I've never noticed any lag. It's stange because I use a lot the elementData, for exemple for things like this :

objects_ =
{"bottle",
 "burger",
  -- etc
}

-- When the player connect for example :

for k,v in pairs(objects_) do
  setElementData(player,v,0)
end

Could it lag if there are many player ?

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