• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Cannot configure an event in CreatureScripts

melegy

Devils
Joined
Dec 5, 2012
Messages
178
Reaction score
2
Location
Egypt
Hello
when char die there's text message (you are dead) so i tried to put this funcation
Code:
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
server say
Error cannot not vaild type for creature event.
any help
regards.
 
Where did you put that, in what script? (Please paste the whole script here)
What Engine are you using? 0.4/1.X
 
Here you are
Code:
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 = 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

I'm using Devland version 8.1
 
Could be those enums arent in use on old distros, try to replace
MESSAGE_EVENT_ADVANCE with 19.
Could also be MSG_EVENT_ADVANCE if its avesta based.
 
where did you get this? never heard of it before. Probably better to use tfs or otx (which is based on tfs) as you can get way more support when facing problems like this
It's been a month searching for mystic spirit 0.2.11.693 source code for client 8.1 but I cannot found ,this will solve my problems with compil.
 
Back
Top