• 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+ "TFS 1.3 & MyAAC & LUA" A Few Questions

excool

New Member
Joined
Nov 22, 2023
Messages
17
Reaction score
3
Witam! Hello!

Translation into English using Google Translator . Tłumaczenie na angielski używając google translator .

I have a few questions, I didn't want to start each separate topic.. Mam kilka pytań, nie chciałem zakładać każdego oddzielnego tematu.

1. Mam problem aby dodać post w "Latest News" każdy długi tekst lub ze znakami specjalnymi wywala błąd.
1. I have a problem with adding a post in "Latest News" - any long text or text with special characters produces an error.
2. Trochę konkretniejsze moim zdaniem jak pisać skrypty które by brały pod uwagę wartości z "config.lua" Rozwiązane!
2. A little more specific, in my opinion, how to write scripts that would take into account the values from "config.lua" Solved!

e.g.
np.
freeBlessMaxLevel = 100

- teraz jak by to wyglądało w tym skrypcie
- and now what it would look like in this script

Lua:
local freeBlessMaxLevel = 80

function onLogin(cid)
    local player = Player(cid)
    if player:getLevel() <= freeBlessMaxLevel then
        for i = 1, 8 do
            if not player:hasBlessing(i) then
                player:addBlessing(i, 1)
            end
        end

        player:sendTextMessage(MESSAGE_EVENT_ADVANCE,'You received adventurers blessings for you to be level less than ' .. freeBlessMaxLevel .. '!')
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    end
    return true
end

thanks for the replies
 
Last edited:
to use values from config.lua file in scripts use for example:

configManager.getBoolean(configKeys.FREE_PREMIUM)
configManager.getNumber(configKeys.FRAG_TIME)

keys are in src/configmanager.h

Lua:
local freeBlessMaxLevel = configManager.getNumber(configKeys.PROTECTION_LEVEL)

function onLogin(player)
    if player:getLevel() <= freeBlessMaxLevel then
        for i = 1, 8 do
            if not player:hasBlessing(i) then
                player:addBlessing(i, 1)
            end
        end

        player:sendTextMessage(MESSAGE_EVENT_ADVANCE,'You received adventurers blessings for you to be level less than ' .. freeBlessMaxLevel .. '!')
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    end
    return true
end
 
or just

Lua:
local blabla = getConfigInfo('freeBlessMaxLevel')
Po dodaniu wyglada to tak:
After adding it, it looks like this:
Lua:
local freeBlessMaxLevel = getConfigInfo('freeBlessMaxLevel')

function onLogin(cid)
    local player = Player(cid)
    if player:getLevel() <= freeBlessMaxLevel then
        for i = 1, 8 do
            if not player:hasBlessing(i) then
                player:addBlessing(i, 1)
            end
        end

        player:sendTextMessage(MESSAGE_EVENT_ADVANCE,'You received adventurers blessings for you to be level less than ' .. freeBlessMaxLevel .. '!')
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    end
    return true
end

config.lua
Lua:
-- Bless
freeBlessMaxlevel = 130

and error in tfs
Code:
Tester has logged in.

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/adventureblessings.lua:onLogin
data/creaturescripts/scripts/others/adventureblessings.lua:5: attempt to compare number with nil
stack traceback:
        [C]: in function '__le'
        data/creaturescripts/scripts/others/adventureblessings.lua:5: in function <data/creaturescripts/scripts/others/adventureblessings.lua:3>
Tester has logged out.

Everything works, I restarted the host and somehow it reads the data
Wszystko działa zrestartowałem hosta i jakims cudem czyta dane

to use values from config.lua file in scripts use for example:

configManager.getBoolean(configKeys.FREE_PREMIUM)
configManager.getNumber(configKeys.FRAG_TIME)

keys are in src/configmanager.h

Lua:
local freeBlessMaxLevel = configManager.getNumber(configKeys.PROTECTION_LEVEL)

function onLogin(player)
    if player:getLevel() <= freeBlessMaxLevel then
        for i = 1, 8 do
            if not player:hasBlessing(i) then
                player:addBlessing(i, 1)
            end
        end

        player:sendTextMessage(MESSAGE_EVENT_ADVANCE,'You received adventurers blessings for you to be level less than ' .. freeBlessMaxLevel .. '!')
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    end
    return true
end
This means that I can only use the values in config.lua that I have in the configmanager.h file
If I add new conditions to the configmanager.h file, I will need to recompile the engine, right?
And is it even possible and safe?
Post automatically merged:

I still have a problem with 1 question. Please help
Nadal mam problem z 1 pytaniem Proszę o pomoc
 
Last edited:
I'm still looking for a solution to the first question, and I also have another one related to RME. I don't know if it's good to write here, but what id blank is inaccessible to the player? Player Cant move item.
Please add the question to the main one because I can't edit it anymore
 
Regarding the latest news.

What web engine are you using? znote? myacc?

I assume you may be using apostrophes ' in your news stories. If you are using an inbuilt web editor to do this, they probably aren't escaping them, which means your apostrophes are ending the string prematurely, and therefore causing an error.

You can either go into the code, and make sure you escape the string of the body, or you can just make sure to escape them yourself when you are writing them. So anything you type a ', put a backslash before it,

I.e
"You're eating all of the person's food."
becomes
"You\'re eating all of the person\'s food."

And as for the long text, you will need to increase the varchar size of the database column, to which the text is stored.
 
Thank you, but as you asked, what is the error I'm getting, so I analyzed it and found a solution in mySQL ;))
 
Back
Top