• 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 1.X+ function onkill tfs 1.5 dont work

Izaack

Member
Joined
Jun 18, 2012
Messages
80
Solutions
1
Reaction score
21
Location
México
Hi Otland, I have a problem with the onkill function. I don't know if I'm setting it up correctly.

LUA:
function onKill(cid, target, lastHit)
if player:isPlayer(cid) and player:isPlayer(target) then
        print("execute action")
        end
    return true
end

The code doesn't print to the console. I don't know if I'm not entering it correctly. Could you help me?

add creaturescripts.xml and login.lua
LUA:
    <event type="kill" name="skull_kill" script="skull_kill.lua" />
    player:registerEvent("skull_kill")

My bad, it was just this: RESOLVED!!!
 
Last edited by a moderator:
Solution
The script is fine, the engine is also fine, it simply has an onPrepareDeath event that doesn't allow the player to die. This usually happens when there's a custom PvP system that handles the player's death in a very specific way from Lua.

The topic should be closed, I already spoke with @Izaack privately on Discord, and it's because of that, I even helped him with it myself.

In short, it's a simple onPrepareDeath event that returns false whenever it's player versus player.
LUA:
local KillEvent = CreatureEvent("TasksKill")

function KillEvent.onKill(player, target)
  if not target or target:isPlayer() or target:getMaster() then
    return true
  end

  print("its working")

  return true
end


KillEvent:type("kill")
KillEvent:register()

put this file in /data/scripts
 
LUA:
local KillEvent = CreatureEvent("TasksKill")

function KillEvent.onKill(player, target)
  if not target or target:isPlayer() or target:getMaster() then
    return true
  end

  print("its working")

  return true
end


KillEvent:type("kill")
KillEvent:register()

put this file in /data/scripts
no work bro i dont print in console when kill player
 
no work bro i dont print in console when kill player
because of top code you see target:isPlayer? this check if creature killed is player or has master (is a summon) remove those leave only if not target and add or target:isMonster() if its ment to be pvp script and leave target:getMaster() altough if we check for monster we dont need alraedy
 
The script is correct here, just go to data/scripts/filename.lua using revscriptsys.
LUA:
local killEvent = CreatureEvent("skull_kill")
function killEvent.onKill(creature, target)
    if creature:isPlayer() and target:isPlayer() then
        print("its working")
    end
    return true
end
killEvent:register()

local loginEvent = CreatureEvent("LoginPlayerKill")
function loginEvent.onLogin(player)
    player:registerEvent("skull_kill")
    return true
end
loginEvent:register()

target:getMaster
This function is only for monsters/summons, so just remove that part. Also, you registered it incorrectly with KillEvent:type("kill"). Just remove that line and add it in onLogin — problem solved.
 
Last edited:
The script is correct here, just go to data/scripts/filename.lua using revscriptsys.
LUA:
local killEvent = CreatureEvent("skull_kill")
function killEvent.onKill(creature, target)
    if creature:isPlayer() and target:isPlayer() then
        print("its working")
    end
    return true
end
killEvent:register()

local loginEvent = CreatureEvent("LoginPlayerKill")
function loginEvent.onLogin(player)
    player:registerEvent("skull_kill")
    return true
end
loginEvent:register()



You can remove the additions to creaturescripts.xml and login.lua — I already made a revscript for that, so there’s no need. But if you don’t want to use revscripts, you can keep it and use this other version without revscripts, it's simpler.

skull_kill.lua
LUA:
function onKill(creature, target)
 if creature:isPlayer() and target:isPlayer() then
        print("its working")
    end
    return true
end



This function is only for monsters/summons, so just remove that part. Also, you registered it incorrectly with KillEvent:type("kill"). Just remove that line and add it in onLogin — problem solved.
It doesn't work for me in either mode, it doesn't print when I kill a player.
Post automatically merged:

any?
 
Last edited:
LUA:
function onKill(cid, target, lastHit)
if player:isPlayer(cid) and player:isPlayer(target) then
        print("execute action")
        end
    return true
end

well the code you posted is like what tfs 1.0? do you even have revscripts?
 
[CÓDIGO=lua]función onKill(cid, objetivo, último golpe)
si jugador:esJugador(cid) y jugador:esJugador(objetivo) entonces
print("ejecutar acción")
fin
devuelve verdadero
fin[/CODE]

Bueno, el código que publicaste es similar al de TFS 1.0. ¿Tienes siquiera revscripts?
i use tfs 1.5 nekiro 8.6 nekiro bro
 
i use tfs 1.5 nekiro 8.6 nekiro bro
then it has to work. you are just not doing it right and we are not magicians we cant see where you put the files if you tagged them correctly if you restarted server and relogged your characters for the proper test maybe ur still running server for last 10h and just replacing scripts without even relogging character
 
entonces tiene que funcionar. Simplemente no lo estás haciendo bien y no somos magos, no podemos ver dónde pusiste los archivos si los etiquetados correctamente si reiniciaste el servidor y volviste a iniciar sesión a tus personajes para la prueba adecuada, tal vez todavía estés ejecutando el servidor durante las últimas 10 horas y solo reemplazas scripts sin siquiera volver a iniciar sesión en el personaje.
Tengo el servidor de pruebas y lo voy cerrando y abriendo con cada modificación, los scripts se van colocando donde me van indicando como dijo @Mateus Robeerto, uno es un revscript y el otro va directo a Creaturescripts, al reiniciar mata a un jugador y no imprime nada en la consola.
 
Tengo el servidor de pruebas y lo voy cerrando y abriendo con cada modificación, los scripts se van colocando donde me van indicando como dijo @Mateus Robeerto, uno es un revscript y el otro va directo a Creaturescripts, al reiniciar mata a un jugador y no imprime nada en la consola.
You just need to remove the regular script file, like data/creaturescripts/filename.lua, and also remove the onLogin.lua registration you added. I left the revscript version — test it, it should work
 
The script is fine, the engine is also fine, it simply has an onPrepareDeath event that doesn't allow the player to die. This usually happens when there's a custom PvP system that handles the player's death in a very specific way from Lua.

The topic should be closed, I already spoke with @Izaack privately on Discord, and it's because of that, I even helped him with it myself.

In short, it's a simple onPrepareDeath event that returns false whenever it's player versus player.
 
Solution
Back
Top