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

[8.0] - TFS 1.2

It's not a problem with this distribution, but SQL schema script file from www service, you attempt to use.
At least one of your *.sql file has unfinished query.

Take a look at this example:
SQL:
UPDATE players SET level = 1,group_id = 3,vocation = 0,health = 100,healthmax = 100,experience = 0,lookbody = 10,lookfeet = 10,lookhead = 10,looklegs = 10,looktype = 136,lookaddons = 3,maglevel = 0,mana = 100,manamax = 100,`

It basically tries to set attributes of lvl 1 player for all records in table players, but it doesn't set town_id or initial positions. It also ends with comma and apostrophe instead of semicolon, as every sql query should.

I'dont know which www service you're trying to use, but myaac-0.8.2 (which I'm personally using) doesn't even have such query.

If I were you I'd try to fix these queries like so: (Even tho I don't know if I'm missing any crucial part)

Example:
SQL:
UPDATE players SET level = 1,group_id = 3,vocation = 0,health = 100,healthmax = 100,experience = 0,lookbody = 10,lookfeet = 10,lookhead = 10,looklegs = 10,looktype = 136,lookaddons = 3,maglevel = 0,mana = 100,manamax = 100;

If it doesn't help, try to use other webpage service.

If you don't know how to find such files. You can use notepad++ ctrl+shift+F function. It finds specified strings in multiple files, which is better option than manual search.
I tried to use my-aac 0.8.2 and the error continues, however using the old distro that was already compiled never gave this error, only the new one I compiled.
I tried to find that part anyway and I didn't find

SQL:
UPDATE players SET level = 1,group_id = 3,vocation = 0,health = 100,healthmax = 100,experience = 0,lookbody = 10,lookfeet = 10,lookhead = 10,looklegs = 10,looktype = 136,lookaddons = 3,maglevel = 0,mana = 100,manamax = 100;
 
I'd like to do my best and help you, but I also don't want to pollute this topic with something in my opinion unrelated. Is there any chance, you could repost this issue on Support subforum, so we could continue there? Also there's bigger chance that the other people may join and help you.

Papamix said:
I tried to use my-aac 0.8.2 and the error continues, however using the old distro that was already compiled never gave this error, only the new one I compiled.

Did you purge your database before connecting a new webservice? I'm asking because open tibia webservices tend to modify databases, create new tables, and run various queries. If your old one somehow screwed your database, a new one will not work.

Papamix said:
I tried to find that part anyway and I didn't find

Multiple reasons for that. Let me explain.
SQL allows to use more than one type of apostrophes. You can use this: 'example', this: "example" or this: example. You can also use multiple white characters such as space, tab etc next to eachother and MariaDB/MySQL will accept that.

This is absolutely the same query (Just as example. There is no need to run it):
SQL:
UPDATE players SET posx=32335, posy=32215, posz=7 WHERE id=1;
UPDATE `players` SET posx=32335, posy=32215, posz=7 WHERE id=1;
UPDATE `players` SET posx=32335, posy=32215, `players`.`posz`=7 WHERE id=1;
UPDATE players SET             posx=32335, posy=32215, `players`.`posz`=7 WHERE id=1;
UPDATE `yourdatabasename`.`players` SET posx=32335, posy=32215, posz=7 WHERE id=1;

However console error output may be simplified and shown without those characters. You get my point? So I suggest searching for shorter string
with pattern matching like the one below.

This example is valid for notepad++
Search filters: *.sql, *.lua, *.php, *.cpp
Search mode: regex
Code:
(.*?)update(.*?)players(.*?)set(.*?)level(.*?)

I performed this search on my pc, and I've found nothing related to this ots distribution. (Just a few files from other datapacks I use as sources for my own scripts like this one from tibia 7.4 avesta: query << "UPDATE players SET level = " << player->level)

If you're not using notepad++, you can also use linux console for the same thing.

If it fails. Is there any chance you could drop your database and create brand new with sql schema files? Or you have to migrate somehow, because you have users in it?


Edit: I assume this error is not a compilation error, but it shows up when you try to run your server. Am I right?
 
Last edited:
Thank you very much for the help, I managed to correct the error, I was using boost 1.60 and not 1.62, I switched to 1.62 and compiled it again, the problem was solved, thanks for your attention.
 
Papamix said:
Thank you very much for the help, I managed to correct the error, I was using boost 1.60 and not 1.62, I switched to 1.62 and compiled it again, the problem was solved, thanks for your attention.

Well I'm confused right now. No idea how version of the boost libs would affect "syntax error", you provided but ok.
 
Small fix:

In file data\lib\miscellaneous\050-functions.lua at line 21 function doAddExp(cid, amount) throws an error upon use:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quests/test.lua:onUse
attempt to index a number value
stack traceback:
[C]: at 0x557361c10372
[C]: in function 'doSendAnimatedText'
data/lib/miscellaneous/050-functions.lua:23: in function 'doAddExp'

Body of this function looks like so:
Lua:
--Functions by Oskar--
function doAddExp(cid, amount)
    doSendAnimatedText(getCreaturePosition(cid), amount, COLOR_WHITE)
    return doPlayerAddExperience(cid, amount) or false
end

This function is not that critical and it can be deleted because all its references are simply replaceable with single line:
Lua:
player:addExperience(amount, true)
However this method has a flaw, because it always omit experience stages.

So I made a replacement of that function. It fixes mentioned error and adds additional functionality. It is also compatible with previous one, because it accepts two or more parameters, so no references have to be changed.
Lua:
function doAddExp(cid, amount, useExpStages, customColor, ...)
    local player = cid:getPlayer()
    if not player then
        return false
    else
        if useExpStages then amount = amount * Game.getExperienceStage(player:getLevel()) end
        if not customColor then customColor = TEXTCOLOR_WHITE_EXP end
        Game.sendAnimatedText(amount, getCreaturePosition(cid), customColor)
        return doPlayerAddExp(cid, amount)
    end
end

Function parameters:
cid - hookup to a certain creature. Function will check if it's a player to avoid error at getting its level later on.
amount - base amount of exp given to a certain player. It may be multiplied by current player's experience stage.
useExpStages - do you want to use experience stages with this function. Must be true or false.
customColor - if you want to use other color than white then you can set it here.

Valid colors are:
TEXTCOLOR_BLUE, TEXTCOLOR_GREEN, TEXTCOLOR_LIGHTGREEN, TEXTCOLOR_LIGHTBLUE, TEXTCOLOR_TEAL, TEXTCOLOR_MAYABLUE, TEXTCOLOR_DARKRED, TEXTCOLOR_LIGHTGREY, TEXTCOLOR_SKYBLUE, TEXTCOLOR_PURPLE, TEXTCOLOR_ELECTRICPURPLE, TEXTCOLOR_RED, TEXTCOLOR_PASTELRED, TEXTCOLOR_ORANGE, TEXTCOLOR_YELLOW, TEXTCOLOR_WHITE_EXP, TEXTCOLOR_NONE

Usage Examples:
Lua:
doAddExp(cid, 10)
Most basic usecase. It will give player ten experience points and display white text animation. Works the same as player:addExperience(10, true)

Lua:
doAddExp(cid, 10, true)
It will give player ten experience points multiplied by current player's experience stage.
It will also work with static exp multiplier without stages. White text animation will be displayed as well.

Lua:
doAddExp(cid, 100, false, TEXTCOLOR_ELECTRICPURPLE)
It will give player one hundred experience points and display electric purple text animation.

Lua:
doAddExp(cid, 50, true, TEXTCOLOR_GREEN)
It will add fifty experience points multiplied by current player's experience stage and display dark green text animation.

Hope you'll find it useful.
 
i did build the source with MSV 2015
this is what i get when running the forgotten server.exe and it close

what i did wrong or what i missing here .

thumb_show.php
 
i did build the source with MSV 2015
this is what i get when running the forgotten server.exe and it close

what i did wrong or what i missing here .

thumb_show.php
Check if your password and database name are correct in config.lua .
 
Small fix:

In file data\lib\miscellaneous\050-functions.lua at line 21 function doAddExp(cid, amount) throws an error upon use:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quests/test.lua:onUse
attempt to index a number value
stack traceback:
[C]: at 0x557361c10372
[C]: in function 'doSendAnimatedText'
data/lib/miscellaneous/050-functions.lua:23: in function 'doAddExp'

Body of this function looks like so:
Lua:
--Functions by Oskar--
function doAddExp(cid, amount)
    doSendAnimatedText(getCreaturePosition(cid), amount, COLOR_WHITE)
    return doPlayerAddExperience(cid, amount) or false
end

This function is not that critical and it can be deleted because all its references are simply replaceable with single line:
Lua:
player:addExperience(amount, true)
However this method has a flaw, because it always omit experience stages.

So I made a replacement of that function. It fixes mentioned error and adds additional functionality. It is also compatible with previous one, because it accepts two or more parameters, so no references have to be changed.
Lua:
function doAddExp(cid, amount, useExpStages, customColor, ...)
    local player = cid:getPlayer()
    if not player then
        return false
    else
        if useExpStages then amount = amount * Game.getExperienceStage(player:getLevel()) end
        if not customColor then customColor = TEXTCOLOR_WHITE_EXP end
        Game.sendAnimatedText(amount, getCreaturePosition(cid), customColor)
        return doPlayerAddExp(cid, amount)
    end
end

Function parameters:
cid - hookup to a certain creature. Function will check if it's a player to avoid error at getting its level later on.
amount - base amount of exp given to a certain player. It may be multiplied by current player's experience stage.
useExpStages - do you want to use experience stages with this function. Must be true or false.
customColor - if you want to use other color than white then you can set it here.

Valid colors are:
TEXTCOLOR_BLUE, TEXTCOLOR_GREEN, TEXTCOLOR_LIGHTGREEN, TEXTCOLOR_LIGHTBLUE, TEXTCOLOR_TEAL, TEXTCOLOR_MAYABLUE, TEXTCOLOR_DARKRED, TEXTCOLOR_LIGHTGREY, TEXTCOLOR_SKYBLUE, TEXTCOLOR_PURPLE, TEXTCOLOR_ELECTRICPURPLE, TEXTCOLOR_RED, TEXTCOLOR_PASTELRED, TEXTCOLOR_ORANGE, TEXTCOLOR_YELLOW, TEXTCOLOR_WHITE_EXP, TEXTCOLOR_NONE

Usage Examples:
Lua:
doAddExp(cid, 10)
Most basic usecase. It will give player ten experience points and display white text animation. Works the same as player:addExperience(10, true)

Lua:
doAddExp(cid, 10, true)
It will give player ten experience points multiplied by current player's experience stage.
It will also work with static exp multiplier without stages. White text animation will be displayed as well.

Lua:
doAddExp(cid, 100, false, TEXTCOLOR_ELECTRICPURPLE)
It will give player one hundred experience points and display electric purple text animation.

Lua:
doAddExp(cid, 50, true, TEXTCOLOR_GREEN)
It will add fifty experience points multiplied by current player's experience stage and display dark green text animation.

Hope you'll find it useful.
Thank you again ,any pull requests on github are welcome =)
 
I got some error it is normal ?

Lua:
[Warning - Event::checkScript] Can not load script: scripts/playerdeath.lua
data/creaturescripts/scripts/playerdeath.lua:106: 'end' expected (to close 'function' at line 6) near '<eof>'
 
I got some error it is normal ?

Lua:
[Warning - Event::checkScript] Can not load script: scripts/playerdeath.lua
data/creaturescripts/scripts/playerdeath.lua:106: 'end' expected (to close 'function' at line 6) near '<eof>'

It has been fixed in most recent commit. Just replace playerdeath.lua and it should be fine.
 
Last edited:
Just to inform people using this distribution: There is an update ready to download. It adds an easy method of making custom greet messages. You can use it for creating npc's like Blind Orc, Queen Eloise, Umar, Elathriel etc.

This code has been adapted from Alkurius and Realera OTS. I should give a proper credits here, but I don't know who the author is.
So I'll just write: "thank you for your work" instead.


It works like so:
If you specify a custom greet messages table, an engine will use it instead of default one, and because this method uses local instances of npcHandler it won't collide with other npcs. All you need to do is place this code in your npc_name.lua file. (After you update ofcourse!)
Lua:
local focusModule = FocusModule:new()
focusModule:addGreetMessage({"charach","oi","hej","czesc"})
npcHandler:addModule(focusModule)
And thats it. Job done. Your npc won't react to standard "hi" or "hello" message. Same with farewell messages.

000.jpg001.jpg

This update also allows usage of parameter "msg" in greetCallback. That might be useful for coding specified reaction to greeting an npc with
certain keyword. You are still able to use regular greetCallback(cid) without parameter "msg" if you wish. (only npc's like Umar that react to secret greetings will probably use this)

Ok. Here is an example npc .xml and .lua files, that you can use for tests:

Blindorc.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Blind Orc" script="Blindorc.lua" walkinterval="2000" access="3" floorchange="0">
    <health now="100" max="100"/>
    <look type="5" head="0" body="0" legs="0" feet="0" addons="0"/>
    <parameters>
        <parameter key="idletime" value="60"/>
        <parameter key="message_greet" value="standard greet message from xml"/>
        <parameter key="message_placedinqueue" value="standard please wait message from xml"/>
        <parameter key="message_alreadyfocused" value="standard alreadyfocused message from xml"/>
        <parameter key="message_walkaway" value="standard walkwaway message from xml"/>
        <parameter key="message_farewell" value="standard farewell message from xml"/>
        <parameter key="message_idletimeout" value="standard timeout message from xml"/>
    </parameters>
</npc>

Blindorc.lua
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
--------------------------------------------------------------------------------------
function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)         npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)    npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                         npcHandler:onThink() end
--------------------------------------------------------------------------------------
local focusModule = FocusModule:new()
focusModule:addGreetMessage({"charach","oi","hej","czesc"}) -- You can add your custom greetwords here. Delete this line if you want your NPC to only respond to standard greetwords.
focusModule:addFarewellMessage({"bye","futchi","tchau","hejda","do widzenia"}) -- You can add your custom farewellwords here. Delete this line if you want your NPC to only respond to standard farewellwords.
npcHandler:addModule(focusModule)
--------------------------------------------------------------------------------------
local talk_state = 0
--------------------------------------------------------------------------------------
local function greetCallback(cid, msg) -- You can delete this entire section if you don't plan to use any reaction depending on certain keyword. An engine will print standard message_greet from xml file in this case.
    if msgcontains(msg, "oi") then
        npcHandler:setMessage(MESSAGE_GREET, "WOW! You know the secret greeting and so do I!")
    else
        npcHandler:setMessage(MESSAGE_GREET, "Hello. How are you?")
    end
    return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
--------------------------------------------------------------------------------------
function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    if msgcontains(msg, "test") then
        npcHandler:say("test reply", cid)
    elseif msgcontains(msg, "do something") then
        npcHandler:say("ok", cid)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BUBBLES)
    end
    return true
end
--------------------------------------------------------------------------------------
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

Please note that, engine uses greeting from lua file even tho <parameter key="message_greet" value="standard greet message from xml"/> in xml file is set. However if you delete a section with greetCallback, it will use standard greet response from xml file.

FarewellCallback is not being handled by lua file in this example, so an engine uses standard response from xml file aswell. I think that should be obvious.

002.jpg

Everything is already merged into celohere/forgottenserver master branch, so go to his github if you want to update.
Don't hesitate to ask if you have any questions.
 
Last edited:
is it possible to create a channel to talk to npc without being by default?
Theoretically by changing NPCHANDLER_CONVBEHAVIOR = CONVERSATION_DEFAULT to CONVERSATION_PRIVATE. But probably you'd have to put some effort to make it work properly. I'm not sure. 8.0 didn't have this feature, so I didn't care much about it.
 
yes, the npc channel launched in 8.2, but i imagined in this matter of trying to create a channel to dialogue with npc
 
BUMP
fixed runes stack inside full containers bug -- crédits to me --

i created a github repository ,if someone finds a bug or wants to help me fix something, you will be welcome =)
celohere/tfs-1.2-8.0 (https://github.com/celohere/tfs-1.2-8.0)
Help me with this man
Two problems are bothering me
 
Hello people,
What/where do I need to edit to change colour of the text in Loot Channel?
 
Back
Top