• 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+ Free bless problem new players

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
Hello guys, i found a script here to allow people below X lvl to have free bless, however its generating an error for new players, first time logging in players

the error is this

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/freebless.lua:onLogin
data/creaturescripts/scripts/others/freebless.lua:8: attempt to call global 'getThingPosition' (a nil value)
stack traceback:
        [C]: in function 'getThingPosition'
        data/creaturescripts/scripts/others/freebless.lua:8: in function <data/creaturescripts/scripts/others/freebless.lua:2>

And the code is this
Lua:
local freeBlessMaxLevel = 50   --- your max lvl to get free bless
function onLogin(cid)
    if(getPlayerLevel(cid) <= freeBlessMaxLevel and not getPlayerBlessing(cid,1)) then
        for b=1, 5 do
            doPlayerAddBlessing(cid, b)   --- here it add the bless
        end
        doCreatureSay(cid, 'You got free bless, because your level lower than 50', TALKTYPE_ORANGE_1)   --- info why he get bless
        doSendMagicEffect(getThingPosition(cid), CONST_ME_HOLYDAMAGE)
        elseif(getPlayerBlessing(cid,1)) then
    doCreatureSay(cid, 'You are blessed!', TALKTYPE_ORANGE_1)
    else
    doCreatureSay(cid, 'You are not blessed.', TALKTYPE_ORANGE_1)
    end
    return true
end

Can anyone help me fix this issue plz?? D:
Thanks in advance!!
 
Solution
E
meta tabled:

Lua:
local freeBlessMaxLevel = 50   --- your max lvl to get free bless
function onLogin(player)
    if player:getLevel() <= freeBlessMaxLevel and not player:hasBlessing(1) then
        for b = 1, 5 do
            player:addBlessing(b)   --- here it add the bless
        end
        player:say("You got free bless, because your level lower than ".. freeBlessMaxLevel .."", TALKTYPE_MONSTER_SAY)   --- info why he get bless
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)

        elseif player:hasBlessing(1) then
            player:say("You are blessed!", TALKTYPE_MONSTER_SAY)
        else
            player:say("You are not blessed.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
Try this
Lua:
local freeBlessMaxLevel = 50   --- your max lvl to get free bless
function onLogin(cid)
    if(getPlayerLevel(cid) <= freeBlessMaxLevel and not getPlayerBlessing(cid,1)) then
        for b=1, 5 do
            doPlayerAddBlessing(cid, b)   --- here it add the bless
        end
        doCreatureSay(cid, 'You got free bless, because your level lower than 50', TALKTYPE_ORANGE_1)   --- info why he get bless
        Player(cid):getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        elseif(getPlayerBlessing(cid,1)) then
    doCreatureSay(cid, 'You are blessed!', TALKTYPE_ORANGE_1)
    else
    doCreatureSay(cid, 'You are not blessed.', TALKTYPE_ORANGE_1)
    end
    return true
end
 
meta tabled:

Lua:
local freeBlessMaxLevel = 50   --- your max lvl to get free bless
function onLogin(player)
    if player:getLevel() <= freeBlessMaxLevel and not player:hasBlessing(1) then
        for b = 1, 5 do
            player:addBlessing(b)   --- here it add the bless
        end
        player:say("You got free bless, because your level lower than ".. freeBlessMaxLevel .."", TALKTYPE_MONSTER_SAY)   --- info why he get bless
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)

        elseif player:hasBlessing(1) then
            player:say("You are blessed!", TALKTYPE_MONSTER_SAY)
        else
            player:say("You are not blessed.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
 
Solution
I edited the line which produce console error, I don't think it is necessary needed to edit all functions.
The one I posted above should work properly for any 1.x TFS.
 
Mixing scripting styles is a problem in itself, if he's using 1.X he should be scripting with 1.X style code, not 0.X.
 
meta tabled:

Lua:
local freeBlessMaxLevel = 50   --- your max lvl to get free bless
function onLogin(player)
    if player:getLevel() <= freeBlessMaxLevel and not player:hasBlessing(1) then
        for b = 1, 5 do
            player:addBlessing(b)   --- here it add the bless
        end
        player:say("You got free bless, because your level lower than ".. freeBlessMaxLevel .."", TALKTYPE_MONSTER_SAY)   --- info why he get bless
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)

        elseif player:hasBlessing(1) then
            player:say("You are blessed!", TALKTYPE_MONSTER_SAY)
        else
            player:say("You are not blessed.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
Thanks man! it worked great!!
To be honest i didnt know the code wasn't tfs 1.x, and i tested it and worked good, till i find out about new players :c
 
Back
Top