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

Windows PlayerDeath problem

Hanoger

Member
Joined
Mar 7, 2011
Messages
247
Reaction score
6
Hello, everything worked fine (what I know, haven't died before)
But now, console says this when I, or someone else die, and the it won't save players deaths (u can't see it at players info):
Lua:
[09/04/2012 12:21:28] Lua Script Error: [CreatureScript Interface] 
[09/04/2012 12:21:28] data/creaturescripts/scripts/PlayerDeath.lua:onDeath
[09/04/2012 12:21:28] data/creaturescripts/scripts/PlayerDeath.lua:22: attempt to concatenate local 'byPlayer' (a boolean value)
[09/04/2012 12:21:28] stack traceback:
[09/04/2012 12:21:28] [C]: in function '__concat'
[09/04/2012 12:21:28] data/creaturescripts/scripts/PlayerDeath.lua:22: in function <data/creaturescripts/scripts/PlayerDeath.lua:3>

I don't know where is the problem, I don't see any problem here, my PlayerDeath.lua:
Lua:
dofile("./config.lua")

function onDeath(cid, corpse, killer)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Fail! You are dead.")
	if deathListEnabled == "yes" then
		if sqlType == "mysql" then
			env = luasql.mysql()
			sql = env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort)
		else -- sqlite
			env = luasql.sqlite3()
			sql = env:connect(sqliteDatabase)
		end
		local byPlayer = FALSE
		if killer == FALSE then
			killerName = "field item"
		else
			if isPlayer(killer) == TRUE then
				byPlayer = TRUE
			end
			killerName = getCreatureName(killer)
		end
		sql:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");")
		local result = sql:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
		local deathRecords = numRows(result)
		if sqlType == "mysql" then
			while deathRecords > maxDeathRecords do
				delete = sql:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;")
				deathRecords = deathRecords - 1
			end
		else
			while deathRecords > maxDeathRecords do
				delete = sql:execute("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
				deathRecords = deathRecords - 1
			end
		end			
		sql:close()
		env:close()
	end
end

Thanks for help!
 
Last edited:
Lua:
dofile("./config.lua")
 
function onDeath(cid, corpse, killer)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
	if deathListEnabled == "yes" then
		if sqlType == "mysql" then
			env = luasql.mysql()
			sql = env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort)
		else -- sqlite
			env = luasql.sqlite3()
			sql = env:connect(sqliteDatabase)
		end
		local byPlayer = 0
		if not killer or killer == 0 then
			killerName = "field item"
		else
			if isPlayer(killer) == TRUE then
				byPlayer = 1
			end
			killerName = getCreatureName(killer)
		end
		sql:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");")
		local result = sql:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
		local deathRecords = numRows(result)
		if sqlType == "mysql" then
			while deathRecords > maxDeathRecords do
				delete = sql:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;")
				deathRecords = deathRecords - 1
			end
		else
			while deathRecords > maxDeathRecords do
				delete = sql:execute("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
				deathRecords = deathRecords - 1
			end
		end			
		sql:close()
		env:close()
	end
end
 
Works, now I can see my dead in database and so, thx, rep+ :) But, another error occured, my bless don't work now, when I die i'm loosing equipment :/
Using this script:
Lua:
function onSay(cid, words, param)
    if getPlayerBlessing(cid, 1) or getPlayerBlessing(cid, 2) or getPlayerBlessing(cid, 3) or getPlayerBlessing(cid, 4) or getPlayerBlessing(cid, 5) then
        doPlayerSendCancel(cid,'You have already got one or more blessings!')
    else
        if doPlayerRemoveMoney(cid, 50000) == TRUE then
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
            doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE,'You have been blessed by the gods!')
        else
            doPlayerSendCancel(cid, "You need 5 crystal coins to get blessed!")
        end
    end    
    return 1
end
 
SQL:
UPDATE `players` SET `loss_experience` = 100; 
UPDATE `players` SET `loss_mana` = 100; 
UPDATE `players` SET `loss_skills` = 100; 
UPDATE `players` SET `loss_containers` = 100; 
UPDATE `players` SET `loss_items` = 100;
 
If the script is right, you shouldn't lose items? Try a new script like this maybe:
(This script was made by me, and i'm not pro, but it should work.
Lua:
function onSay(cid, words, param)

		if		doPlayerRemoveMoney(cid, 50000) then
			doPlayerAddBlessing(cid, 1, 2, 3, 4, 5)
elseif
				getPlayerBlessing(cid) >= 1 then
					doSendPlayerCancel(cid, "You have already been blessed!")
				doSendMagicEffect(getCreaturePosition(cid), 2)
else
			doPlayerSendCancel(cid, "You don't have enough money")
				doSendMagicEffect(getCreaturePosition(cid), 2)
		end
return TRUE
end

This is a simple script without a holy effect, but just tell me if it works
 
Last edited:
Back
Top