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

Lua Script Help - 'getThingFromPos' (a nil value)

Crunch

Premium User
Premium User
Joined
Jun 21, 2011
Messages
353
Reaction score
19
Location
England
Hello,

I have this script, its for an archery game, however I cannot figure out why it wont work. The problem is
Lua:
if (getThingFromPos(arrowpos).itemid) == 5779 then
I have tried various different things but have to ask for some help. Could someone tell me the problem and also why mine wont work. I'm using TFS 1.3, not sure if this is the issue as this was written for a much earlier version, however I cant remember if it ever got it to actually work or not.
Many thanks!

Lua:
local allowedPositions = {{x=1429, y=1055, z=7}, {x=1431, y=1055, z=7}, {x=1433, y=1055, z=7}, {x=1435, y=1055, z=7}}

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local arrowpos = {x=getCreaturePosition(cid).x, y=1051, z=7, stackpos=3}
         fromPosition = getCreaturePosition(cid)
         local inPosition = false
    for i=1, #allowedPositions, 1 do
        if allowedPositions[i].x == fromPosition.x and allowedPositions[i].y == fromPosition.y and allowedPositions[i].z == fromPosition.z then
        inPosition = true
        break
    end
end
    if not inPosition then
        doCreatureSay(cid, 'Your not at the Archery Range.', TALKTYPE_ORANGE_1)
    end   

    if inPosition then
        if (getThingFromPos(arrowpos).itemid) == 5779 then
            doRemoveItem(getThingFromPos(arrowpos).uid)
        end 

    if math.random(1, 100) <= 10 then
          doSendDistanceShoot(getThingPos(cid), {x=fromPosition.x, y=1051, z=7}, 2)
          doSendMagicEffect({x=fromPosition.x, y=1051, z=7}, 31)
          doPlayerAddItem(cid, 6527, 1)
          doCreatureSay(cid, 'You hit the target and won!!', TALKTYPE_ORANGE_1)
          doCreateItem(5779, 1, {x=fromPosition.x, y=1051, z=7})
    else
          doSendDistanceShoot(getThingPos(cid), {x=fromPosition.x, y=1051, z=7}, 2) 
          doSendMagicEffect({x=fromPosition.x, y=1051, z=7}, 2)         
          doCreatureSay(cid, 'You missed!', TALKTYPE_ORANGE_1)       
      end
   end 
   return true
end
 

4Nathu4

valoria.online
Joined
Oct 27, 2009
Messages
283
Solutions
9
Reaction score
159
GitHub
4mrcn4
getThingFromPos doesn't exist in your context, it's a legacy function that has to be included in your compat.lua to work properly.

If you are using TFS 1.3 you shouldn't go wrong with this
 
Top