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

Lua TFS 1.2 Save player

Manigold

Active Member
Joined
Nov 2, 2017
Messages
198
Solutions
8
Reaction score
48
Hello otland, i need a script that saves a player when he kills another player.I'm using tfs 1.2.
Something like this:
Lua:
local config = {
    heal = true,
    save = true,
    effect = false
}

function onAdvance(player, skill, oldLevel, newLevel)
    if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
        return true
    end

    if config.save then
        player:save()
    end
    return true
end
but for player killers
 
Last edited:
Solution
whats the reason behind it?
Lua:
function onKill(player, target)
    if target:isMonster() then
        return true
    end
    if target:isPlayer() then
        player:save()
    end
    return true
end
Lua:
local shutdownAtServerSave = false
local cleanMapAtServerSave = true

local function serverSave()
    if shutdownAtServerSave then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
        Game.setGameState(GAME_STATE_CLOSED)

        if cleanMapAtServerSave then
            cleanMap()
        end

        Game.setGameState(GAME_STATE_NORMAL)
    end
end

local function secondServerSaveWarning()
    broadcastMessage("Server is saving game in one minute. Please logout.", MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
    broadcastMessage("Server is saving game in 3 minutes. Please logout.", MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end

function onTime(interval)
    broadcastMessage("Server is saving game in 5 minutes. Please logout.", MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
 
Lua:
local shutdownAtServerSave = false
local cleanMapAtServerSave = true

local function serverSave()
    if shutdownAtServerSave then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
        Game.setGameState(GAME_STATE_CLOSED)

        if cleanMapAtServerSave then
            cleanMap()
        end

        Game.setGameState(GAME_STATE_NORMAL)
    end
end

local function secondServerSaveWarning()
    broadcastMessage("Server is saving game in one minute. Please logout.", MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
    broadcastMessage("Server is saving game in 3 minutes. Please logout.", MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end

function onTime(interval)
    broadcastMessage("Server is saving game in 5 minutes. Please logout.", MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
I'm not talking about global server save.
I'm talking about saving the player individualy, like the script i showed as an example.
 
Helo otland, i need a script that saves a player when he kills another player.I'm using tfs 1.2.
Something like this:
Lua:
local config = {
    heal = true,
    save = true,
    effect = false
}

function onAdvance(player, skill, oldLevel, newLevel)
    if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
        return true
    end

    if config.save then
        player:save()
    end
    return true
end
but for for player killers

Something like this

Lua:
function onKill(player, target)
if isPlayer(target) ~= TRUE then
     return true
end
     player:save()
    return true
end

I dont know if tfs 1.2 uses isPlayer() or Player() so change
 
Last edited:
Do you mean this .>>

He has killed: [4] Player
He has died: [8] Times??
No , i mean :when player A kills player B ,player A is saved.
Post automatically merged:

Something like this

Lua:
function onKill(player, target)
if isPlayer(target) ~= TRUE then
     return true
end
     player:save()
    return true
end

I dont know if tfs 1.2 uses isPlayer() or Player() so change
 

Attachments

Last edited:
whats the reason behind it?
Lua:
function onKill(player, target)
    if target:isMonster() then
        return true
    end
    if target:isPlayer() then
        player:save()
    end
    return true
end
The reason for this is to show players with skull on website in real time, cause the skulls is only updated on database when gm or server saves.
 
Hi there,

Lua:
function onKill(player, target)
    if target:isMonster() then
        return true
    end
    if target:isPlayer() then
        player:save()
    end
    return true
end

XML:
<event type="kill" name="onKill" script="scripts/scriptname.lua"/>
 
Last edited:
Back
Top