--Functions by Printer
function Player.setExhaustion(self, value, time)
self:setStorageValue(value, time + os.time())
end
function Player.getExhaustion(self, value)
local storage = self:getStorageValue(value)
if not storage or storage <= os.time() then
return 0
end
return storage - os.time()
end
function Player.hasExhaustion(self, value)
return self:getExhaustion(value) >= os.time() and true or false
end
-- / Functions by Printer
local CONFIG = {
COST = 20000, -- On Gold
TIME = 2, -- On minutes
STORAGE = 2552
}
function onSay(player, words, param)
local split = param:split(",")
if split[1] == nil then
player:sendTextMessage(MESSAGE_INFO_DESCR...
--Functions by Printer
function Player.setExhaustion(self, value, time)
self:setStorageValue(value, time + os.time())
end
function Player.getExhaustion(self, value)
local storage = self:getStorageValue(value)
if not storage or storage <= os.time() then
return 0
end
return storage - os.time()
end
function Player.hasExhaustion(self, value)
return self:getExhaustion(value) >= os.time() and true or false
end
-- / Functions by Printer
local CONFIG = {
COST = 20000, -- On Gold
TIME = 2, -- On minutes
STORAGE = 2552
}
function onSay(player, words, param)
local split = param:split(",")
if split[1] == nil then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Command param is required.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if player:removeMoney(CONFIG.COST) then
if player:getExhaustion(CONFIG.STORAGE) <= 0 then
print("> " .. player:getName() .. " broadcasted: \"" .. param .. "\".")
local players = Game.getPlayers()
for i = 1, #players do
players[i]:sendPrivateMessage(player, param, TALKTYPE_BROADCAST)
end
player:setExhaustion(CONFIG.STORAGE, CONFIG.TIME * 60)
return false
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You can only send a message each : '.. CONFIG.TIME ..' minutes.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You need ' .. CONFIG.COST .. ' gold pieces to broadcast.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
return false
end
thank you the message is send! but the exhaustion isnt workingHope this work for you:
Lua:--Functions by Printer function Player.setExhaustion(self, value, time) self:setStorageValue(value, time + os.time()) end function Player.getExhaustion(self, value) local storage = self:getStorageValue(value) if not storage or storage <= os.time() then return 0 end return storage - os.time() end function Player:hasExhaustion(value) return self:getExhaustion(value) >= os.time() and true or false end -- / Functions by Printer local CONFIG = { COST = 20000, -- On Gold TIME = 2, -- On minutes STORAGE = 2552 } function onSay(player, words, param) if player:removeMoney(CONFIG.COST) and not player:hasExhaustion(CONFIG.STORAGE) then print("> " .. player:getName() .. " broadcasted: \"" .. param .. "\".") local players = Game.getPlayers() for i = 1, #players do players[i]:sendPrivateMessage(player, param, TALKTYPE_BROADCAST) end player:setExhaustion(CONFIG.STORAGE, CONFIG.TIME * 60 * 1000) return true end return false end
thank you the message is send! but the exhaustion isnt working
Thanks! could you do further helping(i dont know which one should i remove and modify), just in case somebody else has the same problem in this thread?You have to replace "ifs".
That "if " with money put under the " if "with getexhaustion .
Dont forget replace "elses" too otherwise it will be sending wrong informations.
Thanks! could you do further helping(i dont know which one should i remove and modify), just in case somebody else has the same problem in this thread?
--Functions by Printer
function Player.setExhaustion(self, value, time)
self:setStorageValue(value, time + os.time())
end
function Player.getExhaustion(self, value)
local storage = self:getStorageValue(value)
if not storage or storage <= os.time() then
return 0
end
return storage - os.time()
end
function Player.hasExhaustion(self, value)
return self:getExhaustion(value) >= os.time() and true or false
end
-- / Functions by Printer
local CONFIG = {
COST = 20000, -- On Gold
TIME = 2, -- On minutes
STORAGE = 2552
}
function onSay(player, words, param)
local split = param:split(",")
if split[1] == nil then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Command param is required.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if player:getExhaustion(CONFIG.STORAGE) <= 0 then
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You can only send a message each : '.. CONFIG.TIME ..' minutes.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if player:removeMoney(CONFIG.COST) then
print("> " .. player:getName() .. " broadcasted: \"" .. param .. "\".")
local players = Game.getPlayers()
for i = 1, #players do
players[i]:sendPrivateMessage(player, param, TALKTYPE_BROADCAST)
end
player:setExhaustion(CONFIG.STORAGE, CONFIG.TIME * 60)
return false
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You need ' .. CONFIG.COST .. ' gold pieces to broadcast.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
return false
end
--Functions by Printer
function Player.setExhaustion(self, value, time)
self:setStorageValue(value, time + os.time())
end
function Player.getExhaustion(self, value)
local storage = self:getStorageValue(value)
if not storage or storage <= os.time() then
return 0
end
return storage - os.time()
end
function Player.hasExhaustion(self, value)
return self:getExhaustion(value) >= os.time() and true or false
end
-- / Functions by Printer
local CONFIG = {
COST = 20000, -- On Gold
TIME = 2, -- On minutes
STORAGE = 2552,
IGNORE_STORAGE = 2553
}
function onSay(player, words, param)
local split = param:split(",")
if split[1] == nil then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Command param is required.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if player:removeMoney(CONFIG.COST) then
if player:getExhaustion(CONFIG.STORAGE) <= 0 then
print("> " .. player:getName() .. " broadcasted: \"" .. param .. "\".")
local players = Game.getPlayers()
for i = 1, #players do
if (players[i]:getStorageValue(CONFIG.IGNORE_STORAGE) ~= 1) then
players[i]:sendPrivateMessage(player, param, TALKTYPE_BROADCAST)
end
end
player:setExhaustion(CONFIG.STORAGE, CONFIG.TIME * 60)
return false
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You can only send a message each : '.. CONFIG.TIME ..' minutes.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You need ' .. CONFIG.COST .. ' gold pieces to broadcast.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
return false
end