• 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 Is there a "getCreatureLookPosition(cid)" alternative for TFS 1.0

mmoussa

New Member
Joined
Jul 11, 2011
Messages
37
Reaction score
0
Hi, I'm trying to move my server from 0.3.6 to 1.0, but a lot of my scripts use the function 'getCreatureLookPosition(cid)' and I can't find an alternative.
Is there an alternative function in TFS 1.0 ? Or maybe a combination of other functions to do the same thing?

Thanks!
 
Something like Position.getNextPosition(self, direction, steps)?

position:getNextPosition(player:getDirection())

I get this error:
Code:
attempt to index global 'position' (a nil value)

Here's my code:
Code:
function onSay(cid, var)
local pos = position:getNextPosition(player:getDirection())
end

Edit: Tried this too
Code:
function onSay(player, words, param)
local position = player:getPosition()
position:getNextPosition(player:getDirection())
end
Error:
Code:
attempt to index local 'player' (a number value)
 
Last edited:
Send magic effect:
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local lookPos = player:getPosition():getNextPosition(player:getDirection())
    lookPos:sendMagicEffect(CONST_ME_POFF)
    return false
end

Get crystal coin from tile:
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local lookPos = player:getPosition():getNextPosition(player:getDirection())
    local crystalCoin = Tile(lookPos):getItemById(2160)
    return false
end
 
Send magic effect:
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local lookPos = player:getPosition():getNextPosition(player:getDirection())
    lookPos:sendMagicEffect(CONST_ME_POFF)
    return false
end

Get crystal coin from tile:
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local lookPos = player:getPosition():getNextPosition(player:getDirection())
    local crystalCoin = Tile(lookPos):getItemById(2160)
    return false
end

I get 'Attempt to index a nil value' using the crystal coin code. Sorry for wasting your time:oops:
 
Try this one:


Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local lookPos = player:getPosition():getNextPosition(player:getDirection())
    lookPos:getItemById(2160)
    return false
end

If that doesn't work, please be more specific with what you want this script to even do... Also it would help to know exactly what the error says, returning a nil value could mean almost anything, what returns nil value? On which line are you getting the error for? Anyways the script I posted should work, but it doesn't do anything, it just returns true if there is that item, and false if there isn't... But no action is really done, maybe you want to check if there is a crystal coin in front of someone if so, then they auto grab it, idk, but the script really doesn't do anything...
 
Back
Top