• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Skull remover with time

Vitich

Member
Joined
Nov 28, 2012
Messages
266
Reaction score
11
Hi people! I want add a time that only can use it every 24 hour.

Code:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)

    if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:setSkull(SKULL_NONE)
        player:setSkullTime(0)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
        db.query("UPDATE `player_deaths` SET `unjustified` = 0 WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
        item:remove(1)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
   
    return true
end

Thanks!
 
Solution
Lua:
local reqStorage = xxxx
local reqTime = 24 * 60 * 60 -- time in seconds

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getStorageValue(reqStorage) > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You can use it only once per 24h!\nLast used: [%s]", os.date("%c", reqStorage - reqTime)))
    return true
    end

    if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:setSkull(SKULL_NONE)
        player:setSkullTime(0)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
        db.query("UPDATE `player_deaths` SET `unjustified` = 0...
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getStorageValue(88888) > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use this once every 24 hours.")
        return true
    end
    if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:setSkull(SKULL_NONE)
        player:setSkullTime(0)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
        db.query("UPDATE `player_deaths` SET `unjustified` = 0 WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
        item:remove(1)
        player:setStorageValue(88888, os.time() + (24 * 60 * 60))
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
 
Lua:
local reqStorage = xxxx
local reqTime = 24 * 60 * 60 -- time in seconds

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getStorageValue(reqStorage) > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You can use it only once per 24h!\nLast used: [%s]", os.date("%c", reqStorage - reqTime)))
    return true
    end

    if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:setSkull(SKULL_NONE)
        player:setSkullTime(0)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
        db.query("UPDATE `player_deaths` SET `unjustified` = 0 WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
        player:setStorageValue(reqStorage, os.time() + reqTime)
        item:remove(1)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
 
    return true
end
 
Solution
Back
Top