Skip to content

Commit

Permalink
Time-base reset limiter, spawn default vehicle if none selected
Browse files Browse the repository at this point in the history
  also motd disabling and some config changes
  • Loading branch information
vJoeyz committed Aug 24, 2020
1 parent ba7f969 commit 8b3e1c1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# Uncle Joey's Base
Uncle Joey's Base provides some essential client-side addons for your BeamMP server, such as:
- a message of the day (MOTD)
- player restrictions (limiting respawns, resets, menu options etc.)
- realtime time syncing
Uncle Joey's Base provides some essential client-side addons for your BeamMP server, including:
- A message of the day with BBCode support (motd)
- Player restrictions (limiting rewinds, menu options etc.)
- Limiting resets to a certain amount per time
- Day / night time syncing

## Getting started
1. Download the latest release
2. Place the .zip file in your `Resources/Client` folder of your BeamMP server
3. Configure the addon using the `settings/config.lua` file
4. Optionally add or replace images (supports gifs) in the `ui/uj_base` folder
4. Optionally add or replace images in the `ui/uj_base` folder

### MOTD BBCodes
You can use BBCodes in your MOTD, `config.lua` contains a sample.
`[url] [forumurl] [ico] [h1] [h2] [h3] [h4] [h5] [img] [action] [list] [olist] [strike] [code] [br] [attach] [MEDIA=youtube] [size] [color] [hr] [spoiler] [font] [left] [center] [right]` -- I think that's all
### Motd BBCodes
You can use BBCodes in your motd, `config.lua` contains a sample.
`[url] [forumurl] [ico] [h1] [h2] [h3] [h4] [h5] [h6] [img] [action] [list] [olist] [strike] [code] [br] [MEDIA=youtube] [size] [color] [hr] [spoiler] [font] [left] [center] [right]` -- I think that's all 😊


## Questions, Feature requests & Bugs
Please create an issue here on GitHub.

## Impressions
## Some impressions
![](https://i.imgur.com/ZcNJnBb.png)
![](https://i.imgur.com/EOWs6Xu.png)
![](https://i.imgur.com/dUdR08Z.png)
2 changes: 1 addition & 1 deletion lua/ge/extensions/uj_base/ge_main.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
local a={}local b=1;local c=0;local d,e;local function f()if e.restrictActions then extensions.core_input_actionFilter.setGroup('uj_base',e.disabledActions)extensions.core_input_actionFilter.addAction(0,'uj_base',true)log("I",d.name,"disabled "..#e.disabledActions.." actions")end end;local function g()guihooks.trigger('ScenarioChange',{name=e.motd.title,description=e.motd.description,introType=e.motd.type})end;local function h(i,j)local k=core_environment.getTimeOfDay()k.time=math.abs(i+j/60-12)/12*0.5;core_environment.setTimeOfDay(k)end;local function l()if e.setTime then local m=os.date("!*t",os.time()+e.timeOffsetHours*60*60)h(m.hour,m.min)end end;local function n(j)if e.syncTime and e.setTime then local m=os.date("!*t",os.time()+(e.timeOffsetHours*60+j)*60)h(m.hour,m.min)end end;local function o()d=jsonReadFile("settings/resource.json")e=require("settings/config")guihooks.trigger("ChangeState",{state="scenario-start"})if e.restrictMenu then extensions.core_gamestate.setGameState("scenario","freeroam","uj_base")end;f()l()log("I",d.name,"version "..d.version.." loaded")end;local function p()extensions.core_input_actionFilter.addAction(0,'uj_base',false)extensions.core_gamestate.setGameState("freeroam","freeroam","freeroam")log("I",d.name,"version "..d.version.." unloaded, goodbye!")end;local function q(r,s,t)c=c+r;if c>=b then n(c/60)end end;local function u(v)g()end;local function w(x)if e.motd.type=="selectableVehicle"then g()if x.model and x.config then local y=createPlayerSpawningData(x.model,x.config,x.color,x.licenseText)local z=be:getPlayerVehicle(0)if z then core_vehicles.replaceVehicle(y.model,y.options)else core_vehicles.spawnNewVehicle(y.model,y.options)end;freezeAll(1)end end end;a.onExtensionLoaded=o;a.onExtensionUnloaded=p;a.onUpdate=q;a.onScenarioUIReady=u;a.onVehicleSelected=w;return a
local a={}local b=1;local c=0;local d=0;local e,f,g,h;local function i()if f.restrictActions then extensions.core_input_actionFilter.setGroup('uj_base',f.disabledActions)extensions.core_input_actionFilter.addAction(0,'uj_base',true)log("I",e.name,"disabled "..#f.disabledActions.." actions")end end;local function j()if f.motd.enabled then guihooks.trigger('ScenarioChange',{name=f.motd.title,description=f.motd.description,introType=f.motd.type})end end;local function k(l,m)local n=core_environment.getTimeOfDay()n.time=math.abs(l+m/60-12)/12*0.5;core_environment.setTimeOfDay(n)end;local function o()if f.timesync.enabled then local p=os.date("!*t",os.time()+f.timesync.offsetHours*60*60)k(p.hour,p.min)end end;local function q(m)if f.timesync.realtime and f.timesync.enabled then local p=os.date("!*t",os.time()+(f.timesync.offsetHours*60+m)*60)k(p.hour,p.min)end end;local function r(s)if not f.reset.enabled then guihooks.trigger('toastrMsg',{type="warning",title=f.reset.title,msg=f.reset.disabledMessage,config={timeOut=f.messageDuration}})return end;if d>=f.reset.timeout or f.reset.timeout==-1 then d=0;be:resetVehicle(s)else local t=f.reset.message;t=t:gsub("{secondsLeft}",math.floor(f.reset.timeout-d))guihooks.trigger('toastrMsg',{type="warning",title=f.reset.title,msg=t,config={timeOut=f.messageDuration}})end end;local function u()g=extensions.freeroam_freeroam.onResetGameplay;extensions.freeroam_freeroam.onResetGameplay=r end;local function v()e=jsonReadFile("settings/resource.json")f=require("settings/config")log("I",e.name,"version "..e.version.." loaded")if f.motd.enabled then guihooks.trigger("ChangeState",{state="scenario-start"})end;if f.restrictMenu then extensions.core_gamestate.setGameState("scenario","freeroam","uj_base")end;i()o()u()end;local function w()extensions.core_input_actionFilter.addAction(0,'uj_base',false)extensions.core_gamestate.setGameState("freeroam","freeroam","freeroam")extensions.freeroam_freeroam.onResetGameplay=g;log("I",e.name,"version "..e.version.." unloaded, goodbye!")end;local function x(y,z,A)c=c+y;d=d+y;if c>=b then q(c/60)end end;local function B(C,D)local E=be:getPlayerVehicle(0)if E then core_vehicles.replaceVehicle(C,D)else core_vehicles.spawnNewVehicle(C,D)end end;local function F(G)if G=="start"then j()elseif G=="play"then if not h then B("pickup",{})end end end;local function H(I)if f.motd.type=="selectableVehicle"then j()if I.model and I.config then local J=createPlayerSpawningData(I.model,I.config,I.color,I.licenseText)B(J.model,J.options)h=true end end end;a.onExtensionLoaded=v;a.onExtensionUnloaded=w;a.onUpdate=x;a.onScenarioUIReady=F;a.onVehicleSelected=H;a.trackVehReset=trackVehReset;return a
21 changes: 15 additions & 6 deletions settings/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Please do not redistribute
]]--

local config = {}
config.reset = {}
config.motd = {}
config.timesync = {}

config.messageDuration = 6000 -- global toast message duration in ms

config.restrictMenu = true -- enables or disables (side-)menu for mods, spawning vehicles, tuning, environment, trackbuilder and replay

Expand All @@ -23,11 +28,15 @@ config.disabledActions = {
"faster_motion", -- speeds up time
"toggle_slow_motion", -- slows time down or resets if back to real time
"dropPlayerAtCamera", -- puts the player at the camera
"reset_all_physics", -- restarts physics of all vehicles (reset)
"reset_physics", -- restarts the current scenario
}

config.motd = {}
config.reset.enabled = true -- enables or disables vehicle reset
config.reset.timeout = 30 -- how often a vehicle can be reset, -1 for no limit
config.reset.title = "Vehicle Reset Limiter" -- title shown when resetting is restricted
config.reset.message = "You can reset your vehicle in {secondsLeft} seconds." -- message shown when resetting is restricted
config.reset.disabledMessage = "Vehicle resetting is disabled on this server." -- message shown when resetting is completely disabled

config.motd.enabled = true -- enables or disables the motd
config.motd.type = "selectableVehicle" -- htmlOnly: simple (large) bbcode-only motd || selectableVehicle: motd with the ability to select a vehicle
config.motd.title = "Welcome to a BeamMP server!"
config.motd.description = [[
Expand All @@ -47,8 +56,8 @@ config.motd.description = [[
[color=#FFC0CB][i][right]Made by vJoeyz#5115[/right][/i][/color]
]] -- all bbcodes can be found in the README

config.setTime = true -- enables or disables in-game time syncing to real world time
config.timeOffsetHours = 0 -- 0 for utc, can be positive (+) or negative (-)
config.syncTime = true -- whether in-game time should be actively synced with real world time (only works when settime = true)
config.timesync.enabled = true -- enables or disables in-game time syncing to real world time
config.timesync.offsetHours = 0 -- 0 for utc, can be positive or negative (-)
config.timesync.realtime = true -- whether in-game time should be actively synced with real world time (only works when timesync.enabled = true)

return config
3 changes: 2 additions & 1 deletion settings/resource.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "uj_base",
"version": "1.0.0",
"version": "1.0.1",
"url": "https://github.com/vJoeyz/uj_base",
"author": "vJoeyz#5115 (Uncle Joey)"
}

0 comments on commit 8b3e1c1

Please sign in to comment.