Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated repo #672

Merged
merged 1 commit into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 1 addition & 60 deletions vrp/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,72 +112,13 @@ local lang = vRP.lang
-- Base extension
local Base = class("Base", vRP.Extension)

-- PRIVATE METHODS

-- menu: characters
local function menu_characters(self)
local function m_use(menu, cid)
local user = menu.user
local ok, err = user:useCharacter(cid)
if not ok then
if err <= 2 then
self.remote._notify(user.source, lang.common.must_wait({user.use_character_action:remaining()}))
else
self.remote._notify(user.source, lang.characters.character.error())
end
end
end
local function m_create(menu)
local user = menu.user
if user:createCharacter() then
user:actualizeMenu()
else
self.remote._notify(user.source, lang.characters.create.error())
end
end
local function m_delete(menu)
local user = menu.user
local cid = parseInt(user:prompt(lang.characters.delete.prompt(), ""))
if user:deleteCharacter(cid) then
user:actualizeMenu()
else
self.remote._notify(user.source, lang.characters.delete.error({cid}))
end
end
vRP.EXT.GUI:registerMenuBuilder("characters", function(menu)
local user = menu.user
menu.title = lang.characters.title()
menu.css.header_color = "rgba(0,125,255,0.75)"
-- characters
local characters = user:getCharacters()
for _, cid in pairs(characters) do
local identity = vRP.EXT.Identity:getIdentity(cid)
local prefix
if cid == user.cid then prefix = "* " else prefix = "" end
menu:addOption(prefix..lang.characters.character.title({cid, htmlEntities.encode(identity and identity.name or ""), htmlEntities.encode(identity and identity.firstname or "")}), m_use, nil, cid)
end
menu:addOption(lang.characters.create.title(), m_create)
menu:addOption(lang.characters.delete.title(), m_delete)
end)
end

-- EVENT

Base.event = {}

function Base.event:extensionLoad(ext)
if ext == vRP.EXT.GUI then
menu_characters(self)

local function m_characters(menu)
menu.user:openMenu("characters")
end

vRP.EXT.GUI:registerMenuBuilder("main", function(menu)
if menu.user:hasPermission("player.characters") then
menu:addOption(lang.characters.title(), m_characters)
end
end)

elseif ext == vRP.EXT.Group then
-- register fperm inside
vRP.EXT.Group:registerPermissionFunction("inside", function(user, params)
Expand Down
7 changes: 7 additions & 0 deletions vrp/vRP.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ function vRP:__construct()
self:save()
end
task_save()

--print([[
--██ ██ ██████ ██████
--██ ██ ██ ██ ██ ██
--██ ██ ██████ ██████
-- ██ ██ ██ ██ ██
-- ████ ██ ██ ██ ]])
end

-- register a DB driver
Expand Down