I made a script that takes an item from a player, and lets him access that door for an hour. I've decided to share it with you.
All you need to do is set action id of door to 1780, and set the unique id to anything you want, it doesn't matter. Very simple.
After the player has passed the door, he will not be kicked out after time is up, however, should he leave and try to come back he won't be able to get in if his time expired.
Enjoy.
All you need to do is set action id of door to 1780, and set the unique id to anything you want, it doesn't matter. Very simple.
After the player has passed the door, he will not be kicked out after time is up, however, should he leave and try to come back he won't be able to get in if his time expired.
Code:
local aid_of_door = 1780 -- ActionID of all VIP Doors
local ITEMID_OF_VIPTOKEN = 2195
local tdoor = 3600 -- time in seconds
-- DO NOT EDIT BELOW THIS LINE
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.actionid == aid_of_door) then
local stor = getPlayerStorageValue(cid, item.uid)
if(stor < 1 or (stor+tdoor) <= os.time()) then
local ret = doPlayerRemoveItem(cid, ITEMID_OF_VIPTOKEN, 1)
if(ret) then
setPlayerStorageValue(cid, item.uid, os.time())
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You now have one hour access to this spawn.")
if(not doorEnter(cid, item, toPosition)) then return false end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need atleast one VIP TOKEN to enter this spawn.")
end
else
if(not doorEnter(cid, item, toPosition)) then return false end
end
end
return true
end
function doorEnter(cid, item, toPosition)
local mob = getTopCreature(toPosition); if(mob.uid > 0) then return false end
doTransformItem(item.uid, item.itemid + 1)
doTeleportThing(cid, toPosition)
return true
end
Enjoy.