Windows PlayerDeath problem

Discussion in 'Support' started by Hanoger, Apr 9, 2012.

  1. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247
    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:eek:nDeath
    [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>
    [/lua]

    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
    [/lua]

    Thanks for help!
    Last edited: Apr 9, 2012
  2. Lanceq

    Lanceq Banned User

    Joined:
    Dec 19, 2011
    Messages:
    1,737
  3. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247
    Ah yes, forgot it, TFS 0.2.11pl2
  4. Lanceq

    Lanceq Banned User

    Joined:
    Dec 19, 2011
    Messages:
    1,737
    [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[/lua]
  5. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247
    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
    [/lua]
  6. Lanceq

    Lanceq Banned User

    Joined:
    Dec 19, 2011
    Messages:
    1,737
    Show error, btw. u not repped me yet :>
  7. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247
    Can't add rep, I already added it to u some time before, when I will can I will add ofc :) And no error in console :/
  8. Lanceq

    Lanceq Banned User

    Joined:
    Dec 19, 2011
    Messages:
    1,737
    [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; [/sql]
  9. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247
    PHP:
    Unknown column 'loss_containers' in 'field list'
  10. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247
    Please, need quick fix :/
  11. Royal Inferno

    Royal Inferno Member

    Joined:
    Apr 5, 2012
    Messages:
    459
    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[/LUA]

    This is a simple script without a holy effect, but just tell me if it works
    Last edited: Apr 10, 2012
  12. Wutang

    Wutang Banned User

    Joined:
    Jan 10, 2012
    Messages:
    158
    Well this script just promote you ? ofc you lose items,
  13. Royal Inferno

    Royal Inferno Member

    Joined:
    Apr 5, 2012
    Messages:
    459
    Yeah, kind of realized that when I was sitting on duh toilet and I was like: nuh, ppl wl git angreh at meh :mad:
  14. Royal Inferno

    Royal Inferno Member

    Joined:
    Apr 5, 2012
    Messages:
    459
    And to the thread owned, again, that script doesn't have any holy effect, but, we will change that, if the script worked.
  15. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247
    I'm at school now, I'll test it when I get home, I'll let you know...
  16. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247
    Still same, It's problem with the PlayerDeath that qanti posted to me
  17. Hanoger

    Hanoger New Member

    Joined:
    Mar 7, 2011
    Messages:
    247

Share This Page