Odp: Skrypt na uzywanie itemu raz na pare godzin
[lua]
function secondsToClock(sSeconds)
local nSeconds = tonumber(sSeconds)
if nSeconds == 0 then
return "00:00:00"
else
local nHours = string.format("%02.f", math.floor(nSeconds / 3600))
local nMins = string.format("%02.f", math.floor(nSeconds / 60 - (nHours * 60)))
local nSecs = string.format("%02.f", math.floor(nSeconds - nHours * 3600 - nMins * 60))
return nHours..":"..nMins..":"..nSecs
end
end
function onUse(cid,item,fromPosition,itemEx,toPosition)
local level = (8)
local position = getPlayerMasterPos(cid)
local storage = (10000)
local time = (60 * 60 * 24)
if getCreatureStorage(cid, storage) >= os.time() then
doPlayerSendCancel(cid, "You will be able to use teleporteru for " .. secondsToClock(math.abs(os.difftime(getCreatureStorage(cid, storage), os.time()))) .. ".")
return true
end
if getCreatureCondition(cid,CONDITION_INFIGHT) == TRUE then
doPlayerSendCancel(cid,'You can not teleport in combat!')
return true
end
if (getPlayerLevel(cid) <= level) then
doPlayerSendCancel(cid, "Sorry, you need to " .. level .. " level or higher.")
return true
end
if (isPlayerPzLocked(cid) == true) then
doPlayerSendCancel(cid, "You can not teleport because attacked the player!")
return true
end
doCreatureSay(cid, ".:: You teleported to the Temple ::.", TALKTYPE_ORANGE_1)
doTeleportThing(cid, position)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
doSendMagicEffect(position, CONST_ME_TELEPORT)
doCreatureSetStorage(cid, storage, os.time() + time)
doPlayerSave(cid)
return true
end
[/lua]