• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ player_deaths stores only one death per player

SixNine

Active Member
Joined
Dec 12, 2018
Messages
442
Reaction score
40
TFS 1.2

Hello,
i noticed that in database my player_deaths table stores only one death per player

table structure
381a8374a171982b859e12b8b75642c3.png
 
Solution
player_id_2 might mean this index maybe in player_deaths
ebecb08a4ef21d9d862fcdc53029468e.png
This is how mine looks.

Try to emulate it?

Untitled.png
If you had actually looked it up, you would see the issue.

It must contain a unique value for each row of data.
You setting it to player_id, means player_id must be a unique value.

You can put a primary key pretty much where ever you want. but the data in it must be unique.
As you are wanting multiple deaths per character setting player_id as primary key clearly isn't the right solution for this table.
 
If you had actually looked it up, you would see the issue.


You setting it to player_id, means player_id must be a unique value.

You can put a primary key pretty much where ever you want. but the data in it must be unique.
As you are wanting multiple deaths per character setting player_id as primary key clearly isn't the right solution for this table.
so has to be like this?
 
If I run into an area on a level 1000 mage and kill 10 level 8's in 1 hit.
They will all die at the same time. So no.
 
Coding isn't just about reusing people's codes and databases. Sometimes its about thinking outside the box.

Databases don't need primary keys but its highly recommended.
Look at your other tables and see what they use as unique identifiers or primary keys
 
Last edited:
Coding isn't just about reusing people's codes and databases. Sometimes its about thinking outside the box.

Databases don't need primary keys but its highly recommended.
Look at your other tables and see what they use as unique identifiers or primary keys
in other tables they have id as primary, so idk
 
I think it might be some other script interfering with your player_deaths table.

Search for "player_deaths" in your lua scripts, maybe some other script is deleting your deaths.

Other option you can check, is to log if query is executed.

To do so, after:
Code:
local playerGuid = player:getGuid()

Add:
Code:
print("SLAW-DEBUG:" .. playerGuid .. ", " .. os.time() .. ", " .. player:getLevel() .. ", " .. db.escapeString(killerName) .. ", " .. byPlayer .. ", " .. db.escapeString(mostDamageName) .. ", " .. byPlayerMostDamage .. ", " .. (unjustified and 1 or 0) .. ", " .. (mostDamageUnjustified and 1 or 0) .. ")")

Then try to kill in game someone more times, and see if you see in console SLAW-DEBUG more than once.
 
You can only have a unique value as primary key.
So if player ID is set as primary key, in the players_deaths there will only ever be 1 entry for that user as this is the unique id (primary key) and cannot be any more entries.

I was trying to let him come to the conclusion himself. Teach a man to fish and all that.

The best way to fix it is to remove primary key.

Or clear death list and make a new field 11 int called ID and give it primary key.
 
You can only have a unique value as primary key.
So if player ID is set as primary key, in the players_deaths there will only ever be 1 entry for that user as this is the unique id (primary key) and cannot be any more entries.

I was trying to let him come to the conclusion himself. Teach a man to fish and all that.

I understand, but he is using original SQL table from TFS, and also almost unmodified script. So the reason needs to be somewhere else.
 
This is my last post here, as I really can't be bothered any more, I've tried to show you the way and all I see if someone who wants stuff given without trying, I literally spelt it out in 3 posts on what to do.

a simple search on the internet on how to modify DBs.

ALTER TABLE player_deaths DROP PRIMARY KEY;

"cant"

or do what I said in the other post and make a new column.
 
Didnt solved the issue, still shows only one death so its not db anymore
It's definitely a database issue.

By default, there is 5 player deaths listed in the database, per character. (regulated by your lua script)
But since your database, for whatever reason, has a primary key on player_id, you're forcing the database to have a single entry of that player.

Remove the primary key restriction in player_deaths, and your issue will go away.

Untitled.png
 
It's definitely a database issue.

By default, there is 5 player deaths listed in the database, per character. (regulated by your lua script)
But since your database, for whatever reason, has a primary key on player_id, you're forcing the database to have a single entry of that player.

Remove the primary key restriction in player_deaths, and your issue will go away.

View attachment 62437
Thats exactally how it is
2dfff8990a8605abbdb4daf545c4208c.png
 
Back
Top