• 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 Time between 2 actions in one script (globalevents)

Frostie

Mapper/basic scripter (NL)
Joined
Feb 14, 2012
Messages
447
Reaction score
425
Location
Holland
Hey guys, i was wondering how to put time between 2 actions in one script like creating an item and remove it in like 2 seconds and add a new item
 
Like that?

PHP:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false

local function serverSave()
	if shutdownAtServerSave then
		Game.setGameState(GAME_STATE_SHUTDOWN)
	else
		Game.setGameState(GAME_STATE_NORMAL)
	end

	if cleanMapAtServerSave then
		cleanMap()
	end

	saveServer()
end

local function secondServerSaveWarning()
	broadcastMessage("Server is saving game in one minute. Please go to a safe place.", MESSAGE_STATUS_WARNING)
	addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
	broadcastMessage("Server is saving game in 3 minutes. Please go to a safe place.", MESSAGE_STATUS_WARNING)
	addEvent(secondServerSaveWarning, 120000)
end

function onTime(interval)
	broadcastMessage("Server is saving game in 5 minutes. Please go to a safe place.", MESSAGE_STATUS_WARNING)
	Game.setGameState(GAME_STATE_STARTUP)
	addEvent(firstServerSaveWarning, 120000)
	return not shutdownAtServerSave
end
 
Like that?

PHP:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false

local function serverSave()
    if shutdownAtServerSave then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
        Game.setGameState(GAME_STATE_NORMAL)
    end

    if cleanMapAtServerSave then
        cleanMap()
    end

    saveServer()
end

local function secondServerSaveWarning()
    broadcastMessage("Server is saving game in one minute. Please go to a safe place.", MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
    broadcastMessage("Server is saving game in 3 minutes. Please go to a safe place.", MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end

function onTime(interval)
    broadcastMessage("Server is saving game in 5 minutes. Please go to a safe place.", MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end

Not exactly i made this script±
Code:
local t = {
{2160, 1,  {x=805, y=817, z=7}, CONST_ME_TELEPORT}
}
function onThink(interval)
    local people = getOnlinePlayers()
    if #people == 0 then
        return true
    end

    for i = 1, #t do
        local v = t[i]
        doCreateItem(2486, 1, v[3])
        doSendMagicEffect(v[3], v[4])
    end
   
        for i = 1, #t do
        local v = t[i]
        if getItemDescriptions(2486) then
        doRemoveItem(cid)
        doCreateItem(13498, 1, v[3])
        doSendMagicEffect(v[3], v[4])
    end
    return true
    end
    return true
end

I want the 2 actions to apply in a different time like doCreateItem(2486, 1, v[3]) and after 2 seconds
if getItemDescriptions(2486) then
doRemoveItem(cid)
doCreateItem(13498, 1, v[3])
 
Back
Top