local es,s = 120,12354 -- exhaustion in seconds, storage value.
function onUse(cid,item,toPosition,itemEx,fromPosition)
if exhaustion.check(cid,s) then
return doPlayerSendCancel(cid,'You can only use this each '..es..' seconds.') and false
end
doSendMagicEffect(getThingPos(itemEx),CONST_ME_LOSEENERGY)
doCreatureAddMana(cid,500)
exhaustion.set(cid,s,es)
return true
end
local es,s = 120, {} -- exhaustion in seconds, table with exhaustion
function onUse(cid,item,toPosition,itemEx,fromPosition)
if s[cid] ~= nil and s[cid] > os.time() then
return doPlayerSendCancel(cid,'You can only use this each '..es..' seconds.') and false
end
doSendMagicEffect(getThingPos(itemEx),CONST_ME_LOSEENERGY)
doCreatureAddMana(cid,500)
s[cid] = os.time() + es
return true
end
<action itemid="xxxx" event="script" value="toilette.lua"/>
<action uniqueid="xxxx" event="script" value="toilette.lua"/>
local message = "Put the message you want to appear after you use the toilette"
function onUse(cid, item, frompos, item2, topos)
doPlayerAddMana(cid, 500)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,message) ---- If you don't want messages displayed then erase this line
return true
end
If your server is online for 1000 hours you can change 'cid' to getPlayerGUID(cid) eace:Instead of storages, you prefer potential memory leaks?
local message = "Put the message you want to appear after you use the toilette"
local speed = x --- Put the speed you'd like
function onUse(cid, item, frompos, item2, topos)
doPlayerAddMana(cid, 500)
doChangeSpeed(cid, speed)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,message) ---- If you don't want messages displayed then erase this line
return true
end
local message = "Put the message you want to appear after you use the toilette"
local speed = x --- Put the speed you'd like
local time = x --- Put the time you'd like (it will be multiplied by 1000)
function onUse(cid, item, frompos, item2, topos)
doPlayerAddMana(cid, 500)
doChangeSpeed(cid, speed)
addEvent(doChangeSpeed, time*1000, cid, -speed)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,message) ---- If you don't want messages displayed then erase this line
return true
end
If someone can just put exhaustion to the toilette, and end to the speed then it would be awesome!
local exhaustion = 120 -- exhaustion in seconds
local speedValue = 420 -- speed change
local speedTime = 60 -- time in seconds
local mana = 500 -- mana change
local tmpStorages = {} -- table with exhaustion / do not modify
function onUse(cid,item,toPosition,itemEx,fromPosition)
if tmpStorages[getPlayerGUID(cid)] ~= nil and tmpStorages[getPlayerGUID(cid)] > os.time() then
return doPlayerSendCancel(cid,'You can only use this each '.. exhaustion ..' seconds.') and false
end
doSendMagicEffect(getThingPos(itemEx),CONST_ME_LOSEENERGY)
doCreatureAddMana(cid, mana)
addEvent(function(cid, speedChange) return isPlayer(cid) and doChangeSpeed(cid, speedChange) end, speedTime * 1000, cid, -speedValue)
doChangeSpeed(cid, speedValue)
tmpStorages[getPlayerGUID(cid)] = os.time() + exhaustion
return true
end
local message = "Put the message you want to appear after you use the toilette"
local speed = x --- Put the speed you'd like
local time = x --- Put the time you'd like (it will be multiplied by 1000)
local storage = 15000
local exhaustion = x
function onUse(cid, item, frompos, item2, topos)
if getGlobalStorageValue(storage) < os.time()
doPlayerAddMana(cid, 500)
doChangeSpeed(cid, speed)
addEvent(doChangeSpeed, time*1000, cid, -speed)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,message) ---- If you don't want messages displayed then erase this line
setGlobalStorageValue(storage, os.time() + exhaustion)
else
doPlayerSendCancel(cid, "You must wait "..exhaustion.." minutes to use the toilette again")
return true
end
I get the following error: data/actions/scripts/showers/toilette.lua:3: attempt to index global 'exhaustion' <a nil value>
exhaustion =
{
check = function (cid, storage)
if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
return false
end
return getPlayerStorageValue(cid, storage) >= os.time(t)
end,
get = function (cid, storage)
if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
return false
end
local exhaust = getPlayerStorageValue(cid, storage)
if(exhaust > 0) then
local left = exhaust - os.time(t)
if(left >= 0) then
return left
end
end
return false
end,
set = function (cid, storage, time)
setPlayerStorageValue(cid, storage, os.time(t) + time)
end,
make = function (cid, storage, time)
local exhaust = exhaustion.get(cid, storage)
if(not exhaust) then
exhaustion.set(cid, storage, time)
return true
end
return false
end
}
if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
return false
end
@UP
Rep+ for your help (that can help author on thread with other scripts), but next time read all answers in thread.