everything works on this script.. except that it wont randomize where its warp location is.. the portalPos i have defined at the start is just to be a fail safe.. but the script still refuses to set a random location.
PHP:
-- -- By jgarder
function onUse(cid, item, frompos, item2, topos)
local warzone = { [1] = {name = "Aurora Island", fromPos = {x=908, y=601, z=4}, toPos = {x=958, y=642, z=8}}, }
local post = getThingPosition(cid)
local storage = 15100
local portalPos = {x=943, y=611, z=7, stackpos=1}
setPlayerStorageValue(cid,storage, 0)
local rand1 = math.random(943, 953)
local rand2 = math.random(612, 618)
if isInRange(getThingPosition(cid), warzone[1].fromPos, warzone[1].toPos) then
local portalPos = {x=rand1, y=rand2, z=7, stackpos=1}
else
local portalPos = {x=rand1, y=rand2, z=7, stackpos=1}
doPlayerSendTextMessage(cid,22, "You are not on Aurora Island")
end
if 1==2 then
doPlayerSendCancel(cid, "You cannot create a portal in the same place you are going to!")
return TRUE
end
if(getPlayerStorageValue(cid, 15100) ~= 1) and (getTilePzInfo(getThingPosition(cid)) == false) then
if (isInRange(getThingPosition(cid), warzone[1].fromPos,warzone[1].toPos) == true) then
local portal = doCreateTeleport(1387, portalPos, post)
local a = {cid=cid, storage=storage, post=post}
doPlayerSendTextMessage(cid,22,"You have used The Aurora Portal.")
doTeleportThing(cid, portalPos, FALSE)
setPlayerStorageValue(a.cid, a.storage, 1)
addEvent(removePortal, 10000, a)
else
doPlayerSendTextMessage(cid,22, "You are not on Aurora Island")
end
else
doPlayerSendCancel(cid, "You already have a portal.")
end
end
function removePortal(a)
local rpost = getTileItemByType(a.post, ITEM_TYPE_TELEPORT)
doRemoveItem(rpost.uid, 1)
setPlayerStorageValue(a.cid, a.storage, 0)
end