function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
local config = {
addItem = 1685 -- heart id
itemDesc = "You received this when you killed "..getPlayerName(cid).." when "..sex.." was level ["..getPlayerLevel(cid).."]."
if isPlayer(killer) == TRUE then
sex = getPlayerSex(cid)
if sex == 0 then
"she"
else
"he"
doPlayerAddItem(killer, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc)
end
end
end
return TRUE
end
[16/05/2009 11:52:31] luaDoPlayerAddItem(). Player not found
local config = {
addItem = 1685, -- heart id
itemDesc = {
"You received this when you killed",
-- Name
"when",
-- Sex
"was level"
-- Level
}
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
if isPlayer(killer) == TRUE then
sex = getPlayerSex(cid)
if sex == 0 then
"she"
else
"he"
end
doPlayerAddItem(killer, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc[1].." "..getPlayerName(cid).." "..config.itemDesc[2].." "..sex.." "..config.itemDesc[3].." "..getPlayerLevel(cid)..".")
return TRUE
end
local config = {
addItem = 1685, -- heart id
itemDesc = {
"You received this when you killed",
-- Name
"when",
-- Sex
"was level"
-- Level
}
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
if isPlayer(mostDamageKiller) == TRUE then
if getPlayerSex(cid) == 0 then
"she"
else
"he"
end
doPlayerAddItem(mostDamageKiller, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc[1].." "..getPlayerName(cid).." "..config.itemDesc[2].." "..sex.." "..config.itemDesc[3].." "..getPlayerLevel(cid)..".")
return TRUE
end
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
local config = {
addItem = 1685 -- heart id
itemDesc = "You received this when you killed "..getPlayerName(cid).." when "..sex.." was level ["..getPlayerLevel(cid).."]."
}
if isPlayer(killer) == TRUE then
sex = getPlayerSex(cid)
if sex == 0 then
"she"
else
"he"
doPlayerAddItem(killer, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc)
end
end
return TRUE
end
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
local config = {
addItem = 1685 -- heart id
itemDesc = "You received this when you killed "..getPlayerName(cid).." when "..sex.." was level ["..getPlayerLevel(cid).."]."
}
if isPlayer(killer) == TRUE then
sex = getPlayerSex(cid)
if sex == 0 then
"she"
else
"he"
end
doPlayerAddItem(killer, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc)
end
return TRUE
end
local config = {
deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
sqlType = getConfigInfo('sqlType'),
maxDeathRecords = getConfigInfo('maxDeathRecords')
addItem = 1685 -- heart id
itemDesc = "You received this when you killed "..getPlayerName(cid).." when "..sex.." was level ["..getPlayerLevel(cid).."]."
}
config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL
function onDeath (cid, corpse, lastHitKiller, mostDamageKiller)
sex = 0
if isPlayer(lastHitKiller) == TRUE then
if getPlayerSex(cid) == 0 then
sex = "she"
else
sex = "he"
end
doPlayerAddItem(lastHitKiller, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc)
end
if(config.deathListEnabled ~= TRUE) then
return
end
local hitKillerName = "field item"
local damageKillerName = ""
if(lastHitKiller ~= FALSE) then
if(isPlayer(lastHitKiller) == TRUE) then
hitKillerName = getPlayerGUID(lastHitKiller)
else
hitKillerName = getCreatureName(lastHitKiller)
end
if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
if(isPlayer(mostDamageKiller) == TRUE) then
damageKillerName = getPlayerGUID(mostDamageKiller)
else
damageKillerName = getCreatureName(mostDamageKiller)
end
end
end
db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
if(rows:getID() ~= -1) then
local amount = rows:getRows(true) - config.maxDeathRecords
if(amount > 0) then
if(config.sqlType == DATABASE_ENGINE_SQLITE) then
for i = 1, amount do
db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
end
else
db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
end
end
end
end
dofile("./config.lua")
local config = {
addItem = 1685 -- heart id
itemDesc = "You received this when you killed "..getPlayerName(cid).." when "..sex.." was level ["..getPlayerLevel(cid).."]."
}
function onDeath(cid, corpse, killer)
sex = 0
if isPlayer(killer) == TRUE then
if getPlayerSex(cid) == 0 then
sex = "she"
else
sex = "he"
end
doPlayerAddItem(killer, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc)
end
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
if deathListEnabled == "yes" then
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
if killer == FALSE then
killerName = "field item"
else
if isPlayer(killer) == TRUE then
byPlayer = TRUE
end
killerName = getCreatureName(killer)
end
assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");"))
local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";"))
local deathRecords = numRows(cursor)
if sqlType == "mysql" then
while deathRecords > maxDeathRecords do
delete = assert(con: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 = assert(con: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
con:close()
env:close()
end
end
local config = {
addItem = 1685, -- heart id
itemDesc = {
"You received this when you killed",
-- Name
"when",
-- Sex
"was level"
-- Level
}
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
if isPlayer(mostDamageKiller) == TRUE then
if getPlayerSex(cid) == 0 then
sex = "she"
else
sex = "he"
end
doPlayerAddItem(mostDamageKiller, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc[1].." "..getPlayerName(cid).." "..config.itemDesc[2].." "..sex.." "..config.itemDesc[3].." "..getPlayerLevel(cid)..".")
return TRUE
end
[17/05/2009 16:46:30] [Warning - Event::loadScript] Can not load script (data/creaturescripts/scripts/2.lua)
[17/05/2009 16:46:30] data/creaturescripts/scripts/2.lua:12: '}' expected (to close '{' at line 1) near 'function'
[17/05/2009 16:46:43] [Warning - Event::loadScript] Can not load script (data/creaturescripts/scripts/2.lua)
[17/05/2009 16:46:43] data/creaturescripts/scripts/2.lua:24: 'end' expected (to close 'function' at line 13) near '<eof>'
[17/05/2009 16:48:34] Lua Script Error: [CreatureScript Interface]
[17/05/2009 16:48:34] data/creaturescripts/scripts/2.lua:onDeath
[17/05/2009 16:48:34] luaDoSetItemSpecialDescription(). Item not found
It won't work Zonet, because:
if isPlayer(killer) == TRUE then
sex = getPlayerSex(cid)
if sex == 0 then
"she"
else
"he"
end
what is it? ;p She he? but what? maybe 'sex = "she"?
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
local config = {
addItem = 1685 -- heart id
itemDesc = "You received this when you killed "..getPlayerName(cid).." when "..sex.." was level ["..getPlayerLevel(cid).."]."
}
sex = getPlayerSex(cid)
if sex == 0 then
"she"
else
"he"
end
if isPlayer(mostDamageKiller) == TRUE then
doPlayerAddItem(mostDamageKiller, config.addItem)
doSetItemSpecialDescription(config.addItem, config.itemDesc)
end
return TRUE
end
if getPlayerSex(cid) == 0 then
sex = "she"
else
sex = "he"
end