• 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,197
Best answers
1
Reaction score
871
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!!
 

M0ustafa

1337
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,810
Best answers
227
Reaction score
708
Location
Egypt
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
 

Evil Puncker

its just a flu
TFS Developer
Joined
May 30, 2009
Messages
6,822
Best answers
100
Reaction score
2,451
Location
7x1 land
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
 

M0ustafa

1337
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,810
Best answers
227
Reaction score
708
Location
Egypt
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.
 

Infernum

Support Team
Joined
Feb 14, 2015
Messages
5,505
Best answers
547
Reaction score
3,403
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.
 
OP
Thorn

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,197
Best answers
1
Reaction score
871
Location
Chile
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
 
Top