TFS 1.X+ Free bless problem new players

Thorn

Spriting since 2013
Premium User
Joined
Sep 24, 2012
Messages
2,188
Best answers
1
Reaction score
857
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

Î Àm ŁĕğẹňĎ
Support Team
Joined
Mar 4, 2017
Messages
1,204
Best answers
145
Reaction score
437
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

I'd rather kiss a rattlesnake
Joined
May 30, 2009
Messages
5,957
Best answers
35
Reaction score
1,886
Location
160,54,7
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

Î Àm ŁĕğẹňĎ
Support Team
Joined
Mar 4, 2017
Messages
1,204
Best answers
145
Reaction score
437
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.
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,340
Best answers
528
Reaction score
3,071
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
Premium User
Joined
Sep 24, 2012
Messages
2,188
Best answers
1
Reaction score
857
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