• 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 Where exactly is my "logout" script located?

Simbaclaws

ˁ(⦿ᴥ⦿)ˀ
Joined
Mar 15, 2016
Messages
41
Reaction score
1
Location
Netherlands
I found a script I'd like to add to my server for enabling pets. The thread can be found here:
https://otland.net/threads/many-my-fully-lua-pet-system-many-features.3432/

now, I am still a total noob so please don't take this the wrong way.
The person who made this script basically tells me to put something in my logout script.
Now I've tried searching for it on github for the tfs 1.2 files. And I found a file under: data/creaturescripts/scripts/logout.lua

Is this the logout file that's being referred to in the thread or am I completely wrong?
I would like to know to which script I would have to add his/her code to.

Also I suppose I should replace the cid with playerId? Because my current logout.lua script looks like this:
Code:
function onLogout(player)
    local playerId = player:getId()
    if nextUseStaminaTime[playerId] ~= nil then
        nextUseStaminaTime[playerId] = nil
    end
    return true
end

I am guessing cid stands for creature id?
 
Last edited:
I found a script I'd like to add to my server for enabling pets. The thread can be found here:
https://otland.net/threads/many-my-fully-lua-pet-system-many-features.3432/

now, I am still a total noob so please don't take this the wrong way.
The person who made this script basically tells me to put something in my logout script.
Now I've tried searching for it on github for the tfs 1.2 files. And I found a file under: data/creaturescripts/scripts/logout.lua

Is this the logout file that's being referred to in the thread or am I completely wrong?
I would like to know to which script I would have to add his/her code to.

Also I suppose I should replace the cid with playerId?
That code is very old, and will most likely not work with TFS 1.2.
No, you have to change cid to player, not playerId.

But yeah, the logout he means is this:
https://github.com/otland/forgottenserver/blob/master/data/creaturescripts/scripts/logout.lua
 
That code is very old, and will most likely not work with TFS 1.2.
No, you have to change cid to player, not playerId.

But yeah, the logout he means is this:
https://github.com/otland/forgottenserver/blob/master/data/creaturescripts/scripts/logout.lua
Actually you can still use cid instead of player, of course it would look kind of funny :p
Code:
function onSay(cid, words, param)
    cid:say("hello world", TALKTYPE_ORANGE_1)
end
Code:
function onSay(player, words, param)
    player:say("hello world", TALKTYPE_ORANGE_1)
end

Both above will work in 1.2, it is because both cid and player are one in the same, why is that?
Because they are both sending the same data just because of where they are sitting in the parameter's list.

You can even rename the parameters
Code:
function onSay(cats, worms, parrots)
 
Last edited:
Actually you can still use cid instead of player, of course it would look kind of funny :p
Code:
function onSay(cid, words, param)
    cid:say("hello world", TALKTYPE_ORANGE_1)
end
Code:
function onSay(player, words, param)
    player:say("hello world", TALKTYPE_ORANGE_1)
end

Both above will work in 1.2, it is because both cid and player are one in the same, why is that?
Because they are both sending the same data just because of where they are sitting in the parameter's list.

You can even rename the parameters
Code:
function onSay(p, w, p)

Yeah sorry, that's actually kinda logical and the same with any programming language out there. You simply change the name of the parameter but the input stays the same.

Anyways, seems like I'm already getting my first error for my petConfig script on line 29: attempt to call field 'foreach' (a nil value).
I suppose table.foreach has been replaced at some specific point in time?
The line is as followed:
Code:
x = 0 y = 0 function() x = x + 1 end table.foreach(storages, y)
I'm probably going to ask a lot of questions about which functions to use instead. I think I should be looking at my compat.lua instead and my luascripts.cpp right?

searching for foreach or table in compat.lua and luascripts.cpp didn't turn up anything.
Neither did storage, the only functions that came up are PlayerGetStorageValue and PlayerSetStorageValue...
 
Last edited:
Back
Top