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

Player deaths not working in 2.5

mikeware

New Member
Joined
Jul 17, 2007
Messages
338
Reaction score
0
Location
Brazil
Hey, i guess the table player_deaths not working, or the script.. player died in my server but nothing changed into the table, somebody know what's wrong?

thanks
 
I tested it now, and it worked for me.

Check creaturescripts.xml and check that the script is correct (maybe try do replace it with the one in the SVN).

Also check that maxPlayerDeaths > 0 in config.lua.
 
everything is all right, maybe the script is wrong... there's a new in the SVN ?

edit: I checked in the SVN sources and the newest playerdeath.lua is the one im using that simply it's not working, I die in the server and first the message "you are dead" don't appear, it was supposely to appear as I can see in the script, only the message you downgraded to lv x to y and nothing changes in the table player_deaths too =/
 
Last edited:
Did you check creaturescripts.xml?

Yes, it's all right, at least i guess.
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="death" name="PlayerDeath" script="playerdeath.lua"/>
</creaturescripts>

here's the playerdeath script:
Code:
function onDeath(cid, corpse, killer)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
	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
	query = assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUIDByName(getCreatureName(cid)) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. getCreatureName(killer) .. "', " .. isPlayer(killer) .. ");"))
	local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ";"))
	local deathRecords = cursor:numrows()
	while deathRecords > maxDeathRecords do
		delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. " ORDER BY `time` LIMIT 1;"))
		deathRecords = deathRecords - 1
	end
	con:close()
	env:close()
end
 
Last edited:
Back
Top