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

Solved GET position

nevix

Tunzodus.net
Joined
Mar 31, 2010
Messages
356
Reaction score
62
Location
Lithuanian
I trying get my position but nothing working please help me.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your Cords:"..getThingfromPos(cid).."")

end

But nothing :/
 
Code:
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your current position: [X: " .. getCreaturePosition(cid).x .. ", Y: " .. getCreaturePosition(cid).y .. ", Z: " .. getCreaturePosition(cid).z .. "].")
 
One more question.

Posible like this:


doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your storage X: " .. getPlayerStorageValue(cid, 15000).."")
cords = {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}
setPlayerStorageValue(cid, 15000, cords)



?
 
----- to save
Code:
setPlayerStorageValue(cid, 15000, getCreaturePosition(cid).x)
setPlayerStorageValue(cid, 15001, getCreaturePosition(cid).y)
setPlayerStorageValue(cid, 15002, getCreaturePosition(cid).z)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your position save sucess.")

----- to return position
Code:
doTeleportThing(cid, {x=getPlayerStorageValue(cid, 15000), y=getPlayerStorageValue(cid, 15001), z=getPlayerStorageValue(cid, 15002)})
doSendMagicEffect(getCreaturePosition(cid), 10)
 
It works perfectly :) One more question. I want create portal near me but something dont work:
my all code


Code:
local t = {
sec = 10,
sec2 = 5,
portal = {x = 32346, y = 32224, z = 7},
portalwhere = {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z},
itemid = 11796,
active = 1
}

function onUse(cid, item, fromPosition, itemEx, toPosition)


if(t.active == 1) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Portal has been opened for 10 seconds.")

local portal = doCreateItem(t.itemid,1,t.portalwhere)
doSetItemActionId(portal, 20001)
setPlayerStorageValue(cid, 15001, getCreaturePosition(cid).x)
setPlayerStorageValue(cid, 15002, getCreaturePosition(cid).y)
setPlayerStorageValue(cid, 15003, getCreaturePosition(cid).z)

addEvent(function()
doRemoveItem(getTileItemById(t.portalwhere, t.itemid).uid)
end,
t.sec * 1000)
end

return true
end
 
cid is a parameter from function onUse(cid, item, fromPosition, itemEx, toPosition) and should be in/under this function (or in an other function with cid).

Btw you can also set the storage values with a loop, it's a bit faster.
I made this, but kkk111 was faster than me with posting :p
Code:
local p = getPlayerPosition(cid)
for i = 15000, 15002 do
   setPlayerStorageValue(cid, i, i == 15000 and p.x or (i == 15001 and p.y or p.z))
end

Rest is the same.
 
Not tested...

Code:
local config = {
    secToRemove = 50,
    possCreate = {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z},
    possTeleport = {x = 32346, y = 32224, z = 7},
    tpID = 1387
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Portal has been opened for "..config.secToRemove.." seconds.")
    setPlayerStorageValue(cid, 15001, getCreaturePosition(cid).x)
    setPlayerStorageValue(cid, 15002, getCreaturePosition(cid).y)
    setPlayerStorageValue(cid, 15003, getCreaturePosition(cid).z)
    doCreateTeleport(config.tpID, config.possCreate, config.possTeleport)
    addEvent(removeTP, config.secToRemove * 1000)
    return true
end

function removeTP()
    if(getTileItemById(config.possCreate, config.tpID).uid > 0) then
        doRemoveItem(getTileItemById(config.possCreate, config.tpID).uid)
        doSendMagicEffect(config.possCreate, CONST_ME_POFF)
    end
end
 
Back
Top