# Making new table/database

Hi! First of all, I would thank you all for spending time to help me with my previous questions.

Now, I wanted to make something of a DarkRP ELO system, where after you kill someone, a variable will go up, and for the one who died, the variable will reset to a specific number. The part I’m stuck in? How do I even create a table like that for the game to read from and to determine which variable goes where and how much a variable it will/can deduct? I’ve read something about table contructors here (http://www.lua.org/pil/3.6.html) but it didn’t help me much. Any opinions? Thanks in advance.

Depends what number you want to reset their number to, if it’s a constant, then you don’t need a table.

``````

function SetValuesSpawn( ply )
ply.KillValue = 0;
end

function KillValueDeath( victim, inflictor, attacker )
if ( victim:IsValid() and attacker:IsValid()) then
victim.KillValue = 0
attacker.KillValue = attacker.KillValue + 1
end
end

``````

Something like that?

What do you want to use the table for, write it in psuedocode

Thanks for your reply. I wanted to use the table because I assume that a table was used to collect player data, like the player.GetAll and DarkRP money.
The ELO system I was speaking of is related to this ( http://en.wikipedia.org/wiki/Elo_rating_system ), but I’m using it under a different formula that will calculate the variable changes.

Sorry if I ask incredibly stupid questions, I’m very new to Lua, please be gentle when teaching.

Can you post the algorithm you will be using?
Explain want you want to make in Lua in detail

[editline]7th May 2014[/editline]

Tables are used for allot of things, but depending on your situation depends on if you need tables, you wouldn’t need tables for having a player value, but if you wanted to save this value so if the server closes or something, and you could retrieve their value, then you would use a table so you could store their value in a txt or MySQL database

Well, I wanted to make something like a score/rating system, that’s why I posted the ELO rating system link in my previous post. When a player is spawned in the server, they would get specific “Threat Rating” in accordance to their job type. If they kill a player, their “Threat Rating” will raise, sort of like winning a match in chess or something. But if they die, their “Threat Rating” will go down(scrap the part where it will reset, I notice the formula would be useless if the levels resets every death), like lose a match.

Assuming that a player with a Threat Rating of 50, they kill someone with a Threat Rating of 100, their rating will go up higher because that certain someone who they had killed had a higher rating, stating that the person who died was potentially stronger/better at killing people than the kill who had a rating of 50.

The formula I am planning to use is this formula. ( http://metinmediamath.wordpress.com/2013/11/27/how-to-calculate-the-elo-rating-including-example/ )

Forgot to mention that a player’s Threat Rating will reset if they change their job(which is, in my opinion, quite easy to abuse with, but that’s going to be another matter which I will attempt to solve later).

bump? I still don’t know how to do this.

It uses Frags as the variable to keep track of. If a number exists of the current frags a player has, it strips the weapons from previous level ( if variable is true ), then gives them new weapons for the current level, sets a variable so the server can keep track of current level.

The PlayerLoadout spawns them on respawn, while PlayerDeath spawns them instantly. It can be made shorter.

If that doesn’t help, I have a few more.