• 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
380
Reaction score
32
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

Leesne

i r peekay
Premium User
Joined
Dec 4, 2017
Messages
346
Solutions
34
Reaction score
188
Location
UK
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.
 
OP
OP
SixNine

SixNine

Active Member
Joined
Dec 12, 2018
Messages
380
Reaction score
32
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?
 

Leesne

i r peekay
Premium User
Joined
Dec 4, 2017
Messages
346
Solutions
34
Reaction score
188
Location
UK
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.
 

Leesne

i r peekay
Premium User
Joined
Dec 4, 2017
Messages
346
Solutions
34
Reaction score
188
Location
UK
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:
OP
OP
SixNine

SixNine

Active Member
Joined
Dec 12, 2018
Messages
380
Reaction score
32
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
 

slaw

MyAAC Creator
Premium User
Joined
Aug 27, 2007
Messages
3,353
Solutions
103
Reaction score
807
Location
Germany
GitHub
slawkens
Twitch
PL_Flamaster
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.
 

Leesne

i r peekay
Premium User
Joined
Dec 4, 2017
Messages
346
Solutions
34
Reaction score
188
Location
UK
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.
 

slaw

MyAAC Creator
Premium User
Joined
Aug 27, 2007
Messages
3,353
Solutions
103
Reaction score
807
Location
Germany
GitHub
slawkens
Twitch
PL_Flamaster
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.
 

Leesne

i r peekay
Premium User
Joined
Dec 4, 2017
Messages
346
Solutions
34
Reaction score
188
Location
UK
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.
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
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
 
OP
OP
SixNine

SixNine

Active Member
Joined
Dec 12, 2018
Messages
380
Reaction score
32
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
 
Top