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

TFS 0.3.6 Isn't calling a script

filipus

Member
Joined
Dec 31, 2010
Messages
229
Reaction score
12
So, I want to call a script when the character dies but I've been going around this for hours and I haven't been able to do anything!
Can anyone help??

Creaturescripts
Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" event="script" value="login.lua"/>
<event type="login" name="FirstItems" event="script" value="firstitems.lua"/>
<event type="login" name="Lowlevellock" event="script" value="lowlevellock.lua"/>
<event type="login" name="fraglook_register" event="script" value="fraglook.lua"/>
<event type="advance" name="playeradvance" script="advance.lua"/>
<event type="advance" name="Addons" event="script" value="Addons.lua"/>
<event type="look" name="fraglook" event="script" value="fraglook.lua"/>
<event type="death" name="DeathBroadcast" event="script" value="deathBroadcast.lua"/>
<event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
<event type="think" name="Idle" event="script" value="idle.lua"/>
<event type="death" name="Deathcheck" event="script" value="death.lua"/>
</creaturescripts>


Login.lua
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "A sua ultima visita foi em " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Por favor escolha seu outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Olá, ao que parece o seu nome foi bloqueado, qual gostaria que fosse o novo nome?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Olá, escreva 'account' para managear a sua conta ou escreva 'cancel' para recomeçar.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Olá, escreva 'account' para criar uma conta ou escreva 'recover' para recuperar uma conta.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end


  
    registerCreatureEvent(cid, "kill")
    registerCreatureEvent(cid, "onPrepareDeath")
    registerCreatureEvent(cid, "PlayerLogout")
    registerCreatureEvent(cid, "playeradvance")
    registerCreatureEvent(cid, "onPrepareDeath")
    registerCreatureEvent(cid, "deathBroadcast")
    registerCreatureEvent(cid, "DeathBroadcast")
    registerCreatureEvent(cid, "OnLogin")
    registerCreatureEvent(cid, "death")
    registerCreatureEvent(cid, "onDeath")
  

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    return true
end



death.lua THE SCRIPT I WANT TO CALL
Code:
-- config
local newlevel = 129 -- level após reset
local newexp = 34963299 -- nova experiencia após reset
local newskulls = 0 -- skulls apos reset
local posicionX = 965
local posicionY = 1017
local posicionZ = 6



-- end config


function onDeath(cid, corpse, deathList)
    local playerid = getPlayerGUID(cid)
    db.executeQuery("UPDATE `players` SET `level` = ".. newlevel ..",`experience` = ".. newexp ..",`skull` = ".. newskulls ..",`skulltime` = "..newskulls..",`posx` = "..posicionX..",`posy` = "..posicionY..",`posz` = "..posicionZ.." WHERE `id` = ".. playerid ..";")
    return true
end




Please help ):
 
Last edited:
Register the name you used in creaturescripts.xml.

<event type="death" name="Deathcheck" event="script" value="death.lua"/>

registerCreatureEvent(cid, "Deathcheck")
 
Register the name you used in creaturescripts.xml.

<event type="death" name="Deathcheck" event="script" value="death.lua"/>

registerCreatureEvent(cid, "Deathcheck")

Did this, still doesn't call.
Maybe it is a problem in the db.executeQuery?
Is there any way I can print a message to test if the function is even being called?
 
OK SORRY FOR DOUBLE POST, BUT THE FUNCTION IS BEING CALLED, THE PROBLEM IS IN THE db.executeQuery.

I added a doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "THIS WORKS GRAWW") and it printed it on the screen.
Im using SQLite. I love you guys, thanks so much for helping!
 
No error.

If I change to db.Query it says this
Description:
[07/03/2014 15:43:12] data/creaturescripts/scripts/death.lua:17: attempt to call field 'Query' (a nil value)
[07/03/2014 15:43:12] stack traceback:
[07/03/2014 15:43:12] data/creaturescripts/scripts/death.lua:17: in function <data/creaturescripts/scripts/death.lua:14>

So I suppose query its only 0.4 upward.
 
Back
Top