• 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 help in completing this script

tiddpd

PHP Scripter
Joined
Apr 16, 2008
Messages
331
Reaction score
0
I can make a simple version of this script but I need for features. Firstly this is a talkaction script, what I want it to do is when you say "open sesame" in front of the door, it will open. That door is the first of several doors through the quest where you have to figure out what to say to open it.

I am having two problems, the first is using doTransformItem to open the door (it doesnt know what item is), and my second problem is putting it so you have to be on a certain tile for it to open (so that you can't open the door from anywhere on the map).

This what I have so far... lol, note: I have tried putting doCreateItem right after remove item, does not work.

Code:
	local statuePos = {x = 457, y = 198, z = 7, stackpos=1}
	local statue = getThingfromPos(statuePos)

function onSay(cid, words, param)
		doRemoveItem(statue.uid,1)
end
 
Comparing position of player with set position in script:
(functions.lua)
Code:
function comparePos(pos1, pos2)
return (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z)
end

script:
Code:
local standPos = {x=970,y=1113,z=6}
local statue = getThingfromPos({x = 457, y = 198, z = 7, stackpos=1})

function onSay(cid, param)
    if comparePos(getPlayerPosition(cid), standPos) then
        if statue.itemid > 0 then
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        else
            doRemoveItem(statue.uid,1)
        end
    end
    return 1
end
 
Comparing position of player with set position in script:
(functions.lua)
Code:
function comparePos(pos1, pos2)
return (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z)
end

script:
Code:
local standPos = {x=970,y=1113,z=6}
local statue = getThingfromPos({x = 457, y = 198, z = 7, stackpos=1})

function onSay(cid, param)
    if comparePos(getPlayerPosition(cid), standPos) then
        if statue.itemid > 0 then
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        else
            doRemoveItem(statue.uid,1)
        end
    end
    return 1
end

Hio.
fromPosition is nil `!`
 
lib/functions.lua (only in > beta 2)

@Rudolf
how frompos can be nil as I wasn't used it in script :o, I have just written:
Code:
getPlayerPosition(cid)
 
Back
Top