• 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 Changing game mode on certain days?

dominique120

Science & Reason
Senator
Premium User
Joined
Jun 16, 2013
Messages
3,881
Solutions
3
Reaction score
1,046
Location
Númenor
Is there a way to make the game switch from no-pvp to pvp and back on certain days? I want to make an event called pvp mondays, and have the other days stay on no pvp

TFS is 0.3.6
 
Code:
local t = {
    ["Friday"] = {WORLDTYPE_OPTIONAL, "Optional PvP"},
    ["Saturday"] = {WORLDTYPE_OPEN, "Open PvP"},
    ["Sunday"] = {WORLDTYPE_HARDCORE, "Hardcore PvP"}
}

function onTime()
local v = t[os.date("%A")]
    if v then
        setWorldType(v[1])
        doBroadcastMessage("Gameworld type set to: " .. v[2] .. ".", MESSAGE_EVENT_ADVANCE)
    end
    return true
end
 
Last edited:
Musst i put this in Globalevents ?

Cann i make this too for hours ??
Always Open Pvp and
Monday are from 18:00-19:00 clock is Hardcore PVP.
And Tuesday is Optional PVp for 8 Hours.

I want that script too :D
 
Last edited:
Musst i put this in Globalevents ?

Cann i make this too for hours ??
Always Open Pvp and
Monday are from 18:00-19:00 clock is Hardcore PVP.
And Tuesday is Optional PVp for 8 Hours.

I want that script too :D

Use the function os.time() insted of os.date()
WibbenZ
 
Code:
local t = {
    ["Friday"] = {WORLDTYPE_OPTIONAL, "Optional PvP"},
    ["Saturday"] = {WORLDTYPE_OPEN, "Open PvP"},
    ["Sunday"] = {WORLDTYPE_HARDCORE, "Hardcore PvP"}
}

function onTime()
local v = t[os.date("%A")]
    setWorldType(v[1])
    doBroadcastMessage("Gameworld type set to: " .. v[2] .. ".", MESSAGE_EVENT_ADVANCE)
    return true
end

How would I make it broadcast every two hours? Can we do it with an if statement in this same script or does it have to be done with a separate script? What type pf global event is this?
 
Ohh and will the script change back to no-pvp when it is no longer Monday?

I have this:

Code:
local t = {
    ["Monday"] = {WORLDTYPE_OPEN, "Open PvP"}
}

function onTime()
local v = t[os.date("%A")]
    setWorldType(v[1])
    doBroadcastMessage("Gameworld type set to: " .. v[2] .. ".", MESSAGE_EVENT_ADVANCE)
    return true
end
 
Ohh and will the script change back to no-pvp when it is no longer Monday?

I have this:

Code:
local t = {
    ["Monday"] = {WORLDTYPE_OPEN, "Open PvP"}
}

function onTime()
local v = t[os.date("%A")]
    setWorldType(v[1])
    doBroadcastMessage("Gameworld type set to: " .. v[2] .. ".", MESSAGE_EVENT_ADVANCE)
    return true
end
You can add a second day (e.g tuesday) which sets it to optional pvp.
 
You can add a second day (e.g tuesday) which sets it to optional pvp.

Code:
local t = {
    ["Monday"] = {WORLDTYPE_OPEN, "Open PvP"},
    ["Tuesday"] = {WORLDTYPE_OPTIONAL, "Optional PvP"}
}

function onTime()
local v = t[os.date("%A")]
    setWorldType(v[1])
    doBroadcastMessage("Gameworld type set to: " .. v[2] .. ".", MESSAGE_EVENT_ADVANCE)
    return true
end

Like this? And with what type do I register it in globalevents.xml?
 
You register it as time in globalevents.xml
Code:
<globalevent name="worldtype" time="00:00" event="script" value="worldtype.lua"/>
You could use onThink (interval instead of time) otherwise. :p
 
You register it as time in globalevents.xml
Code:
<globalevent name="worldtype" time="00:00" event="script" value="worldtype.lua"/>
You could use onThink (interval instead of time) otherwise. :p

I'll test it out. Does TFS get the date and time from the OS? If I modify the date will TFS see the change, and act accordingly?
 
I got this:
[25/10/2013 14:50:56] [Warning - Event::loadScript] Event onTimer not found (data/globalevents/scripts/worldtype.lua)
So I changed onTime to onTimer. I get no errors now
 
Cann i make Hardcore PVP for a Area ???

I want to make a small Hardcore PVP arena
and when someone enter the Arena a message should appear.
Like you entered the Hardcore Pvp arena

function onstep e.t.c
 
Cann i make Hardcore PVP for a Area ???

I want to make a small Hardcore PVP arena
and when someone enter the Arena a message should appear.
Like you entered the Hardcore Pvp arena

function onstep e.t.c

On my no-pvp serv I use pvp tiles from the map editor for that, and it would be great IF YOU STOPPED HIGHJACKING MY THREADS lol
 
I traveled in time and I bring good new, it works. Thanks!

How would I get it to broadcast when its is not Monday anymore?
 
I may have run into a hiccup. I get this:


Code:
[26/10/2013 00:00:00] [Error - GlobalEvent Interface]
[26/10/2013 00:00:00] data/globalevents/scripts/worldtype.lua:onTimer
[26/10/2013 00:00:00] Description:
[26/10/2013 00:00:01] data/globalevents/scripts/worldtype.lua:8: attempt to index local 'v' (a nil value)
[26/10/2013 00:00:01] stack traceback:
[26/10/2013 00:00:01]    data/globalevents/scripts/worldtype.lua:8: in function <data/globalevents/scripts/worldtype.lua:6>
[26/10/2013 00:00:01] [Error - GlobalEvents::timer] Couldn't execute event: worldtype

It was exactly at twelve so I suppose it does not know what to do because I only put in two days right?

Code:
local t = {
    ["Monday"] = {WORLDTYPE_OPEN, "Open PvP"},
    ["Tuesday"] = {WORLDTYPE_OPTIONAL, "Optional PvP"}
}

function onTimer()
local v = t[os.date("%A")]
    setWorldType(v[1])
    doBroadcastMessage("Its Monday, that means its time to get out there and KILL!", MESSAGE_EVENT_ADVANCE)
    return true
end
 
Code:
local t = {
    ["Monday"] = {WORLDTYPE_OPEN, "Its Monday, that means its time to get out there and KILL!"},
    ["Tuesday"] = {WORLDTYPE_OPTIONAL, "Blabla"}
}

function onTimer()
local v = t[os.date("%A")]
    if v then
        setWorldType(v[1])
        doBroadcastMessage(v[2], MESSAGE_EVENT_ADVANCE)
    end
    return true
end
 

Similar threads

  • Question Question
RevScripts BLOCK MC PVP
Replies
4
Views
682
Back
Top