Jump to content

[Help] account


Fire Monkey

Recommended Posts

I'm writing an account system.
When the player login, sets all the database index and values on the ID player set as a table.

To get index of player is received from the table.

To set index and value of player, I used query and table again.

For example:

local data = {}

function getData(player, data)
	local id = playerid[player]
	if not id then return end
	return data[id][data]
end

function setData(player, data, value)
	local id = playerid[player]
	if not id then return end
	data[id][data] = value
	--query
	return true
end

Do you think it is better to set on the ID or on the player?

Or does it matter?

Link to comment
9 hours ago, iPrestege said:

Why don't you just set it on the player instead? And if you want to store it use the player serial to make it more efficient and no one can have more than one record since it's by serial.

Does using an ID or player make a difference in improving performance?

Link to comment
  • Scripting Moderators
10 hours ago, Fire Monkey said:

Does using an ID or player make a difference in improving performance?

No, 
but I suggest to to use the player element
you don't need to use another function to get the serial or id
just pass the player

Link to comment
  • Moderators
On 15/10/2020 at 16:26, Fire Monkey said:

Element do not look optimized.

Especially if there are more players.

There are not more items in the table playerid than if you do it directly in the table data.

Unless you load the entire database in to the memory, there is no direct performance benefit gained by the way you do it now (2x indexing is slower).

 

Edited by IIYAMA
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...