Is it possible to add player deaths to MySQL in TFS 0.2.4?
When player die i want to know who killed who and when.
I have table in mysql 'player_deaths' with:
in "creaturescript.xml" i have:
in "ffa-pvparena.lua" i have:
in "config.lua":
Anyone know why it doesn't work? I host e-pvp server and i want stats on page, but first i need to know who killed who and how many times.
When player die i want to know who killed who and when.
I have table in mysql 'player_deaths' with:
Code:
CREATE TABLE `player_deaths` (
`player_id` int(11) NOT NULL,
`time` bigint(20) unsigned NOT NULL default '0',
`level` int(11) NOT NULL default '1',
`killed_by` varchar(255) collate latin1_general_ci NOT NULL,
`is_player` tinyint(1) NOT NULL default '1',
KEY `player_id` (`player_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" script="login.lua"/>
<event type="logout" name="PlayerLogout" script="logout.lua"/>
<event type="preparedeath" name="FreeForAll-PVPArena" script="ffa-pvparena.lua"/>
</creaturescripts>
Code:
onPrepareDeath(cid, killer)
dofile("./config.lua")
if sqlType == "mysql" then
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
else -- sqlite
env = assert(luasql.sqlite3())
con = assert(env:connect(sqliteDatabase))
end
local byPlayer = FALSE
local killerName = escapeString(getCreatureName(killer))
if isPlayer(killer) == TRUE then
byPlayer = TRUE
elseif isPlayer(killer) ~= FALSE then
killerName = "field item"
end
query = assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUIDByName(getCreatureName(cid)) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. killerName .. "', " .. byPlayer .. ");"))
local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ";"))
local deathRecords = cursor:numrows()
con:close()
env:close()
end
Code:
------------------ THE FORGOTTEN SERVER CONFIG.LUA ------------------
-- Server Config --
mapName = "Zuriana"
mapAuthor = "Ziko"
houseRentPeriod = "monthly"
loginMessage = "Welcome to the Forgotten Server!"
serverName = "Forgotten"
ownerName = "Talaturen"
ownerEmail = "[email protected]"
url = "http://www.otland.net/"
location = "Sweden"
motd = "Welcome to the Forgotten Server!"
maxPlayers = "1000"
pzLocked = 60*1000
allowClones = 0
rateExp = 5
rateSkill = 3
rateLoot = 2
rateMagic = 3
rateSpawn = 1
worldType = "pvp"
serverSaveHour = 0
housePriceEachSQM = 1000
killsToRedSkull = 3
killsToBan = 5
deSpawnRange = 2
deSpawnRadius = 50
highscoreDisplayPlayers = 15
updateHighscoresAfterMinutes = 60
onePlayerOnlinePerAccount = "yes"
timeBetweenActions = 200
timeBetweenExActions = 1000
hotkeyAimbotEnabled = "yes"
maxMessageBuffer = 4
criticalHitChance = 3
displayGamemastersWithOnlineCommand = "no"
kickIdlePlayerAfterMinutes = 15
removeAmmoWhenUsingDistanceWeapon = "yes"
removeChargesFromRunes = "yes"
bankSystemStorageId = "300"
randomizeTiles = "yes"
defaultPriority = "high"
shutdownAtServerSave = "no"
freePremium = "no"
protectionLevel = 1
adminLogsEnabled = "no"
deathLosePercent = 10
-- Account Manager Config --
accountManager = "yes"
newPlayerChooseVoc = "no"
newPlayerSpawnPosX = 95
newPlayerSpawnPosY = 117
newPlayerSpawnPosZ = 7
newPlayerTownId = 1
newPlayerLevel = 1
newPlayerMagicLevel = 0
-- PVP Server Config --
displayOnOrOffAtCharlist = "no"
allowChangeOutfit = "yes"
noDamageToSameLookfeet = "no"
experienceByKillingPlayers = "no"
-- Database Config --
sqlHost = "localhost"
sqlUser = "root"
sqlPass = ""
sqlDatabase = "theforgottenserver"
sqliteDatabase = "forgottenserver.s3db"
sqlType = "mysql"
useMD5Passwords = "no"
-- Connection Config --
ip = "127.0.0.1"
port = 7171
loginTries = 500
retryTimeout = 30 * 1000
loginTimeout = 60 * 1000
---------------------------------------------------------------------
Anyone know why it doesn't work? I host e-pvp server and i want stats on page, but first i need to know who killed who and how many times.