• 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!

Add player deaths to mysql?

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,966
Solutions
99
Reaction score
3,383
Location
Poland
GitHub
gesior
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:
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;
in "creaturescript.xml" i have:
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>
in "ffa-pvparena.lua" i have:
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
in "config.lua":
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.
 
So i have another question.

I want make PvP Arena. How can i make it? It is possible on newest sources? Becouse i think that Forgotten haven't it?
 
Last edited:
So i have another question.

I want make PvP Arena. How can i make it? It is possible on newest sources? Becouse i think that Forgotten haven't it?
Did u try to copy script from 0.2.4?
Where can i download 0.2.5 version? :>
EDIT:
Ok. I found 0.2.5 source and DevC++ 1.2 by Talaturen. Updated to newest SVN and it works! Thank you very much!
If someone else need help with DeathList send me priv msg on forum.
 
Last edited:
Back
Top