Imported everything.

This commit is contained in:
flash 2025-05-10 22:29:17 +00:00
commit 607be89e35
2185 changed files with 573466 additions and 0 deletions

6
.gitattributes vendored Normal file
View file

@ -0,0 +1,6 @@
* text=auto eol=lf
# Ignored files by `git archive`
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

View file

@ -0,0 +1,10 @@
Directory layout for MTA:SA resources
---------------------------------------------
Important things to note:
* Any directory surrounded with [...] will be assumed to contain further directories and resources.
* The directory layout is to assist organising resources in the server directory only. Internally MTA:SA still sees all the resources in a big flat list.
* Therefore, do not use the [...] paths in script or config files.
* Therefore, you can move resources around without having to worry about [...] paths.
* But, a resource will not load if it exists twice anywhere in the directory hierarchy.
* And finally, this is only a suggested layout. You can move stuff around, but it's probably best to leave the official resources where they are for simpler updating.

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2008-2020 mtasa-resources contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

15
README.md Normal file
View file

@ -0,0 +1,15 @@
# Resources
Resources are a key part of [Multi Theft Auto](https://github.com/multitheftauto). A resource is essentially a folder or zip file that contains a collection of files - including essential script and content files, plus a meta file that describes how the resource should be loaded - and runs on a Multi Theft Auto dedicated server.
A resource can be seen as being partly equivalent to a program running in an operating system - it can be started and stopped, and multiple resources can run at once. It's worth remembering, though, that unlike programs on an operating system, there is no multi-tasking between resources. Resources generally contain content and Lua scripts for game modes, user interfaces, and other tasks affecting the players that are connected to the dedicated server on which the resources are running.
This project maintains a list of up-to-date resources that come with Multi Theft Auto. These can be checked out by anyone who wishes to run a dedicated server with the latest resources. To learn about every resource in this repository, visit the [Default resources Wiki Page](https://wiki.multitheftauto.com/wiki/Default_resources).
For a collection of user-created resources, head over to our [Community](https://community.multitheftauto.com) web page which serves as a place for hosting our community's resources.
To report a bug or suggest an idea, [please submit a GitHub issue](https://github.com/multitheftauto/mtasa-resources/issues/new/choose). To understand the entire development cycle and process of this project, read the [Contributing Guide](https://github.com/multitheftauto/mtasa-docs/blob/main/mtasa-resources/CONTRIBUTING.md).
## License
Unless otherwise specified, all source code hosted in this repository is licensed under the MIT license. See the LICENSE file for more details.

460
[admin]/acpanel/_common.lua Normal file
View file

@ -0,0 +1,460 @@
--
-- Anti-Cheat Control Panel
--
-- _common.lua
--
_version = "0.1.8"
MIN_CLIENT_VERSION_FOR_MOD_BLOCKS = "1.3.1-9.04818"
function outputDebug(msg)
msg = getTickCount() .. " " .. msg
outputDebugString(msg)
end
function stripColorCodes ( text )
return string.gsub ( text, '#%x%x%x%x%x%x', '' )
end
function table.find(t, ...)
local args = { ... }
if #args == 0 then
for k,v in pairs(t) do
if v then
return k, v
end
end
return false
end
local value = table.remove(args)
if value == '[nil]' then
value = nil
end
for k,v in pairs(t) do
for i,index in ipairs(args) do
if type(index) == 'function' then
v = index(v)
else
if index == '[last]' then
index = #v
end
v = v[index]
end
end
if v == value then
return k, t[k]
end
end
return false
end
function math.bit(p)
return 2 ^ (p - 1) -- 1-based indexing
end
-- Typical call: if hasbit(x, bit(3)) then ...
function math.hasbit(x, p)
return x % (p + p) >= p
end
newline = "\n"
colorYellow = {255,255,0}
colorGreen = {128,255,128}
colorRed = {255,128,128}
colorGrey = {128,128,128}
colorLtGrey = {192,192,192}
colorWhite = {255,255,255}
---------------------------------------------------------------------------
---------------------------------------------------------------------------
---------------------------------------------------------------------------
aBlockModsTab_presets = {
none = "",
all = "*",
modelsAnims = ".ifp" .. newline ..
".dff",
weaponModels = "grenade.dff" .. newline ..
"teargas.dff" .. newline ..
"molotov.dff" .. newline ..
"colt45.dff" .. newline ..
"silenced.dff" .. newline ..
"desert_eagle.dff" .. newline ..
"chromegun.dff" .. newline ..
"sawnoff.dff" .. newline ..
"shotgspa.dff" .. newline ..
"micro_uzi.dff" .. newline ..
"mp5lng.dff" .. newline ..
"ak47.dff" .. newline ..
"m4.dff" .. newline ..
"cuntgun.dff" .. newline ..
"rocketla.dff" .. newline ..
"heatseek.dff" .. newline ..
"flame.dff" .. newline ..
"minigun.dff" .. newline ..
"satchel.dff" .. newline ..
"tec9.dff" .. newline ..
"sniper.dff",
playerModels =
[[cj.dff
truth.dff
maccer.dff
andre.dff
bbthin.dff
bb.dff
emmet.dff
male01.dff
janitor.dff
bfori.dff
bfost.dff
vbfycrp.dff
bfyri.dff
bfyst.dff
bmori.dff
bmost.dff
bmyap.dff
bmybu.dff
bmybe.dff
bmydj.dff
bmyri.dff
bmycr.dff
bmyst.dff
wmybmx.dff
wbdyg1.dff
wbdyg2.dff
wmybp.dff
wmycon.dff
bmydrug.dff
wmydrug.dff
hmydrug.dff
dwfolc.dff
dwmolc1.dff
dwmolc2.dff
dwmylc1.dff
hmogar.dff
wmygol1.dff
wmygol2.dff
hfori.dff
hfost.dff
hfyri.dff
hfyst.dff
jethro.dff
hmori.dff
hmost.dff
hmybe.dff
hmyri.dff
hmycr.dff
hmyst.dff
omokung.dff
wmymech.dff
bmymoun.dff
wmymoun.dff
ofost.dff
ofyri.dff
ofyst.dff
omori.dff
omost.dff
omyri.dff
omyst.dff
wmyplt.dff
wmopj.dff
bfypro.dff
hfypro.dff
kendl.dff
bmypol1.dff
bmypol2.dff
wmoprea.dff
sbfyst.dff
wmosci.dff
wmysgrd.dff
swmyhp1.dff
swmyhp2.dff
swfopro.dff
wfystew.dff
swmotr1.dff
wmotr1.dff
bmotr1.dff
vbmybox.dff
vwmybox.dff
vhmyelv.dff
vbmyelv.dff
vimyelv.dff
vwfypro.dff
ryder3.dff
vwfyst1.dff
wfori.dff
wfost.dff
wfyjg.dff
wfyri.dff
wfyro.dff
wfyst.dff
wmori.dff
wmost.dff
wmyjg.dff
wmylg.dff
wmyri.dff
wmyro.dff
wmycr.dff
wmyst.dff
ballas1.dff
ballas2.dff
ballas3.dff
fam1.dff
fam2.dff
fam3.dff
lsv1.dff
lsv2.dff
lsv3.dff
maffa.dff
maffb.dff
mafboss.dff
vla1.dff
vla2.dff
vla3.dff
triada.dff
triadb.dff
sindaco.dff
triboss.dff
dnb1.dff
dnb2.dff
dnb3.dff
vmaff1.dff
vmaff2.dff
vmaff3.dff
vmaff4.dff
dnmylc.dff
dnfolc1.dff
dnfolc2.dff
dnfylc.dff
dnmolc1.dff
dnmolc2.dff
sbmotr2.dff
swmotr2.dff
sbmytr3.dff
swmotr3.dff
wfybe.dff
bfybe.dff
hfybe.dff
sofybu.dff
sbmyst.dff
sbmycr.dff
bmycg.dff
wfycrk.dff
hmycm.dff
wmybu.dff
bfybu.dff
smokev.dff
wfybu.dff
dwfylc1.dff
wfypro.dff
wmyconb.dff
wmybe.dff
wmypizz.dff
bmobar.dff
cwfyhb.dff
cwmofr.dff
cwmohb1.dff
cwmohb2.dff
cwmyfr.dff
cwmyhb1.dff
bmyboun.dff
wmyboun.dff
wmomib.dff
bmymib.dff
wmybell.dff
bmochil.dff
sofyri.dff
somyst.dff
vwmybjd.dff
vwfycrp.dff
sfr1.dff
sfr2.dff
sfr3.dff
bmybar.dff
wmybar.dff
wfysex.dff
wmyammo.dff
bmytatt.dff
vwmycr.dff
vbmocd.dff
vbmycr.dff
vhmycr.dff
sbmyri.dff
somyri.dff
somybu.dff
swmyst.dff
wmyva.dff
copgrl3.dff
gungrl3.dff
mecgrl3.dff
nurgrl3.dff
crogrl3.dff
gangrl3.dff
cwfofr.dff
cwfohb.dff
cwfyfr1.dff
cwfyfr2.dff
cwmyhb2.dff
dwfylc2.dff
dwmylc2.dff
omykara.dff
wmykara.dff
wfyburg.dff
vwmycd.dff
vhfypro.dff
suzie.dff
omonood.dff
omoboat.dff
wfyclot.dff
vwmotr1.dff
vwmotr2.dff
vwfywai.dff
sbfori.dff
swfyri.dff
wmyclot.dff
sbfost.dff
sbfyri.dff
sbmocd.dff
sbmori.dff
sbmost.dff
shmycr.dff
sofori.dff
sofost.dff
sofyst.dff
somobu.dff
somori.dff
somost.dff
swmotr5.dff
swfori.dff
swfost.dff
swfyst.dff
swmocd.dff
swmori.dff
swmost.dff
shfypro.dff
sbfypro.dff
swmotr4.dff
swmyri.dff
smyst.dff
smyst2.dff
sfypro.dff
vbfyst2.dff
vbfypro.dff
vhfyst3.dff
bikera.dff
bikerb.dff
bmypimp.dff
swmycr.dff
wfylg.dff
wmyva2.dff
bmosec.dff
bikdrug.dff
wmych.dff
sbfystr.dff
swfystr.dff
heck1.dff
heck2.dff
bmycon.dff
wmycd1.dff
bmocd.dff
vwfywa2.dff
wmoice.dff
tenpen.dff
pulaski.dff
Hernandez.dff
dwayne.dff
smoke.dff
sweet.dff
ryder.dff
forelli.dff
tbone.dff
laemt1.dff
lvemt1.dff
sfemt1.dff
lafd1.dff
lvfd1.dff
sffd1.dff
lapd1.dff
sfpd1.dff
lvpd1.dff
csher.dff
lapdm1.dff
swat.dff
fbi.dff
army.dff
dsher.dff
zero.dff
rose.dff
paul.dff
cesar.dff
ogloc.dff
wuzimu.dff
torino.dff
jizzy.dff
maddogg.dff
cat.dff
claude.dff]]
}
aBlockModsTab = {
radioButtons = {
{ type="none", desc="None", color=colorRed, button=false, custom=false, text=aBlockModsTab_presets.none },
{ type="all", desc="All", color=colorGreen, button=false, custom=false, text=aBlockModsTab_presets.all },
{ type="models_anims", desc="Models+Anims", color=colorWhite, button=false, custom=false, text=aBlockModsTab_presets.modelsAnims },
{ type="weapons", desc="Some weapons", color=colorWhite, button=false, custom=false, text=aBlockModsTab_presets.weaponModels },
{ type="players", desc="Player Models", color=colorWhite, button=false, custom=false, text=aBlockModsTab_presets.playerModels },
{ type="custom", desc="Custom", color=colorWhite, button=false, custom=true, text="" },
}
}
function aBlockModsTab.getInfoForType(type)
for _,info in ipairs(aBlockModsTab.radioButtons) do
if info.type == type then
return info
end
end
end
---------------------------------------------------------------------------
---------------------------------------------------------------------------
---------------------------------------------------------------------------
aServerConfigTab_presets = {
none = "",
maxMinClient = "1.3.1-9.04835",
release = "1.3.1-9.04709",
}
aServerConfigTab = {
radioButtons = {
{ type="none", desc="None", color=colorRed, button=false, custom=false, text=aServerConfigTab_presets.none },
{ type="latest", desc="Latest anti-cheat defs", color=colorGreen, button=false, custom=false, text=aServerConfigTab_presets.maxMinClient },
{ type="release", desc="Current release version", color=colorWhite, button=false, custom=false, text=aServerConfigTab_presets.release },
{ type="custom", desc="Custom", color=colorWhite, button=false, custom=true, text="" },
}
}
function aServerConfigTab.getInfoForType(type)
for _,info in ipairs(aServerConfigTab.radioButtons) do
if info.type == type then
return info
end
end
end

99
[admin]/acpanel/c_gui.lua Normal file
View file

@ -0,0 +1,99 @@
--
-- Anti-Cheat Control Panel
--
-- c_gui.lua
--
aAdminMain = {
Form = nil,
Panel = nil,
Tabs = {},
Tab = nil,
Refresh = 0,
Hidden = false
}
g_serverConfigSettings = {}
addEvent ( "onAdminInitialize", true )
addEvent ( "onAdminRefresh", false )
addEvent ( "onAcpClientInitialSettings", true )
addEventHandler ( "onAcpClientInitialSettings", resourceRoot,
function ( serverConfigSettings )
g_serverConfigSettings = serverConfigSettings;
end
)
function getServerConfigSetting(name)
return g_serverConfigSettings[name]
end
addEvent ( "aClientAcMenu", true )
addEventHandler ( "aClientAcMenu", resourceRoot,
function ( mode )
if ( ( ( aAdminMain.Form ) and ( guiGetVisible ( aAdminMain.Form ) == true ) ) or ( aAdminMain.Hidden ) or mode == "close" ) then
aAdminMain.Close ( false )
else
aAdminMain.Open ()
end
end
)
function aAdminMain.Open ()
if ( aAdminMain.Form == nil ) then
local x, y = guiGetScreenSize()
aAdminMain.Form = guiCreateWindow ( x / 2 - 310 - 20, y / 2 - 260 - 20, 620, 520, "Anti-Cheat Panel - v".._version, false )
aAdminMain.Panel = guiCreateTabPanel ( 0.01, 0.05, 0.98, 0.95, true, aAdminMain.Form )
aAdminMain.AddTab ( "Status", aAntiCheatTab, "anticheat" )
aAdminMain.AddTab ( "Status #2", aAntiCheatTab2, "anticheat" )
aAdminMain.AddTab ( "Block Img Mods", aBlockModsTab, "mods" )
aAdminMain.AddTab ( "Server Config", aServerConfigTab, "server" )
addEventHandler ( "onClientGUITabSwitched", resourceRoot, aAdminMain.Switch )
addEventHandler ( "onAdminInitialize", aAdminMain.Form, aAdminMain.Initialize )
triggerEvent ( "onAdminInitialize", aAdminMain.Form )
end
guiSetAlpha ( aAdminMain.Form, 1 )
guiSetVisible ( aAdminMain.Form, true )
guiSetInputMode( "no_binds_when_editing" )
showCursor ( true )
aAdminMain.Hidden = false
end
function aAdminMain.Close ()
guiSetVisible ( aAdminMain.Form, false )
showCursor ( false )
end
function aAdminMain.Initialize ()
if ( #aAdminMain.Tabs > 0 ) then
aAdminMain.Switch ( aAdminMain.Tabs[1].Tab )
end
end
function aAdminMain.Switch ( tab )
aAdminMain.Tab = tab
local id = aAdminMain.GetTab ( tab )
if ( id ) then
if ( not aAdminMain.Tabs[id].Loaded ) then
aAdminMain.Tabs[id].Class.Create ( tab )
aAdminMain.Tabs[id].Loaded = true
end
end
end
function aAdminMain.AddTab ( name, class, acl )
local tab = guiCreateTab ( name, aAdminMain.Panel, acl )
table.insert ( aAdminMain.Tabs, { Tab = tab, Class = class, Loaded = false } )
end
function aAdminMain.GetTab ( tab )
for k, v in ipairs ( aAdminMain.Tabs ) do
if ( v.Tab == tab ) then return k end
end
return nil
end

View file

@ -0,0 +1,139 @@
--
-- Anti-Cheat Control Panel
--
-- c_gui_ac.lua
--
aAntiCheatTab = {
}
function aAntiCheatTab.Create ( tab )
aAntiCheatTab.Tab = tab
xpos = 20
ypos = 10
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- AC list
------------------------------------------------------------------------------
------------------------------------------------------------------------------
local acInfoList = {
{ id=1, desc="Classic health/armour hack detector" },
{ id=4, desc="Detects presence of trainer. Capital letters in the message are for tagging particular trainers" },
{ id=5, desc="Detects use of trainer." },
{ id=6, desc="Detects use of trainer incl.: player movement, health/damage, weapons, money, gamespeed, game cheats, aimbot" },
{ id=7, desc="Detects use of trainer." },
{ id=8, desc="Detects unauthorized mods. Capital letters in the message are for tagging particular items e.g. CLEO - Cleo detected, RENDER - Wall hack detected" },
{ id=11, desc="Dll injector / Trainer" },
{ id=13, desc="Data files issue" },
{ id=17, desc="Speed / wall hacks" },
{ id=18, desc="Modifed game files" },
{ id=21, desc="Trainers / custom gta_sa.exe" },
{ id=26, desc="Anti-cheat component blocked" },
}
local disabledAcDesc = getServerConfigSetting( "disableac" )
--outputDebug( "disabledAcDesc" .. tostring(disabledAcDesc) )
disabledAcList = split(disabledAcDesc, ",")
local label1 = guiCreateLabel ( xpos, ypos, 100, 16, "AC settings:", false, tab )
guiSetFont(label1, "default-bold-small" )
ypos = ypos + 17
for _,info in ipairs(acInfoList) do
local bEnabled = not table.find(disabledAcList, tostring(info.id))
local label4 = guiCreateLabel ( xpos, ypos, 50, 16, "AC #" .. info.id, false, tab )
local label2 = guiCreateLabel ( xpos+70, ypos, 50, 16, bEnabled and "ON" or "OFF", false, tab )
local label3 = guiCreateLabel ( xpos+110, ypos, 450, 16, "( "..info.desc.." )", false, tab )
if bEnabled then
guiLabelSetColor(label2, unpack(colorGreen) )
else
guiLabelSetColor(label2, unpack(colorRed) )
guiSetFont(label2, "default-bold-small" )
end
guiLabelSetColor(label3, unpack(colorGrey) )
ypos = ypos + 14
end
ypos = ypos + 5
local msg = "To turn OFF an AC#, add number to <disableac> setting in mtaserver.conf and restart server"
local label5 = guiCreateLabel ( xpos, ypos, 700, 16, msg, false, tab )
guiLabelSetColor(label5, unpack(colorYellow) )
guiSetFont(label5, "default-bold-small" )
ypos = ypos + 25
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- SD list
------------------------------------------------------------------------------
------------------------------------------------------------------------------
local sdInfoList = {
{ id=12, sver="1.3.1", cver="1.3.1", desc="Disallow custom D3D9.DLL" },
{ id=14, sver="1.3.1-9.04605", cver="1.3.1-9.04605", desc="Disallow virtual machines such as VMWare" },
{ id=15, sver="1.3.1-9.04791", cver="1.3.1-9.04791", desc="Disallow disabled driver signing" },
{ id=16, sver="1.3.1-9.05097", cver="1.3.1-9.05097", desc="Disallow disabled AC components" },
{ id=20, sver="1.3.1-9.05097", cver="1.3.1-9.05097", desc="Disallow modified gta3.img" },
{ id=22, sver="1.3.4-9.05884", cver="1.3.4-9.05884", desc="Disallow resource download errors/corruption (Lua script files)" },
{ id=23, sver="1.3.4-9.05884", cver="1.5.2-9.07911", desc="Disallow resource download errors/corruption (Non-Lua files e.g. png,dff)" },
{ id=28, sver="1.3.4-9.05884", cver="1.3.4-9.05884", desc="Disallow Linux Wine" },
{ id=31, sver="1.5.3", cver="1.5.3-9.11204", desc="Ignore injected keyboard inputs" },
{ id=32, sver="1.5.3", cver="1.5.3-9.11528", desc="Ignore injected mouse button inputs and movement" },
{ id=33, sver="1.5.6", cver="1.5.6", desc="Disallow software of the category 'Net limiter'" },
{ id=34, sver="1.5.6", cver="1.5.6", desc="Disallow internet café users" },
{ id=35, sver="1.5.6", cver="1.5.6", desc="Disallow certain software with \"FPS locking\" capabilities" },
{ id=36, sver="1.5.7", cver="1.5.7", desc="Disallow AutoHotKey base application (used to load .ahk files)" },
}
local enableSdDesc = getServerConfigSetting( "enablesd" )
--outputDebug( "enableSdDesc" .. tostring(enableSdDesc) )
enableSdList = split(enableSdDesc, ",")
local label6 = guiCreateLabel ( xpos, ypos, 100, 16, "SD settings:", false, tab )
guiSetFont(label6, "default-bold-small" )
ypos = ypos + 17
for _,info in ipairs(sdInfoList) do
local bEnabled = table.find(enableSdList, tostring(info.id))
local name = "SD #" .. info.id
local label7 = guiCreateLabel ( xpos, ypos, 50, 16, name, false, tab )
local label8 = guiCreateLabel ( xpos+70, ypos, 50, 16, bEnabled and "ON" or "OFF", false, tab )
local label9 = guiCreateLabel ( xpos+110, ypos, 450, 16, "( "..info.desc.." )", false, tab )
if bEnabled then
guiLabelSetColor(label8, unpack(colorGreen) )
else
guiLabelSetColor(label8, unpack(colorRed) )
guiSetFont(label8, "default-bold-small" )
end
guiLabelSetColor(label9, unpack(colorGrey) )
ypos = ypos + 14
if bEnabled then
if getVersion().sortable < info.sver then
outputChatBox( "Need at least server version " .. info.sver .. " To use " .. name )
end
end
end
ypos = ypos + 5
local msg2 = "To turn ON a SD#, add number to <enablesd> setting in mtaserver.conf and restart server"
local label10 = guiCreateLabel ( xpos, ypos, 700, 16, msg2, false, tab )
guiSetFont(label10, "default-bold-small" )
guiLabelSetColor(label10, unpack(colorYellow) )
ypos = ypos + 25
aAntiCheatTab.Refresh()
end
function aAntiCheatTab.Refresh ()
end

View file

@ -0,0 +1,93 @@
--
-- Anti-Cheat Control Panel
--
-- c_gui_ac2.lua
--
aAntiCheatTab2 = {
}
function aAntiCheatTab2.Create ( tab )
aAntiCheatTab2.Tab = tab
xpos = 20
ypos = 15
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Verify client files
------------------------------------------------------------------------------
------------------------------------------------------------------------------
gtaDataFiles = {
{ 1, "data/animgrp.dat" },
{ 3, "data/ar_stats.dat" },
{ 0, "data/carmods.dat" },
{ 5, "data/clothes.dat" },
{ 7, "data/default.dat" },
{ 9, "data/default.ide" },
{ 11, "data/gta.dat" },
{ 25, "data/maps" },
{ 6, "data/object.dat" },
{ 13, "data/peds.ide" },
{ 15, "data/pedstats.dat" },
{ 17, "data/txdcut.ide" },
{ 14, "data/vehicles.ide" },
{ 20, "data/weapon.dat" },
{ 4, "data/melee.dat" },
{ 16, "data/water.dat" },
{ 18, "data/water1.dat" },
{ 2, "data/handling.cfg" },
{ 19, "models/coll/weapons.col" },
{ 21, "data/plants.dat" },
{ 23, "data/furnitur.dat" },
{ 24, "data/procobj.dat" },
{ 8, "data/surface.dat" },
{ 12, "data/surfinfo.dat" },
{ 22, "anim/ped.ifp" },
}
local msg = "Client files which are allowed to be customized:"
local label1 = guiCreateLabel ( xpos, ypos, 700, 16, msg, false, tab )
ypos = ypos + 30
local gridlist = guiCreateGridList ( xpos, ypos, 300, 386, false, tab )
local col1 = guiGridListAddColumn ( gridlist, "Filename", 0.65 )
local col2 = guiGridListAddColumn ( gridlist, "Status", 0.25 )
local verifyFlagsString = getServerConfigSetting( "verifyclientsettingsstring" )
for _,info in ipairs(gtaDataFiles) do
local id = info[1]
local file = info[2]
local c = string.sub(verifyFlagsString, id+1, id+1 )
local allowed = (c == "1")
-- outputDebug(""
-- .. " included:" .. tostring(included)
-- .. " c:" .. tostring(c)
-- .. " id:" .. tostring(id)
-- .. " file:" .. tostring(file)
-- )
local row = guiGridListAddRow ( gridlist )
guiGridListSetItemText( gridlist, row, col1, file, false, false )
if allowed then
guiGridListSetItemText( gridlist, row, col2, "Allowed", false, false )
guiGridListSetItemColor( gridlist, row, col2, unpack(colorRed) )
else
guiGridListSetItemText( gridlist, row, col2, "Blocked", false, false )
guiGridListSetItemColor( gridlist, row, col2, unpack(colorGreen) )
end
end
aAntiCheatTab2.Refresh()
end
function aAntiCheatTab2.Refresh ()
end

View file

@ -0,0 +1,133 @@
--
-- Anti-Cheat Control Panel
--
-- c_gui_block_mods.lua
--
function aBlockModsTab.Create ( tab )
aBlockModsTab.Tab = tab
xpos = 20
ypos = 10
local label1 = guiCreateLabel ( xpos, ypos, 100, 16, "Img file blocking", false, tab )
ypos = ypos + 20
---------------------------------------------------------
-- Radio buttons
---------------------------------------------------------
local xoffset = 0
for _,info in ipairs(aBlockModsTab.radioButtons) do
if xoffset > 200 then
xoffset = 0
ypos = ypos + 20
end
info.label = guiCreateLabel( xpos + xoffset + 20, ypos - 1, 110, 16, info.desc, false, tab )
guiSetProperty ( info.label, "RiseOnClick", "False" )
info.button = guiCreateRadioButton( xpos + xoffset, ypos, 16+70, 16, "", false, tab )
guiLabelSetColor( info.label, unpack(info.color) )
xoffset = xoffset + 130
end
ypos = ypos + 20
---------------------------------------------------------
-- Definition list
---------------------------------------------------------
local label2 = guiCreateLabel ( xpos, ypos, 200, 16, "File name matches (one per line)", false, tab )
ypos = ypos + 20
aBlockModsTab.memoDefinition = guiCreateMemo ( xpos, ypos, 250, 300, "", false, tab )
ypos = ypos + 300
---------------------------------------------------------
-- Version warning
---------------------------------------------------------
ypos = ypos + 20
aBlockModsTab.versionWarningLabel = guiCreateLabel ( xpos, ypos, 400, 16, "** acpanel MUST BE RUNNING for this to work **", false, tab )
guiLabelSetColor( aBlockModsTab.versionWarningLabel, unpack(colorYellow) )
guiSetVisible( aBlockModsTab.versionWarningLabel, false )
ypos = ypos + 20
ypos = ypos - 320
xpos = xpos + 360
---------------------------------------------------------
-- Detections log
---------------------------------------------------------
--[[
local label2 = guiCreateLabel ( xpos, ypos, 100, 16, "Recent detections:", false, tab )
ypos = ypos + 20
local memo2 = guiCreateMemo ( xpos, ypos, 200, 300, "", false, tab )
ypos = ypos + 300
guiMemoSetReadOnly( memo2, true )
guiSetAlpha( memo2, 0.75 )
--]]
aBlockModsTab.Refresh()
addEventHandler ( "onClientGUIClick", aBlockModsTab.Tab, aBlockModsTab.onClientGUIClick )
addEventHandler ( "onClientGUIChanged", aBlockModsTab.memoDefinition, aBlockModsTab.onMemoDefinitionChanged )
end
function aBlockModsTab.onMemoDefinitionChanged(element)
if bSaveMemoEdits then
setPanelSetting( "blockmods.customText", guiGetText(aBlockModsTab.memoDefinition) )
end
end
function aBlockModsTab.onClientGUIClick()
local element = source
local typeNew = aBlockModsTab.getTypeFromGui()
local typeCurrent = getPanelSetting( "blockmods.type" )
if typeNew ~= typeCurrent then
setPanelSetting( "blockmods.type", typeNew )
aBlockModsTab.Refresh()
end
if element ~= aBlockModsTab.memoDefinition then
guiMoveToBack( aBlockModsTab.memoDefinition )
end
end
function aBlockModsTab.getTypeFromGui()
for _,info in ipairs(aBlockModsTab.radioButtons) do
if guiRadioButtonGetSelected( info.button ) then
return info.type
end
end
end
function aBlockModsTab.Refresh()
local type = getPanelSetting( "blockmods.type" )
if type == "none" then
guiSetVisible( aBlockModsTab.versionWarningLabel, false )
else
guiSetVisible( aBlockModsTab.versionWarningLabel, true )
end
local info = aBlockModsTab.getInfoForType(type)
guiRadioButtonSetSelected( info.button, true )
if info.custom then
local customText = getPanelSetting( "blockmods.customText" )
guiSetText( aBlockModsTab.memoDefinition, customText )
guiMemoSetReadOnly( aBlockModsTab.memoDefinition, false )
guiSetAlpha ( aBlockModsTab.memoDefinition, 1 )
bSaveMemoEdits = true
else
bSaveMemoEdits = false
guiSetText( aBlockModsTab.memoDefinition, info.text )
guiMemoSetReadOnly( aBlockModsTab.memoDefinition, true )
guiSetAlpha ( aBlockModsTab.memoDefinition, 0.75 )
end
end

View file

@ -0,0 +1,131 @@
--
-- Anti-Cheat Control Panel
--
-- c_gui_config.lua
--
function aServerConfigTab.Create ( tab )
aServerConfigTab.Tab = tab
xpos = 20
ypos = 10
local label1 = guiCreateLabel ( xpos, ypos, 200, 16, "Minimum allow client setting", false, tab )
ypos = ypos + 20
---------------------------------------------------------
-- Radio buttons
---------------------------------------------------------
local xoffset = 0
for _,info in ipairs(aServerConfigTab.radioButtons) do
if xoffset > 400 then
xoffset = 0
ypos = ypos + 20
end
info.label = guiCreateLabel( xpos + xoffset + 20, ypos - 1, 250, 16, info.desc, false, tab )
guiSetProperty ( info.label, "RiseOnClick", "False" )
info.button = guiCreateRadioButton( xpos + xoffset, ypos, 16+70, 16, "", false, tab )
guiLabelSetColor( info.label, unpack(info.color) )
xoffset = xoffset + 250
end
ypos = ypos + 20
---------------------------------------------------------
-- Definition list
---------------------------------------------------------
local label2 = guiCreateLabel ( xpos, ypos, 200, 16, "Min client version:", false, tab )
ypos = ypos + 20
--aServerConfigTab.memoDefinition = guiCreateMemo ( xpos, ypos, 250, 40, "", false, tab )
aServerConfigTab.memoDefinition = guiCreateEdit ( xpos, ypos, 250, 30, "", false, tab )
ypos = ypos + 40
ypos = ypos + 240
---------------------------------------------------------
-- acpanel version alert
---------------------------------------------------------
aServerConfigTab.acpanelVersionLabel = guiCreateLabel ( xpos+5, ypos, 400, 16, "NEW VERSION OF Anti Cheat Panel is available from:", false, tab )
guiLabelSetColor( aServerConfigTab.acpanelVersionLabel, unpack(colorRed) )
ypos = ypos + 20
aServerConfigTab.acpanelUrlEdit = guiCreateEdit ( xpos, ypos, 550, 30, "", false, tab )
guiSetVisible( aServerConfigTab.acpanelVersionLabel, false )
guiSetVisible( aServerConfigTab.acpanelUrlEdit, false )
aServerConfigTab.Refresh()
-- EVENTS
addEventHandler ( "onClientGUIClick", aServerConfigTab.Tab, aServerConfigTab.onClientGUIClick )
addEventHandler ( "onClientGUIChanged", aServerConfigTab.memoDefinition, aServerConfigTab.onMemoDefinitionChanged )
end
function aServerConfigTab.onMemoDefinitionChanged(element)
if bSaveMemoEdits then
setPanelSetting( "minclientconfig.customText", guiGetText(aServerConfigTab.memoDefinition) )
end
end
function aServerConfigTab.onClientGUIClick()
local element = source
local typeNew = aServerConfigTab.getTypeFromGui()
local typeCurrent = getPanelSetting( "minclientconfig.type" )
if typeNew ~= typeCurrent then
setPanelSetting( "minclientconfig.type", typeNew )
aServerConfigTab.Refresh()
end
if element ~= aServerConfigTab.memoDefinition then
guiMoveToBack( aServerConfigTab.memoDefinition )
end
end
function aServerConfigTab.getTypeFromGui()
for _,info in ipairs(aServerConfigTab.radioButtons) do
if guiRadioButtonGetSelected( info.button ) then
return info.type
end
end
end
function aServerConfigTab.Refresh()
local type = getPanelSetting( "minclientconfig.type" )
local info = aServerConfigTab.getInfoForType("release")
info.text = getPanelSetting( "lastFetchedReleaseVersion" )
local info2 = aServerConfigTab.getInfoForType("latest")
info2.text = getPanelSetting( "lastFetchedLatestVersion" )
local info3 = aServerConfigTab.getInfoForType(type)
guiRadioButtonSetSelected( info3.button, true )
if info3.custom then
local customText = getPanelSetting( "minclientconfig.customText" )
guiSetText( aServerConfigTab.memoDefinition, customText )
guiEditSetReadOnly( aServerConfigTab.memoDefinition, false )
guiSetAlpha ( aServerConfigTab.memoDefinition, 1 )
bSaveMemoEdits = true
else
bSaveMemoEdits = false
guiSetText( aServerConfigTab.memoDefinition, info3.text )
guiEditSetReadOnly( aServerConfigTab.memoDefinition, true )
guiSetAlpha ( aServerConfigTab.memoDefinition, 0.75 )
end
-- ALERT ** VERY IMPORTANT NEWS **
local acpanelVersion = getPanelSetting( "acpanelVersion" )
local acpanelUrl = getPanelSetting( "acpanelUrl" )
if acpanelVersion and acpanelUrl and acpanelVersion > _version then
guiSetVisible( aServerConfigTab.acpanelVersionLabel, true )
guiSetVisible( aServerConfigTab.acpanelUrlEdit, true )
guiSetText( aServerConfigTab.acpanelUrlEdit, acpanelUrl )
end
end

View file

@ -0,0 +1,21 @@
--
-- Anti-Cheat Control Panel
--
-- c_joiner.lua
--
-- See s_joiner.lua
--
------------------------------------------------------
------------------------------------------------------
--
-- Events
--
------------------------------------------------------
------------------------------------------------------
addEventHandler("onClientResourceStart", resourceRoot,
function ()
-- Tell server we are ready
triggerServerEvent( "onResourceLoadedAtClient_internal", resourceRoot, localPlayer )
end
)

View file

@ -0,0 +1,49 @@
--
-- Anti-Cheat Control Panel
--
-- c_model_switcher.lua
--
modifiedPlayerModels = {}
function receiveModifiedPlayerModels(list)
modifiedPlayerModels = list
setTimer(checkForModifiedPlayerModel, 1000, 0)
end
addEvent("acpanel.gotModifiedPlayerModelsList", true)
addEventHandler("acpanel.gotModifiedPlayerModelsList", localPlayer, receiveModifiedPlayerModels)
function checkForModifiedPlayerModel()
local model = getElementModel(localPlayer)
-- See if we're using a modified model
if (not isModelModified(model)) then
return true
end
outputChatBox("This server doesn't allow modified player models (ID "..model..") switching models.", 255, 0, 0)
local maxLoops = 0
-- Find another model for us to use
while true do
model = model + 1
if (model > 312) then -- Start from the begging if reached the end
model = 1
end
if (not isModelModified(model) and setElementModel(localPlayer, model)) then -- Found one to use
return true
end
maxLoops = maxLoops + 1
if (maxLoops == 312) then -- In the unlikely event every model is modified
outputChatBox("Unable to find an unmodified player model, killing you instead.", 255, 0, 0)
setElementHealth(localPlayer, 0)
return false
end
end
end
function isModelModified(model)
for i, m in ipairs(modifiedPlayerModels) do
if (m == model) then
return true
end
end
return false
end

View file

@ -0,0 +1,29 @@
--
-- Anti-Cheat Control Panel
--
-- c_settings.lua
--
-----------------------------------------------------------------
-- Settings
-----------------------------------------------------------------
clientCachedSettings = {}
addEvent ( "onAcpClientSettingsChanged", true )
addEventHandler ( "onAcpClientSettingsChanged", resourceRoot,
function ( newSettings )
clientCachedSettings = newSettings
end
)
function getPanelSetting(name)
return clientCachedSettings[name]
end
function setPanelSetting(name,value)
if clientCachedSettings[name] ~= value then
clientCachedSettings[name] = value
triggerServerEvent("onAcpSettingsChange", resourceRoot, name, value )
end
end

48
[admin]/acpanel/meta.xml Normal file
View file

@ -0,0 +1,48 @@
<meta>
<info description="Anti-Cheat Control Panel" author="ccw" version="0.2.0" type="script" />
<min_mta_version server="1.6.0" client="1.6.0"></min_mta_version>
<script src="_common.lua"/>
<script src="s_joiner.lua"/>
<script src="s_main.lua"/>
<script src="s_settings.lua"/>
<script src="s_img_mod.lua"/>
<script src="_common.lua" type="client" cache="false" />
<script src="c_joiner.lua" type="client" cache="false" />
<script src="c_settings.lua" type="client" cache="false"/>
<script src="c_gui.lua" type="client" cache="false" />
<script src="c_gui_ac.lua" type="client" cache="false" />
<script src="c_gui_ac2.lua" type="client" cache="false" />
<script src="c_gui_block_mods.lua" type="client" cache="false" />
<script src="c_gui_config.lua" type="client" cache="false" />
<script src="c_model_switcher.lua" type="client" cache="false" />
<settings>
<setting name="*admingroup" value="Admin"
friendlyname="Admin group list"
group="_Advanced"
accept="*"
examples="Admin,Moderator,SuperModerator"
desc="To use this resource, the player must belong to one of the groups listed."
/>
<setting name="*switchplayermodels" value="false"
friendlyname="Switch player model if modified"
group="_Advanced"
accept="true,false"
examples="true,false"
desc="Rather than kick a player for modified player model, switch them to an unmodified model on their client only, so the server and other players will still see the normal skin. Bear in mind that if your scripts use client side skin checks this could affect them. If you enable this you won't need to have 'Player Models' listed in block Img mods.."
/>
</settings>
<!--
Allow these rights by typing the following into the server or client console:
aclrequest allow acpanel all
-->
<aclrequest>
<right name="function.setServerConfigSetting" access="true"></right>
<right name="function.kickPlayer" access="true"></right>
<right name="function.fetchRemote" access="true"></right>
</aclrequest>
</meta>

View file

@ -0,0 +1,73 @@
--
-- Anti-Cheat Control Panel
--
-- s_img_mod.lua
--
addEventHandler( "onPlayerModInfo", root,
function ( filename, modList )
local player = source
for _,mod in ipairs(modList) do -- Check each modified item
if isImgModBlocked( mod.name ) then
local msg = "Modified " .. mod.name .. " in " .. filename .. " not allowed"
kickPlayer( source, msg )
--outputDebug( msg )
return
end
end
-- Get list of modified player models
local modifiedPlayerModels = {}
if get("*switchplayermodels") == "true" and filename == "gta3.img" then
for _,mod in ipairs(modList) do
if tonumber(mod.id) < 313 and string.find(mod.name, ".dff") then
table.insert(modifiedPlayerModels, tonumber(mod.id))
end
end
if #modifiedPlayerModels > 0 then
triggerClientEvent(player, "acpanel.gotModifiedPlayerModelsList", player, modifiedPlayerModels)
end
end
end
)
addEventHandler ( "onResourceStart", resourceRoot,
function ()
for _,plr in ipairs(getElementsByType("player")) do
resendPlayerModInfo(plr)
end
end
)
function isImgModBlocked( name )
local defText = getBlockDefText()
local type = getPanelSetting( "blockmods.type" )
--outputDebug( "Checking " .. name .. " against type " .. tostring(type) )
--outputDebug( tostring(defText) )
local lineList = split(defText,"\n")
for _, line1 in ipairs(lineList) do
local line = string.gsub(line1, "\r", "")
--outputDebug( "Checking " .. name .. " against line " .. tostring(line) )
if line == "*" or string.find(name,line) then
return true
end
end
return false
end
function getBlockDefText()
local type = getPanelSetting( "blockmods.type" )
local info = aBlockModsTab.getInfoForType( type )
if info.custom then
return getPanelSetting( "blockmods.customText" )
else
return info.text
end
end

View file

@ -0,0 +1,131 @@
--
-- Anti-Cheat Control Panel
--
-- s_joiner.lua
--
-- Delays triggerClientEvent until the client is ready.
-- Based on _triggequeue.lua from amx.
-- Should be high up in meta.xml.
--
---------------------------------------------------------------------------
--
-- Variables
--
---------------------------------------------------------------------------
local _triggerClientEvent = triggerClientEvent
local playerData = {} -- { player = { loaded = bool, pending = {...} } }
---------------------------------------------------------------------------
--
-- Events
--
---------------------------------------------------------------------------
addEventHandler('onResourceStart', resourceRoot,
function()
for i,player in ipairs(getElementsByType('player')) do
playerData[player] = { loaded = false, pending = {} }
end
end
)
addEventHandler('onPlayerJoin', root,
function()
playerData[source] = { loaded = false, pending = {} }
end
)
addEventHandler('onPlayerQuit', root,
function()
playerData[source] = nil
end
)
-- New player loaded
addEvent('onResourceLoadedAtClient_internal', true)
addEventHandler('onResourceLoadedAtClient_internal', resourceRoot,
function()
player = client
--if checkClient( false, player, 'onResourceLoadedAtClient_internal' ) then return end
if playerData[player] then
playerData[player].loaded = true
-- Do queued events
for i,event in ipairs(playerData[player].pending) do
_triggerClientEvent(player, event.name, event.source, unpack(event.args))
end
playerData[player].pending = nil
end
end
)
---------------------------------------------------------------------------
--
-- Functions
--
---------------------------------------------------------------------------
local function addToQueue(player, name, source, args)
for i,a in pairs(args) do
if type(a) == 'table' then
args[i] = table.deepcopy(a)
end
end
table.insert(playerData[player].pending, { name = name, source = source, args = args })
end
function triggerClientEvent( triggerFor, name, theElement, ... )
local args = { ... }
if type(triggerFor) == 'string' then
table.insert(args, 1, theElement)
theElement = name
name = triggerFor
triggerFor = nil
end
triggerFor = triggerFor or root
if triggerFor == root then
-- trigger for everyone
for player,data in pairs(playerData) do
if data.loaded then
_triggerClientEvent(player, name, theElement, unpack(args))
else
addToQueue(player, name, theElement, args)
end
end
elseif playerData[triggerFor] then
-- trigger for single player
if playerData[triggerFor].loaded then
_triggerClientEvent(triggerFor, name, theElement, unpack(args))
else
addToQueue(triggerFor, name, theElement, args)
end
end
end
---------------------------------------------------------------------------
--
-- Util
--
---------------------------------------------------------------------------
function table.deepcopy(t1)
local known = {}
local function _deepcopy(t)
local result = {}
for k,v in pairs(t) do
if type(v) == 'table' then
if not known[v] then
known[v] = _deepcopy(v)
end
result[k] = known[v]
else
result[k] = v
end
end
return result
end
return _deepcopy(t1)
end

153
[admin]/acpanel/s_main.lua Normal file
View file

@ -0,0 +1,153 @@
--
-- Anti-Cheat Control Panel
--
-- s_main.lua
--
local wasAllowedList = {}
addEventHandler ( "onResourceStart", resourceRoot,
function ()
doesResourceHasPermissions()
for _,plr in ipairs(getElementsByType("player")) do
updatePlayer(plr)
end
end
)
addEventHandler ( "onPlayerJoin", root,
function ()
updatePlayer(source)
end
)
addEventHandler ( "onPlayerQuit", root,
function ()
wasAllowedList[source] = nil
end
)
addEventHandler ( "onPlayerLogin", root,
function ()
updatePlayer(source)
end
)
addEventHandler ( "onPlayerLogout", root,
function ()
updatePlayer(source)
end
)
function updatePlayer(player)
local oldAllowed = wasAllowedList[player]
local newAllowed = isPlayerAllowedHere(player)
wasAllowedList[player] = newAllowed
if newAllowed and not oldAllowed then
bindKey( player, "o", "down", "Show_AC_Panel" )
outputChatBox ( "Press 'o' to open AC panel", player )
if not bAllowGui then return end
sendAllSettingsToClient()
triggerClientEvent(player, 'onAcpClientInitialSettings', resourceRoot, getServerConfigSettingsToTransfer() )
elseif not newAllowed and oldAllowed then
triggerClientEvent(player, 'aClientAcMenu', resourceRoot, "close" )
unbindKey( player, "o", "down", "Show_AC_Panel" )
end
end
function showACPanel(player)
if not isPlayerAllowedHere(player) then return false end
if not doesResourceHasPermissions() then return end
triggerClientEvent(player, 'aClientAcMenu', resourceRoot, "toggle" )
end
addCommandHandler('acp',showACPanel)
addCommandHandler('Show_AC_Panel',showACPanel)
function getServerConfigSettingsToTransfer()
local result = {}
local settingNameList = { "disableac", "enablesd", "verifyclientsettings" }
for _,name in ipairs(settingNameList) do
local value = getServerConfigSetting(name)
result[name] = value
end
local verifyFlags = getServerConfigSetting( "verifyclientsettings" )
verifyFlags = -1-verifyFlags
local stringresult = ""
for i=1,32 do
local isset = math.hasbit(verifyFlags, math.bit(i))
stringresult = stringresult .. ( isset and "1" or "0" )
end
result["verifyclientsettingsstring"] = stringresult
return result
end
--------------------------------------------------------------------
-- Check this resource can do stuff
--------------------------------------------------------------------
function doesResourceHasPermissions()
if hasObjectPermissionTo( getThisResource(), "function.kickPlayer" ) and
hasObjectPermissionTo( getThisResource(), "function.setServerConfigSetting" ) and
hasObjectPermissionTo( getThisResource(), "function.fetchRemote" ) then
bResourceHasPermissions = true
end
if not bDoneFirstCheck then
bDoneFirstCheck = true
if bResourceHasPermissions then
bAllowGui = true
return true
end
end
if bAllowGui then
return true
end
if not bResourceHasPermissions then
outputServerLog( "AC Panel can not start until this command is run:" )
outputServerLog( "aclrequest allow acpanel all" )
else
outputServerLog( "Please restart AC Panel" )
end
return false
end
--------------------------------------------------------------------
-- Check player can do stuff
--------------------------------------------------------------------
function isPlayerAllowedHere(player)
local admingroup = get("admingroup") or "Admin"
if not isPlayerInACLGroup(player, tostring(admingroup) ) then
return false
end
return true
end
function isPlayerInACLGroup(player, groupName)
local account = getPlayerAccount(player)
if not account then
return false
end
local accountName = getAccountName(account)
for _,name in ipairs(split(groupName,',')) do
local group = aclGetGroup(name)
if group then
for i,obj in ipairs(aclGroupListObjects(group)) do
if obj == 'user.' .. accountName or obj == 'user.*' then
return true
end
end
end
end
return false
end

View file

@ -0,0 +1,257 @@
--
-- Anti-Cheat Control Panel
--
-- s_settings.lua
--
local aSettings = {
File = nil,
Cache = {}
}
serverCachedSettings = {}
function sendAllSettingsToClient()
triggerClientEvent(player, 'onAcpClientSettingsChanged', resourceRoot, aSettings.Cache )
end
---------------------------------------------------------
-- Change from client
---------------------------------------------------------
addEvent( "onAcpSettingsChange", true )
addEventHandler( "onAcpSettingsChange", resourceRoot,
function( name, value )
if not isPlayerAllowedHere(client) then return false end
setPanelSetting( name, value )
end
)
---------------------------------------------------------
-- getPanelSetting
---------------------------------------------------------
function getPanelSetting(name)
return aSettings.Cache[name]
end
---------------------------------------------------------
-- setPanelSetting
---------------------------------------------------------
function setPanelSetting(name, value)
name = tostring ( name )
value = tostring ( value )
aSettings.Cache[name] = value
local node = xmlFindChild ( aSettings.File, name, 0 )
if ( not node ) then
node = xmlCreateChild ( aSettings.File, name )
end
xmlNodeSetValue ( node, tostring ( value ) )
startDelayedSave()
local minclientconfig_type = getPanelSetting("minclientconfig.type")
local minclientconfig_customText = getPanelSetting("minclientconfig.customText")
-- Handle when "minclientconfig.customText" is changed by user
if ( name == "minclientconfig.customText" and minclientconfig_type == "custom" ) then
setServerConfigSetting( "minclientversion_auto_update", "0", true )
setServerConfigSetting( "minclientversion", minclientconfig_customText, true )
end
-- Handle when "minclientconfig.type" is changed by user
if name == "minclientconfig.type" then
if minclientconfig_type == "none" then
setServerConfigSetting( "minclientversion_auto_update", "0", true )
setServerConfigSetting( "minclientversion", "", true )
elseif minclientconfig_type == "custom" then
setServerConfigSetting( "minclientversion_auto_update", "0", true )
setServerConfigSetting( "minclientversion", minclientconfig_customText, true )
elseif minclientconfig_type == "release" then
setServerConfigSetting( "minclientversion_auto_update", "1", true )
setServerConfigSetting( "minclientversion", getPanelSetting("lastFetchedReleaseVersion"), true )
elseif minclientconfig_type == "latest" then
setServerConfigSetting( "minclientversion_auto_update", "2", true )
setServerConfigSetting( "minclientversion", getPanelSetting("lastFetchedLatestVersion"), true )
end
end
end
---------------------------------------------------------
-- Enforce min client override
---------------------------------------------------------
_setServerConfigSetting = setServerConfigSetting
function setServerConfigSetting( name, value, save )
if name == "minclientversion" then
local type = getPanelSetting( "blockmods.type" )
if type and type ~= "none" then
if value < MIN_CLIENT_VERSION_FOR_MOD_BLOCKS then
--outputDebug("Enforcing minclientversion from " .. value .. " to " .. MIN_CLIENT_VERSION_FOR_MOD_BLOCKS )
value = MIN_CLIENT_VERSION_FOR_MOD_BLOCKS
end
end
end
_setServerConfigSetting( name, value, save )
--outputDebug("setServerConfigSetting( " .. name .. ", " .. value .. ", " .. tostring(save) )
end
---------------------------------------------------------
-- Save settings in 2 seconds
---------------------------------------------------------
function startDelayedSave()
if isTimer(saveTimer) then
killTimer(saveTimer)
saveTimer = nil
end
saveTimer = setTimer( doSave, 2000, 1 )
end
---------------------------------------------------------
-- Make sure we save on exit
---------------------------------------------------------
addEventHandler ( "onResourceStop", resourceRoot,
function ()
doSave()
xmlUnloadFile( aSettings.File )
end
)
---------------------------------------------------------
-- Set default if name not set
---------------------------------------------------------
function maybeSetDefault( name, value )
if aSettings.Cache[name] == nil then
aSettings.Cache[name] = value
end
end
function setSetting( name, value )
aSettings.Cache[name] = value
end
---------------------------------------------------------
-- Actually do load
---------------------------------------------------------
function doLoad()
aSettings.File = xmlLoadFile( "settings.xml" )
if ( not aSettings.File ) then
aSettings.File = xmlCreateFile( "settings.xml", "main" )
xmlSaveFile( aSettings.File )
end
local messageNodes = xmlNodeGetChildren( aSettings.File )
for _,node in ipairs( messageNodes ) do
local name = xmlNodeGetName( node )
local value = xmlNodeGetValue( node )
aSettings.Cache[name] = value
end
-- Defaults
maybeSetDefault( "blockmods.type", "none" )
maybeSetDefault( "blockmods.customText", "Enter your matches" )
maybeSetDefault( "lastFetchedReleaseVersion", "1.3.2" )
maybeSetDefault( "lastFetchedLatestVersion", "1.3.2" )
local minclientversion = getServerConfigSetting("minclientversion")
local minclientversion_auto_update = getServerConfigSetting("minclientversion_auto_update")
-- Determine "minclientconfig.type" from mtaserver.conf
if minclientversion_auto_update == "0" then
if minclientversion == "" then
setSetting( "minclientconfig.type", "none" )
else
setSetting( "minclientconfig.type", "custom" )
end
elseif minclientversion_auto_update == "1" then
setSetting( "minclientconfig.type", "release" )
elseif minclientversion_auto_update == "2" then
setSetting( "minclientconfig.type", "latest" )
end
-- Ensure "minclientconfig.customText" is not blank
if minclientversion == "" then
maybeSetDefault( "minclientconfig.customText", "1.3.2-9.01234" )
else
maybeSetDefault( "minclientconfig.customText", minclientversion )
end
GetVersInfoFromRemoteServer()
end
---------------------------------------------------------
-- Actually do save
---------------------------------------------------------
function doSave()
if isTimer(saveTimer) then
killTimer(saveTimer)
saveTimer = nil
end
xmlSaveFile ( aSettings.File )
end
---------------------------------------------------------
-- Get version data from remote server
---------------------------------------------------------
function GetVersInfoFromRemoteServer()
fetchRemote( "https://nightly.multitheftauto.com/ver/", onGotVersInfo )
end
function onGotVersInfo( responseData, errno )
if errno == 0 then
local ver = string.sub( getVersion().sortable, 1, 3 )
releaseMinVersion = string.match( responseData, "Auto-update default:%s*" .. ver .. "%.([%d%-%.]+)" )
latestMinVersion = string.match( responseData, "Max recommended/minclientversion:%s*" .. ver .. "%.([%d%-%.]+)" )
if releaseMinVersion and latestMinVersion then
releaseMinVersion = ver .. "." .. releaseMinVersion
latestMinVersion = ver .. "." .. latestMinVersion
if isValidVersionString(releaseMinVersion) and isValidVersionString(latestMinVersion) then
setPanelSetting( "lastFetchedReleaseVersion", releaseMinVersion )
setPanelSetting( "lastFetchedLatestVersion", latestMinVersion )
sendAllSettingsToClient()
--outputDebug("valid version datas")
end
end
end
GetAcPanelVersInfoFromRemoteServer()
end
function isValidVersionString( text )
return string.match(text, "%d%.%d%.%d%-%d%.%d%d%d%d%d%.%d") ~= nil
end
---------------------------------------------------------
-- Get version info about this resource
---------------------------------------------------------
function GetAcPanelVersInfoFromRemoteServer()
fetchRemote( "https://nightly.multitheftauto.com/ver/acpanel/", onGotAcPanelVersInfo )
end
function onGotAcPanelVersInfo( responseData, errno )
if errno == 0 then
acpanelVersion = string.match( responseData, "acpanel ver:(.-)[^0-9.-]" )
acpanelUrl = string.match( responseData, "acpanel url:(.-)[^A-z0-9.-:/?=&]" )
--outputDebug("acpanelVersion:" .. acpanelVersion)
--outputDebug("acpanelUrl:" .. acpanelUrl)
if acpanelVersion and acpanelUrl then
setPanelSetting( "acpanelVersion", acpanelVersion )
setPanelSetting( "acpanelUrl", acpanelUrl )
if acpanelVersion > _version then
outputServerLog("New version of Anti-Cheat panel is available!")
end
end
end
end
doLoad() -- Load during resource startup

55
[admin]/admin/admin.htm Normal file
View file

@ -0,0 +1,55 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<* = call ( getResourceFromName("ajax"), "start", getResourceName(getThisResource()) ) *>
<link rel="stylesheet" type="text/css" href="server\http\admin.css" />
<script src='server\http\admin.js' type='text/javascript'></script>
</head>
<body onLoad="onLoad();">
<div align="center">
<table width="700" height="100%" cellspacing="0" cellpadding="0">
<tr class="main_top_menu">
<td width="36" align="center" class="main_top_menu"><a href="#" onclick="setPreviousPage ()"><img src="server\http\images\back.png" border="0" /><br />Back</a></td>
<td width="36" align="center" class="main_top_menu"><a href="#" onclick="setHomePage ()"><img src="server\http\images\home.png" border="0" /><br />Home</a></td>
<td>&nbsp;</td>
</tr>
<tr height="180">
<td colspan="3" background="server\http\images\header.png">&nbsp;</td>
</tr>
<tr>
<td colspan="3">
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td width="25%">
<div style="width: 100%; height: 500px; overflow: auto;">
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="main_right" id="menu">
<*
local table = call ( getThisResource(), "httpGetMenuItems" )
for name, section in pairs ( table ) do
httpWrite ( "<tr><td colspan=\"2\"><b>"..name.."</b><br /><hr /></td></tr>" )
local total = #section
local i = 1
while ( i <= total ) do
httpWrite ( "<tr>" )
httpWrite ( "<td align=\"center\"><a href=\"#\" onclick=\"setCurrentPage ( '"..section[i]["page"].."' )\"><img src=\""..section[i]["icon"].."\" border=\"0\" alt=\""..section[i]["alt"].."\" /><br />"..section[i]["name"].."</a></td>" )
if ( i < total ) then
i = i + 1
httpWrite ( "<td align=\"center\"><a href=\"#\" onclick=\"setCurrentPage ( '"..section[i]["page"].."' )\"><img src=\""..section[i]["icon"].."\" border=\"0\" alt=\""..section[i]["alt"].."\" /><br />"..section[i]["name"].."</a></td>" )
end
httpWrite ( "</tr>" )
i = i + 1
end
end
*>
</table>
</div>
</td>
<td valign="top"><div id="page"></div></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>

View file

@ -0,0 +1,23 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_definitions.lua
*
* Original File by lil_Toady
*
**************************************]]
_DEBUG = false
_version = '1.6'
-- MISC DEFINITIONS
ADMIN_CHAT_MAXLENGTH = 225
function enum ( args, prefix )
for i, v in ipairs ( args ) do
if ( prefix ) then _G[v] = prefix..i
else _G[v] = i end
end
end

View file

@ -0,0 +1,36 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_ACL.lua
*
* Original File by lil_Toady
*
**************************************]]
_aclrights = {}
function hasPermissionTo ( object )
if ( _aclrights[object] ) then
return true
end
return false
end
addEvent ( "aPermissions", true )
addEventHandler ( "aPermissions", localPlayer, function ( table )
for id, right in ipairs ( table ) do
_aclrights[right] = true
if ( aAdminForm ) then
if _guiprotected[right] then
guiSetEnabled ( _guiprotected[right], true )
end
end
end
end )
addEventHandler ( "onAdminInitialize", resourceRoot, function()
if ( #_guiprotected == 0 ) then
triggerServerEvent ( "aPermissions", localPlayer )
end
end )

View file

@ -0,0 +1,220 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_client.lua
*
* Original File by lil_Toady
*
**************************************]]
_DEBUG = false
_version = '1.6'
_flags = {}
_widgets = {}
_settings = nil
aWeathers = {}
_weathers_max = 0
function aClientAdminMenu ()
if ( aAdminForm ) and ( guiGetVisible ( aAdminForm ) == true ) then
for id, widget in pairs ( _widgets ) do
widget.close ( false )
end
aAdminMenuClose ( false )
else
aAdminMenu ()
guiFocus (aAdminForm)
end
end
addEvent ( "onAdminInitialize", true )
addEvent ( "aMessage", true )
addEvent ( "aClientLog", true )
addEvent ( "aClientSync", true )
addEvent ( "aClientPlayerJoin", true )
addEvent ( "aModdetails", true )
addEvent ( "aClientAdminChat", true )
addEvent ( "aClientResourceStart", true )
addEvent ( "aClientResourceStop", true )
addEvent ( "aClientAdminMenu", true )
addEvent ( "aClientReports", true )
function aAdminResourceStart ()
addEventHandler ( "aClientAdminMenu", root, aClientAdminMenu )
local node = xmlLoadFile ( "conf\\weathers.xml" )
if ( node ) then
while ( true ) do
local weather = xmlFindChild ( node, "weather", _weathers_max )
if ( not weather ) then break end
local id = tonumber ( xmlNodeGetAttribute ( weather, "id" ) )
local name = xmlNodeGetAttribute ( weather, "name" )
aWeathers[id] = name
_weathers_max = _weathers_max + 1
end
if ( _weathers_max >= 1 ) then _weathers_max = _weathers_max - 1 end
xmlUnloadFile ( node )
end
aLoadSettings ()
triggerServerEvent ( "aPermissions", localPlayer )
setTimer( function() triggerServerEvent ( "aPlayerVersion", localPlayer, getVersion() ) end, 2000, 1 )
guiSetInputMode ( "no_binds_when_editing" )
end
function aAdminResourceStop ()
showCursor ( false )
end
function aRegister ( name, welement, fopen, fclose )
_widgets[name] = {}
_widgets[name].element = welement
_widgets[name].initialize = fopen
_widgets[name].close = fclose
end
function aAdminDestroy ()
if ( aAdminForm ) then
for id, widget in pairs ( _widgets ) do
widget.close ( true )
end
_widgets = {}
aAdminMenuClose ( true )
end
end
function aLoadSettings ()
if _settings then
xmlUnloadFile ( _settings )
end
_settings = xmlLoadFile ( "admin.xml" )
if ( not _settings ) then
_settings = xmlCreateFile ( "admin.xml", "main" )
xmlSaveFile ( _settings )
end
end
function aGetSetting ( setting )
local result = xmlFindChild ( _settings, tostring ( setting ), 0 )
if ( result ) then
result = xmlNodeGetValue ( result )
if ( result == "true" ) then return true
elseif ( result == "false" ) then return false
else return result end
end
return false
end
function aSetSetting ( setting, value )
local node = xmlFindChild ( _settings, tostring ( setting ), 0 )
if ( not node ) then
node = xmlCreateChild ( _settings, tostring ( setting ) )
end
xmlNodeSetValue ( node, tostring ( value ) )
xmlSaveFile ( _settings )
end
function aRemoveSetting ( setting )
local node = xmlFindChild ( _settings, tostring ( setting ), 0 )
if ( node ) then
xmlDestroyNode ( node )
end
xmlSaveFile ( _settings )
end
function getWeatherNameFromID ( weather )
return iif ( aWeathers[weather], aWeathers[weather], "Unknown" )
end
function iif ( cond, arg1, arg2 )
if ( cond ) then
return arg1
end
return arg2
end
function getPlayerFromNick ( nick )
for id, player in ipairs(getElementsByType("player")) do
if ( getPlayerName ( player ) == nick ) then return player end
end
return false
end
addEventHandler ( "onClientResourceStart", resourceRoot, aAdminResourceStart )
addEventHandler ( "onClientResourceStop", resourceRoot, aAdminResourceStop )
--
-- Upgrade check message for 1.0 to 1.0.2
--
addEvent ( "aClientShowUpgradeMessage", true )
addEventHandler ( "aClientShowUpgradeMessage", root,
function()
local xml = xmlLoadFile("upgrade_cookie.xml")
if not xml then
xml = xmlCreateFile("upgrade_cookie.xml", "settings")
end
if not xml then return end
local node = xmlFindChild(xml, "upgradeMessage", 0)
if not node then
node = xmlCreateChild(xml, "upgradeMessage")
end
local timeNow = getRealTimeSeconds()
local bShowConsoleText = true
local bShowMessageBox = true
if bShowConsoleText then
local lastTime = xmlNodeGetAttribute(node, "lastConsoleTextTime")
local age = timeNow - ( tonumber(lastTime) or 0 )
if age > 60*60 then
xmlNodeSetAttribute(node, "lastConsoleTextTime", tostring( timeNow ))
xmlSaveFile(xml)
outputConsole( "A new version of MTA:SA is available! - Please download from www.multitheftauto.com" )
end
end
if bShowMessageBox then
local lastTime = xmlNodeGetAttribute(node, "lastMessageBoxTime")
local age = timeNow - ( tonumber(lastTime) or 0 )
if age > 60*60*24 then
xmlNodeSetAttribute(node, "lastMessageBoxTime", tostring( timeNow ))
xmlSaveFile(xml)
aMessageBox( "A new version of MTA:SA is available!", "Please download from www.multitheftauto.com" )
setTimer ( aMessageBoxClose, 15000, 1, true )
end
end
xmlUnloadFile (xml)
end
)
function getRealTimeSeconds()
return realTimeToSeconds( getRealTime() )
end
function realTimeToSeconds( time )
local leapyears = math.floor( ( time.year - 72 + 3 ) / 4 )
local days = ( time.year - 70 ) * 365 + leapyears + time.yearday
local seconds = days * 60*60*24
seconds = seconds + time.hour * 60*60
seconds = seconds + time.minute * 60
seconds = seconds + time.second
seconds = seconds - time.isdst * 60*60
return seconds
end
-- seconds to description i.e. "10 mins"
function secondsToTimeDesc( seconds )
if seconds then
local tab = { {"day",60*60*24}, {"hour",60*60}, {"min",60}, {"sec",1} }
for i,item in ipairs(tab) do
local t = math.floor(seconds/item[2])
if t > 0 or i == #tab then
return tostring(t) .. " " .. item[1] .. (t~=1 and "s" or "")
end
end
end
return ""
end

View file

@ -0,0 +1,21 @@
--
--
-- admin_clientprefs.lua
--
--
g_Prefs = {}
------------------------------------------------------
------------------------------------------------------
--
-- Events
--
------------------------------------------------------
------------------------------------------------------
addEvent( "onClientUpdatePrefs", true )
addEventHandler("onClientUpdatePrefs", resourceRoot,
function ( prefs )
g_Prefs = prefs
end
)

View file

@ -0,0 +1,188 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_gui.lua
*
* Original File by lil_Toady
*
**************************************]]
_guiprotected = {}
local lists = {}
function guiCreateHeader ( x, y, w, h, text, relative, parent )
local header = guiCreateLabel ( x, y, w, h, text, relative, parent )
if ( header ) then
guiLabelSetColor ( header, 255, 0, 0 )
guiSetFont ( header, "default-bold-small" )
return header
end
return false
end
_guiCreateTab = guiCreateTab
function guiCreateTab ( name, parent, right )
local tab = _guiCreateTab ( name, parent )
if ( tab ) then
if ( right ) then
right = "general.tab_"..right
if ( not hasPermissionTo ( right ) ) then
guiSetEnabled ( tab, false )
_guiprotected[right] = tab
end
end
return tab
end
return false
end
_guiCreateButton = guiCreateButton
function guiCreateButton ( x, y, w, h, text, relative, parent, right )
local button = _guiCreateButton ( x, y, w, h, text, relative, parent )
if ( button ) then
if ( right ) then
right = "command."..right
if ( not hasPermissionTo ( right ) ) then
guiSetEnabled ( button, false )
_guiprotected[right] = button
end
end
guiSetFont ( button, "default-bold-small" )
return button
end
return false
end
function guiCreateList(x, y, w, h, tabHeight, header, relative, parent, right)
local list = guiCreateButton(x, y, w, h, header, relative, parent, right)
local parentWidth, parentHeight = guiGetSize(parent, false)
local absoluteWidth = parentWidth * w
local absoluteHeight = parentHeight * h
local dropDown = guiCreateStaticImage(absoluteWidth - 20, 0, 20, 20, "client\\images\\dropdown.png", false, list)
guiSetProperty(dropDown, 'AlwaysOnTop', 'True')
addEventHandler('onClientGUIClick', dropDown, function()
guiListSetVisible(list, true)
end, false)
local bg = guiCreateButton(x, y, w, tabHeight, '', relative, parent)
guiSetProperty(bg, 'AlwaysOnTop', 'True')
guiSetVisible(bg, false)
local edit = guiCreateEdit(0, 0, absoluteWidth - 20, 20, '', false, bg)
guiSetProperty(edit, 'AlwaysOnTop', 'True')
addEventHandler('onClientGUIChanged', edit, function()
guiListLoadItems(list)
end)
local searchIcon = guiCreateStaticImage(absoluteWidth - 40, 0, 20, 20, "client\\images\\search.png", false, edit)
guiSetEnabled(searchIcon, false)
guiSetProperty(searchIcon, 'AlwaysOnTop', 'True')
local close = guiCreateButton(absoluteWidth-20, 0, 20, 20, 'X', false, bg)
guiSetProperty(close, 'AlwaysOnTop', 'True')
guiSetAlpha(close, 1)
addEventHandler('onClientGUIClick', close, function()
guiListSetVisible(list, false)
end, false)
local gridlist = guiCreateGridList(0, 0, 1, 1, true, bg)
addEventHandler('onClientGUIDoubleClick', gridlist, function()
local callback = lists[list].callback
if (type(callback) == 'function') then
local row = guiGridListGetSelectedItem(gridlist)
local data = guiGridListGetItemData(gridlist, row, 1)
local text = guiGridListGetItemText(gridlist, row, 1)
if (row > -1) then
callback(data, text)
guiListSetVisible(list, false)
end
end
end, false)
lists[list] = {
bg = bg,
edit = edit,
gridlist = gridlist,
items = {},
callback = function() end,
}
return list
end
function guiListSetVisible(list, state)
if lists[list] then
guiSetVisible(lists[list].bg, state)
if state then
guiFocus(lists[list].edit)
end
return true
end
return false
end
function guiListSetItems(list, items)
if lists[list] then
lists[list].items = items
guiListLoadItems(list)
return true
end
return false
end
function guiListSetCallBack(list, callback)
if lists[list] then
lists[list].callback = callback
return true
end
return false
end
function guiListSetColumns(list, columns)
if lists[list] then
for _, v in ipairs(columns) do
guiGridListAddColumn(lists[list].gridlist, v.text, v.width)
end
return true
end
return false
end
function guiListLoadItems(list)
local listData = lists[list]
if listData then
local filter = guiGetText(listData.edit)
guiGridListClear(listData.gridlist)
for k, v in ipairs(listData.items) do
if (v.text:lower():find(filter:lower())) then
local row = guiGridListAddRow(listData.gridlist)
guiGridListSetItemText(listData.gridlist, row, 1, tostring ( v.text ), false, false )
guiGridListSetItemData(listData.gridlist, row, 1, tostring ( v.data ) )
end
end
return true
end
return false
end
addEventHandler('onClientGUIClick', guiRoot, function(button)
if (button == 'left') then
local parent = getElementParent(source)
if parent then
for list in pairs(lists) do
if guiGetVisible(list) and (parent ~= list) and (getElementParent(parent) ~= getElementParent(list)) then
guiListSetVisible(list, false)
end
end
end
end
end)

View file

@ -0,0 +1,81 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_wrapper.lua
*
* Original File by lil_Toady
*
**************************************]]
_guiprotected = {}
function guiCreateHeader ( x, y, w, h, text, relative, parent )
local header = guiCreateLabel ( x, y, w, h, text, relative, parent )
if ( header ) then
guiLabelSetColor ( header, 255, 0, 0 )
guiSetFont ( header, "default-bold-small" )
return header
end
return false
end
_guiCreateTab = guiCreateTab
function guiCreateTab ( name, parent, right )
local tab = _guiCreateTab ( name, parent )
if ( tab ) then
if ( right ) then
right = "general.tab_"..right
if ( not hasPermissionTo ( right ) ) then
guiSetEnabled ( tab, false )
_guiprotected[right] = tab
end
end
return tab
end
return false
end
_guiCreateButton = guiCreateButton
function guiCreateButton ( x, y, w, h, text, relative, parent, right )
local button = _guiCreateButton ( x, y, w, h, text, relative, parent )
if ( button ) then
if ( right ) then
right = "command."..right
if ( not hasPermissionTo ( right ) ) then
guiSetEnabled ( button, false )
_guiprotected[right] = button
end
end
guiSetFont ( button, "default-bold-small" )
return button
end
return false
end
_getVehicleNameFromID = getVehicleNameFromModel
function getVehicleNameFromID ( id )
local avehspecial = { [596] = "Police LS",
[597] = "Police SF",
[598] = "Police LV",
[556] = "Monster 2",
[557] = "Monster 3"
}
if ( avehspecial[id] ) then
return avehspecial[id]
end
return _getVehicleNameFromID ( id )
end
_getVehicleIDFromName = getVehicleModelFromName
function getVehicleIDFromName ( name )
local avehspecial = { ["Police LS"] = 596,
["Police SF"] = 597,
["Police LV"] = 598,
["Monster 2"] = 556,
["Monster 3"] = 557
}
if ( avehspecial[name] ) then
return avehspecial[name]
end
return _getVehicleIDFromName ( name )
end

Binary file not shown.

After

(image error) Size: 88 B

View file

@ -0,0 +1,239 @@
sw, sh = guiGetScreenSize()
pickerTable = {}
colorPicker = {}
colorPicker.__index = colorPicker
function openPicker(id, start, title)
if id and not pickerTable[id] then
pickerTable[id] = colorPicker.create(id, start, title)
pickerTable[id]:updateColor()
return true
end
return false
end
function closePicker(id)
if id and pickerTable[id] then
pickerTable[id]:destroy()
return true
end
return false
end
function colorPicker.create(id, start, title)
local cp = {}
setmetatable(cp, colorPicker)
cp.id = id
cp.color = {}
cp.color.h, cp.color.s, cp.color.v, cp.color.r, cp.color.g, cp.color.b, cp.color.hex = 0, 1, 1, 255, 0, 0, "#FF0000"
cp.color.white = tocolor(255,255,255,255)
cp.color.black = tocolor(0,0,0,255)
cp.color.current = tocolor(255,0,0,255)
cp.color.huecurrent = tocolor(255,0,0,255)
if start and getColorFromString(start) then
cp.color.h, cp.color.s, cp.color.v = rgb2hsv(getColorFromString(start))
end
cp.gui = {}
cp.gui.width = 416
cp.gui.height = 304
cp.gui.snaptreshold = 0.02
cp.gui.window = guiCreateWindow((sw-cp.gui.width)/2, (sh-cp.gui.height)/2, cp.gui.width, cp.gui.height, tostring(title or "COLORPICKER"), false)
cp.gui.svmap = guiCreateStaticImage(16, 32, 256, 256, "client/colorpicker/blank.png", false, cp.gui.window)
cp.gui.hbar = guiCreateStaticImage(288, 32, 32, 256, "client/colorpicker/blank.png", false, cp.gui.window)
cp.gui.blank = guiCreateStaticImage(336, 32, 64, 64, "client/colorpicker/blank.png", false, cp.gui.window)
cp.gui.edith = guiCreateLabel(338, 106, 64, 20, "H: 0°", false, cp.gui.window)
cp.gui.edits = guiCreateLabel(338, 126, 64, 20, "S: 100%", false, cp.gui.window)
cp.gui.editv = guiCreateLabel(338, 146, 64, 20, "V: 100%", false, cp.gui.window)
cp.gui.editr = guiCreateLabel(338, 171, 64, 20, "R: 255", false, cp.gui.window)
cp.gui.editg = guiCreateLabel(338, 191, 64, 20, "G: 0", false, cp.gui.window)
cp.gui.editb = guiCreateLabel(338, 211, 64, 20, "B: 0", false, cp.gui.window)
cp.gui.okb = guiCreateButton(336, 235, 64, 24, "OK", false, cp.gui.window)
cp.gui.closeb = guiCreateButton(336, 265, 64, 24, "Cancel", false, cp.gui.window)
guiWindowSetSizable(cp.gui.window, false)
cp.handlers = {}
cp.handlers.mouseDown = function() cp:mouseDown() end
cp.handlers.mouseSnap = function() cp:mouseSnap() end
cp.handlers.mouseUp = function(b,s) cp:mouseUp(b,s) end
cp.handlers.mouseMove = function(x,y) cp:mouseMove(x,y) end
cp.handlers.render = function() cp:render() end
cp.handlers.guiFocus = function() cp:guiFocus() end
cp.handlers.guiBlur = function() cp:guiBlur() end
cp.handlers.pickColor = function() cp:pickColor() end
cp.handlers.destroy = function() cp:destroy() end
addEventHandler("onClientGUIMouseDown", cp.gui.svmap, cp.handlers.mouseDown, false)
addEventHandler("onClientMouseLeave", cp.gui.svmap, cp.handlers.mouseSnap, false)
addEventHandler("onClientMouseMove", cp.gui.svmap, cp.handlers.mouseMove, false)
addEventHandler("onClientGUIMouseDown", cp.gui.hbar, cp.handlers.mouseDown, false)
addEventHandler("onClientMouseMove", cp.gui.hbar, cp.handlers.mouseMove, false)
addEventHandler("onClientClick", root, cp.handlers.mouseUp)
addEventHandler("onClientGUIMouseUp", root, cp.handlers.mouseUp)
addEventHandler("onClientRender", root, cp.handlers.render)
addEventHandler("onClientGUIFocus", cp.gui.window, cp.handlers.guiFocus, false)
addEventHandler("onClientGUIBlur", cp.gui.window, cp.handlers.guiBlur, false)
addEventHandler("onClientGUIClick", cp.gui.okb, cp.handlers.pickColor, false)
addEventHandler("onClientGUIClick", cp.gui.closeb, cp.handlers.destroy, false)
showCursor(true)
return cp
end
function colorPicker:render()
local x,y = guiGetPosition(self.gui.window, false)
dxDrawRectangle(x+16, y+32, 256, 256, self.color.huecurrent, self.gui.focus)
dxDrawImage(x+16, y+32, 256, 256, "client/colorpicker/sv.png", 0, 0, 0, self.color.white, self.gui.focus)
dxDrawImage(x+288, y+32, 32, 256, "client/colorpicker/h.png", 0, 0, 0, self.color.white, self.gui.focus)
dxDrawImageSection(x+8+math.floor(256*self.color.s), y+24+(256-math.floor(256*self.color.v)), 16, 16, 0, 0, 16, 16, "client/colorpicker/cursor.png", 0, 0, 0, self.color.white, self.gui.focus)
dxDrawImageSection(x+280, y+24+(256-math.floor(256*self.color.h)), 48, 16, 16, 0, 48, 16, "client/colorpicker/cursor.png", 0, 0, 0, self.color.huecurrent, self.gui.focus)
dxDrawRectangle(x+336, y+32, 64, 64, self.color.current, self.gui.focus)
dxDrawText(self.color.hex, x+336, y+32, x+400, y+96, self.color.v < 0.5 and self.color.white or self.color.black, 1, "default", "center", "center", true, true, self.gui.focus)
end
function colorPicker:mouseDown()
if source == self.gui.svmap or source == self.gui.hbar then
self.gui.track = source
local cx, cy = getCursorPosition()
self:mouseMove(sw*cx, sh*cy)
end
end
function colorPicker:mouseUp(button, state)
if not state or state ~= "down" then
if self.gui.track then
triggerEvent("onColorPickerChange", root, self.id, self.color.hex, self.color.r, self.color.g, self.color.b)
end
self.gui.track = false
end
end
function colorPicker:mouseMove(x,y)
if self.gui.track and source == self.gui.track then
local gx,gy = guiGetPosition(self.gui.window, false)
if source == self.gui.svmap then
local offsetx, offsety = x - (gx + 16), y - (gy + 32)
self.color.s = offsetx/255
self.color.v = (255-offsety)/255
elseif source == self.gui.hbar then
local offset = y - (gy + 32)
self.color.h = (255-offset)/255
end
self:updateColor()
end
end
function colorPicker:mouseSnap()
if self.gui.track and source == self.gui.track then
if self.color.s < self.gui.snaptreshold or self.color.s > 1-self.gui.snaptreshold then self.color.s = math.round(self.color.s) end
if self.color.v < self.gui.snaptreshold or self.color.v > 1-self.gui.snaptreshold then self.color.v = math.round(self.color.v) end
self:updateColor()
end
end
function colorPicker:updateColor()
self.color.r, self.color.g, self.color.b = hsv2rgb(self.color.h, self.color.s, self.color.v)
self.color.current = tocolor(self.color.r, self.color.g, self.color.b,255)
self.color.huecurrent = tocolor(hsv2rgb(self.color.h, 1, 1))
self.color.hex = string.format("#%02X%02X%02X", self.color.r, self.color.g, self.color.b)
guiSetText(self.gui.edith, "H: "..tostring(math.round(self.color.h*360)).."°")
guiSetText(self.gui.edits, "S: "..tostring(math.round(self.color.s*100)).."%")
guiSetText(self.gui.editv, "V: "..tostring(math.round(self.color.v*100)).."%")
guiSetText(self.gui.editr, "R: "..tostring(self.color.r))
guiSetText(self.gui.editg, "G: "..tostring(self.color.g))
guiSetText(self.gui.editb, "B: "..tostring(self.color.b))
end
function colorPicker:guiFocus()
self.gui.focus = true
guiSetAlpha(self.gui.window, 1)
end
function colorPicker:guiBlur()
self.gui.focus = false
guiSetAlpha(self.gui.window, 0.5)
end
function colorPicker:pickColor()
triggerEvent("onColorPickerOK", root, self.id, self.color.hex, self.color.r, self.color.g, self.color.b)
self:destroy()
end
function colorPicker:destroy()
removeEventHandler("onClientGUIMouseDown", self.gui.svmap, self.handlers.mouseDown)
removeEventHandler("onClientMouseLeave", self.gui.svmap, self.handlers.mouseSnap)
removeEventHandler("onClientMouseMove", self.gui.svmap, self.handlers.mouseMove)
removeEventHandler("onClientGUIMouseDown", self.gui.hbar, self.handlers.mouseDown)
removeEventHandler("onClientMouseMove", self.gui.hbar, self.handlers.mouseMove)
removeEventHandler("onClientClick", root, self.handlers.mouseUp)
removeEventHandler("onClientGUIMouseUp", root, self.handlers.mouseUp)
removeEventHandler("onClientRender", root, self.handlers.render)
removeEventHandler("onClientGUIFocus", self.gui.window, self.handlers.guiFocus)
removeEventHandler("onClientGUIBlur", self.gui.window, self.handlers.guiBlur)
removeEventHandler("onClientGUIClick", self.gui.okb, self.handlers.pickColor)
removeEventHandler("onClientGUIClick", self.gui.closeb, self.handlers.destroy)
destroyElement(self.gui.window)
pickerTable[self.id] = nil
setmetatable(self, nil)
--showCursor(areThereAnyPickers())
end
function areThereAnyPickers()
for _ in pairs(pickerTable) do
return true
end
return false
end
function hsv2rgb(h, s, v)
local r, g, b
local i = math.floor(h * 6)
local f = h * 6 - i
local p = v * (1 - s)
local q = v * (1 - f * s)
local t = v * (1 - (1 - f) * s)
local switch = i % 6
if switch == 0 then
r = v g = t b = p
elseif switch == 1 then
r = q g = v b = p
elseif switch == 2 then
r = p g = v b = t
elseif switch == 3 then
r = p g = q b = v
elseif switch == 4 then
r = t g = p b = v
elseif switch == 5 then
r = v g = p b = q
end
return math.floor(r*255), math.floor(g*255), math.floor(b*255)
end
function rgb2hsv(r, g, b)
r, g, b = r/255, g/255, b/255
local max, min = math.max(r, g, b), math.min(r, g, b)
local h, s
local v = max
local d = max - min
s = max == 0 and 0 or d/max
if max == min then
h = 0
elseif max == r then
h = (g - b) / d + (g < b and 6 or 0)
elseif max == g then
h = (b - r) / d + 2
elseif max == b then
h = (r - g) / d + 4
end
h = h/6
return h, s, v
end
function math.round(v)
return math.floor(v+0.5)
end
addEvent("onColorPickerOK", true)
addEvent("onColorPickerChange", true)

Binary file not shown.

After

(image error) Size: 650 B

Binary file not shown.

After

(image error) Size: 199 B

Binary file not shown.

After

(image error) Size: 26 KiB

View file

@ -0,0 +1,297 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_acl.lua
*
* Original File by lil_Toady
*
**************************************]]
aAclForm = nil
aAclData = {}
addEvent ( "aAdminACL", true )
function aManageACL ()
if ( aAclForm == nil ) then
aAclData["group_objects"] = {}
aAclData["group_acls"] = {}
aAclData["acl_rights"] = {}
local x, y = guiGetScreenSize()
aAclForm = guiCreateWindow ( x / 2 - 230, y / 2 - 250, 460, 500, "ACL Management", false )
aACLList = guiCreateGridList ( 0.03, 0.05, 0.50, 0.90, true, aAclForm )
guiGridListSetSortingEnabled ( aACLList, false )
guiGridListAddColumn( aACLList, "", 0.10 )
guiGridListAddColumn( aACLList, "", 0.85 )
aACLCreateGroup = guiCreateButton ( 0.55, 0.05, 0.40, 0.04, "Create group", true, aAclForm, "aclcreate" )
aACLCreateACL = guiCreateButton ( 0.55, 0.10, 0.40, 0.04, "Create ACL", true, aAclForm, "aclcreate" )
aACLLabel = guiCreateLabel ( 0.55, 0.19, 0.40, 0.04, "", true, aAclForm )
aACLSeparator = guiCreateStaticImage ( 0.55, 0.235, 0.40, 0.0025, "client\\images\\dot.png", true, aAclForm )
aACLDestroyGroup = guiCreateButton ( 0.55, 0.25, 0.40, 0.04, "Destroy group", true, aAclForm, "acldestroy" )
aACLDestroyACL = guiCreateButton ( 0.55, 0.25, 0.40, 0.04, "Destroy ACL", true, aAclForm, "acldestroy" )
aACLAddObject = guiCreateButton ( 0.55, 0.30, 0.40, 0.04, "Add Object", true, aAclForm, "acladd" )
aACLRemoveObject = guiCreateButton ( 0.55, 0.35, 0.40, 0.04, "Remove Object", true, aAclForm, "aclremove" )
aACLAddACL = guiCreateButton ( 0.55, 0.40, 0.40, 0.04, "Add ACL", true, aAclForm )
aACLRemoveACL = guiCreateButton ( 0.55, 0.45, 0.40, 0.04, "Remove ACL", true, aAclForm )
aACLActionLabel = guiCreateLabel ( 0.55, 0.31, 0.40, 0.04, "", true, aAclForm )
aACLDropCurrent = guiCreateEdit ( 0.55, 0.35, 0.40, 0.04, "", true, aAclForm )
guiSetEnabled ( aACLDropCurrent, false )
aACLDropDown = guiCreateStaticImage ( 0.91, 0.35, 0.04, 0.04, "client\\images\\dropdown.png", true, aAclForm )
aACLDropList = guiCreateGridList ( 0.55, 0.35, 0.40, 0.30, true, aAclForm )
guiGridListAddColumn( aACLDropList, "", 0.85 )
guiSetVisible ( aACLDropList, false )
aACLOk = guiCreateButton ( 0.55, 0.40, 0.19, 0.04, "Ok", true, aAclForm )
aACLCancel = guiCreateButton ( 0.76, 0.40, 0.19, 0.04, "Cancel", true, aAclForm )
aACLAddRight = guiCreateButton ( 0.55, 0.30, 0.40, 0.04, "Add Right", true, aAclForm )
aACLExit = guiCreateButton ( 0.75, 0.90, 0.27, 0.04, "Close", true, aAclForm )
aclDisplayOptions ( "", "" )
addEventHandler ( "aAdminACL", localPlayer, aAdminACL )
addEventHandler ( "onClientGUIClick", aAclForm, aClientACLClick )
addEventHandler ( "onClientGUIDoubleClick", aAclForm, aClientACLDoubleClick )
--Register With Admin Form
aRegister ( "ACLManage", aAclForm, aManageACL, aACLClose )
triggerServerEvent ( "aAdmin", localPlayer, "sync", "aclgroups" )
end
guiSetVisible ( aAclForm, true )
guiBringToFront ( aAclForm )
end
function aACLClose ( destroy )
if ( destroy ) then
if ( aAclForm ) then
removeEventHandler ( "onClientGUIClick", aAclForm, aClientACLClick )
removeEventHandler ( "onClientGUIDoubleClick", aAclForm, aClientACLDoubleClick )
destroyElement ( aAclForm )
aAclForm = nil
end
else
guiSetVisible ( aAclForm, false )
end
end
function aAdminACL ( type, acltable )
guiGridListClear ( aACLList )
if ( type == "aclgroups" ) then
aAclData["viewing"] = nil
aAclData["group_row"] = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, aAclData["group_row"], 2, "Groups:", true, false )
aAclData["groups"] = acltable["groups"]
for id, name in ipairs ( acltable["groups"] ) do
local row = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, row, 1, "+", false, false )
guiGridListSetItemText ( aACLList, row, 2, name, false, false )
end
local row = guiGridListAddRow ( aACLList )
aAclData["acl_row"] = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, aAclData["acl_row"], 2, "ACL:", true, false )
aAclData["acl"] = acltable["acl"]
for id, name in ipairs ( acltable["acl"] ) do
local row2 = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, row2, 1, "+", false, false )
guiGridListSetItemText ( aACLList, row2, 2, name, false, false )
end
aclDisplayOptions ( "", "" )
elseif ( type == "aclobjects" ) then
aAclData["group_row"] = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, aAclData["group_row"], 2, "Groups:", true, false )
for i, group in ipairs ( aAclData["groups"] ) do
local group_row = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, group_row, 2, group, false, false )
if ( group == acltable["name"] ) then
aclDisplayOptions ( "Group", acltable["name"] )
aAclData["objects_row"] = guiGridListAddRow ( aACLList )
aAclData["group_objects"][group] = acltable["objects"]
guiGridListSetItemText ( aACLList, aAclData["objects_row"], 2, " objects:", true, false )
for j, object in ipairs ( acltable["objects"] ) do
local row = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, row, 2, " "..object, false, false )
end
aAclData["acls_row"] = guiGridListAddRow ( aACLList )
aAclData["group_acls"][group] = acltable["acl"]
guiGridListSetItemText ( aACLList, aAclData["acls_row"], 2, " acl:", true, false )
for j, acl in ipairs ( acltable["acl"] ) do
local row = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, row, 2, " "..acl, false, false )
end
guiGridListSetItemText ( aACLList, group_row, 1, "-", false, false )
else
guiGridListSetItemText ( aACLList, group_row, 1, "+", false, false )
end
end
aAclData["acl_row"] = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, aAclData["acl_row"], 2, "ACL:", true, false )
for id, name in ipairs ( aAclData["acl"] ) do
local row = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, row, 1, "+", false, false )
guiGridListSetItemText ( aACLList, row, 2, name, false, false )
end
elseif ( type == "aclrights" ) then
aAclData["viewing"] = "rights"
aAclData["group_row"] = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, aAclData["group_row"], 2, "Groups:", true, false )
for id, name in ipairs ( aAclData["groups"] ) do
local row = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, row, 1, "+", false, false )
guiGridListSetItemText ( aACLList, row, 2, name, false, false )
end
aAclData["acl_row"] = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, aAclData["acl_row"], 2, "ACL:", true, false )
for i, acl in ipairs ( aAclData["acl"] ) do
local acl_row = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, acl_row, 2, acl, false, false )
if ( acl == acltable["name"] ) then
aAclData["acl_rights"][acl] = acltable["rights"]
aclDisplayOptions ( "ACL", acltable["name"] )
aAclData["rights_row"] = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, aAclData["rights_row"], 2, " rights:", true, false )
for name, access in pairs ( acltable["rights"] ) do
local row = guiGridListAddRow ( aACLList )
guiGridListSetItemText ( aACLList, row, 2, " "..name, false, false )
if guiGridListSetItemColor then
guiGridListSetItemColor ( aACLList, row, 2, access and 0 or 255, access and 255 or 0, 0, 255)
end
end
guiGridListSetItemText ( aACLList, acl_row, 1, "-", false, false )
else
guiGridListSetItemText ( aACLList, acl_row, 1, "+", false, false )
end
end
end
end
function aClientACLDoubleClick ( button )
if ( button == "left" ) then
if ( source == aACLList ) then
local row = guiGridListGetSelectedItem ( aACLList )
if ( row ~= -1 ) then
local clicked = guiGridListGetItemText ( aACLList, row, 2 )
local state = guiGridListGetItemText ( aACLList, row, 1 )
if ( row > aAclData["acl_row"] ) then
for i, acl in ipairs ( aAclData["acl"] ) do
if ( acl == clicked ) then
if ( state == "-" ) then
triggerServerEvent ( "aAdmin", localPlayer, "sync", "aclgroups" )
else
triggerServerEvent ( "aAdmin", localPlayer, "sync", "aclrights", clicked )
end
return
end
end
else
for i, group in ipairs ( aAclData["groups"] ) do
if ( group == clicked ) then
if ( state == "-" ) then
triggerServerEvent ( "aAdmin", localPlayer, "sync", "aclgroups" )
else
triggerServerEvent ( "aAdmin", localPlayer, "sync", "aclobjects", clicked )
end
return
end
end
end
end
elseif ( source == aACLDropList ) then
local row = guiGridListGetSelectedItem ( aACLDropList )
if ( row ~= -1 ) then
local clicked = guiGridListGetItemText ( aACLDropList, row, 1 )
guiSetText ( aACLDropCurrent, clicked )
guiSetVisible ( aACLDropList, false )
end
end
end
end
function aClientACLClick ( button )
if ( source ~= aACLDropList ) then guiSetVisible ( aACLDropList, false ) end
if ( button == "left" ) then
if ( source == aACLExit ) then
aACLClose ( false )
elseif ( source == aACLCreateGroup ) then
aInputBox ( "Create ACL Group", "Enter group name:", "", "aclCreateGroup" )
elseif ( source == aACLCreateACL ) then
aInputBox ( "Create ACL", "Enter acl name:", "", "aclCreate" )
elseif ( source == aACLAddObject ) then
aInputBox ( "Create ACL Group", "Enter object name:", "", "aclAddObject", aAclData["current"] )
elseif ( source == aACLAddRight ) then
aInputBox ( "Create ACL", "Enter right name:", "", "aclAddRight", aAclData["current"] )
elseif ( source == aACLDestroyGroup ) then
aMessageBox ( "warning", "Are you sure to destroy "..aAclData["current"].." group?", "aclDestroyGroup", aAclData["current"])
elseif ( source == aACLDestroyACL ) then
aMessageBox ( "warning", "Are you sure to destroy "..aAclData["current"].." ACL?", "aclDestroy", aAclData["current"])
elseif ( ( source == aACLRemoveObject ) or ( source == aACLAddACL ) or ( source == aACLRemoveACL ) ) then
guiSetVisible ( aACLAddObject, false )
guiSetVisible ( aACLRemoveObject, false )
guiSetVisible ( aACLAddACL, false )
guiSetVisible ( aACLRemoveACL, false )
guiSetVisible ( aACLDropCurrent, true )
guiSetVisible ( aACLDropDown, true )
guiSetVisible ( aACLOk, true )
guiSetVisible ( aACLCancel, true )
guiSetVisible ( aACLActionLabel, true )
guiGridListClear ( aACLDropList )
local table = {}
guiSetText ( aACLActionLabel, guiGetText ( source )..":" )
if ( source == aACLRemoveObject ) then table = aAclData["group_objects"][aAclData["current"]]
elseif ( source == aACLAddACL ) then table = aAclData["acl"]
elseif ( source == aACLRemoveACL ) then table = aAclData["group_acls"][aAclData["current"]] end
if ( #table >= 1 ) then guiSetText ( aACLDropCurrent, table[1] ) end
for id, object in ipairs ( table ) do
guiGridListSetItemText ( aACLDropList, guiGridListAddRow ( aACLDropList ), 1, object, false, false )
end
elseif ( source == aACLDropDown ) then
guiSetVisible ( aACLDropList, true )
guiBringToFront ( aACLDropList )
elseif ( source == aACLCancel ) then
aclDisplayOptions ( aAclData["viewing"], aAclData["current"] )
elseif ( source == aACLOk ) then
local action = guiGetText ( aACLActionLabel )
if ( action == "Remove Object:" ) then
triggerServerEvent ( "aAdmin", localPlayer, "aclremove", "object", aAclData["current"], guiGetText ( aACLDropCurrent ) )
elseif ( action == "Add ACL:" ) then
triggerServerEvent ( "aAdmin", localPlayer, "acladd", "acl", aAclData["current"], guiGetText ( aACLDropCurrent ) )
elseif ( action == "Remove ACL:" ) then
triggerServerEvent ( "aAdmin", localPlayer, "aclremove", "acl", aAclData["current"], guiGetText ( aACLDropCurrent ) )
end
end
end
end
function aclDisplayOptions ( state, name )
guiSetVisible ( aACLSeparator, false )
aAclData["viewing"] = state
if ( state ~= "" ) then
aAclData["current"] = name
guiSetVisible ( aACLSeparator, true )
guiSetText ( aACLLabel, state..": "..name )
else
aAclData["current"] = ""
guiSetText ( aACLLabel, "" )
end
guiSetVisible ( aACLDestroyGroup, false )
guiSetVisible ( aACLDestroyACL, false )
guiSetVisible ( aACLAddObject, false )
guiSetVisible ( aACLRemoveObject, false )
guiSetVisible ( aACLAddACL, false )
guiSetVisible ( aACLRemoveACL, false )
guiSetVisible ( aACLAddRight, false )
guiSetVisible ( aACLDropCurrent, false )
guiSetVisible ( aACLDropList, false )
guiSetVisible ( aACLDropDown, false )
guiSetVisible ( aACLCancel, false )
guiSetVisible ( aACLOk, false )
guiSetVisible ( aACLActionLabel, false )
if ( state == "ACL" ) then
guiSetVisible ( aACLDestroyACL, true )
guiSetVisible ( aACLAddRight, true )
elseif ( state == "Group" ) then
guiSetVisible ( aACLDestroyGroup, true )
guiSetVisible ( aACLAddObject, true )
guiSetVisible ( aACLAddACL, true )
guiSetVisible ( aACLRemoveObject, true )
guiSetVisible ( aACLRemoveACL, true )
end
end

View file

@ -0,0 +1,111 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_ban.lua
*
* Original File by lil_Toady
*
**************************************]]
aBanForm = nil
local clipContent = nil
function aBanDetails ( ip )
if ( aBanForm == nil ) then
local x, y = guiGetScreenSize()
aBanForm = guiCreateWindow ( x / 2 - 185, y / 2 - 150, 330, 370, "Ban Details", false )
aBanIP = guiCreateLabel ( 0.03, 0.10, 0.80, 0.09, "", true, aBanForm )
aBanNick = guiCreateLabel ( 0.03, 0.20, 0.80, 0.09, "", true, aBanForm )
aBanDate = guiCreateLabel ( 0.03, 0.30, 0.80, 0.09, "", true, aBanForm )
aBanTime = guiCreateLabel ( 0.03, 0.40, 0.80, 0.09, "", true, aBanForm )
aBanBanner = guiCreateLabel ( 0.03, 0.50, 0.80, 0.09, "", true, aBanForm )
aBanUnban = guiCreateLabel ( 0.03, 0.60, 0.80, 0.09, "", true, aBanForm )
aBanCopy = guiCreateButton ( 0.03, 0.88, 0.30, 0.08, "", true, aBanForm )
aBanClose = guiCreateButton ( 0.80, 0.88, 0.17, 0.08, "Close", true, aBanForm )
guiSetVisible ( aBanForm, false )
addEventHandler ( "onClientGUIClick", aBanForm, aClientBanClick )
addEventHandler ( "onClientGUISize", aBanForm, aBanDetailsWindowResize, false )
--Register With Admin Form
aRegister ( "BanDetails", aBanForm, aBanDetails, aBanDetailsClose )
end
if ( aBans["IP"][ip] ) then
clipContent = { "IP address", ip }
guiSetText ( aBanIP, "IP: "..ip )
guiSetText ( aBanNick, "Nickname: "..iif ( aBans["IP"][ip]["nick"], aBans["IP"][ip]["nick"], "Unknown" ) )
guiSetText ( aBanDate, "Date: "..iif ( aBans["IP"][ip]["date"], aBans["IP"][ip]["date"], "Unknown" ) )
guiSetText ( aBanTime, "Time: "..iif ( aBans["IP"][ip]["time"], aBans["IP"][ip]["time"], "Unknown" ) )
guiSetText ( aBanBanner, "Banned by: "..iif ( aBans["IP"][ip]["banner"], aBans["IP"][ip]["banner"], "Unknown" ) )
guiSetText ( aBanCopy, "Copy IP" )
local unban = tostring(aBans["IP"][ip]["unban"])
if not unban or unban == "0" then
guiSetText ( aBanUnban, "Unban: Permanent", unban)
else
guiSetText ( aBanUnban, "Unban: "..FormatDate("d/m/y h:i:s", "'", unban) )
end
if ( aBanReason ) then destroyElement ( aBanReason ) end
aBanReason = guiCreateLabel ( 0.03, 0.70, 0.80, 0.30, "Reason: "..iif ( aBans["IP"][ip]["reason"], aBans["IP"][ip]["reason"], "Unknown" ), true, aBanForm )
guiLabelSetHorizontalAlign ( aBanReason, "left", true )
guiSetVisible ( aBanForm, true )
guiBringToFront ( aBanForm )
guiBringToFront ( aBanCopy )
elseif ( aBans["Serial"][ip] ) then
clipContent = { "serial", ip }
guiSetText ( aBanIP, "Serial: "..ip )
guiSetText ( aBanNick, "Nickname: "..iif ( aBans["Serial"][ip]["nick"], aBans["Serial"][ip]["nick"], "Unknown" ) )
guiSetText ( aBanDate, "Date: "..iif ( aBans["Serial"][ip]["date"], aBans["Serial"][ip]["date"], "Unknown" ) )
guiSetText ( aBanTime, "Time: "..iif ( aBans["Serial"][ip]["time"], aBans["Serial"][ip]["time"], "Unknown" ) )
guiSetText ( aBanBanner, "Banned by: "..iif ( aBans["Serial"][ip]["banner"], aBans["Serial"][ip]["banner"], "Unknown" ) )
guiSetText ( aBanCopy, "Copy Serial" )
local unban = tostring(aBans["Serial"][ip]["unban"])
if not unban or unban == "0" then
guiSetText ( aBanUnban, "Unban: Permanent", unban)
else
guiSetText ( aBanUnban, "Unban: "..FormatDate("d/m/y h:i:s", "'", unban) )
end
if ( aBanReason ) then destroyElement ( aBanReason ) end
aBanReason = guiCreateLabel ( 0.03, 0.70, 0.80, 0.30, "Reason: "..iif ( aBans["Serial"][ip]["reason"], aBans["Serial"][ip]["reason"], "Unknown" ), true, aBanForm )
guiLabelSetHorizontalAlign ( aBanReason, "left", true )
guiSetVisible ( aBanForm, true )
guiBringToFront ( aBanForm )
guiBringToFront ( aBanCopy )
end
end
function aBanDetailsClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceBan ) ) ) then
if ( aBanForm ) then
removeEventHandler ( "onClientGUIClick", aBanForm, aClientBanClick )
destroyElement ( aBanForm )
aBanForm = nil
clipContent = nil
end
else
guiSetVisible ( aBanForm, false )
end
end
function aClientBanClick ( button )
if ( button == "left" ) then
if ( source == aBanClose ) then
aBanDetailsClose ( false )
elseif ( source == aBanCopy ) then
setClipboard( clipContent[2] )
outputChatBox( "Successfully copied the " .. clipContent[1] .. " into clipboard.", 255, 100, 70 )
end
end
end
-- BUGFIX: Buttons stop working on ban details window resize.
-- MTA seems not to update GUI position on resize but does move the clickable area.
-- Could also be a problem deeper in the admin code
-- Workaround is just to setPosition and setSize to update it.
function aBanDetailsWindowResize ()
guiSetSize( aBanCopy, 0.30, 0.08, true )
guiSetSize( aBanClose, 0.17, 0.08, true )
guiSetPosition( aBanCopy, 0.03, 0.88, true )
guiSetPosition( aBanClose, 0.80, 0.88, true )
end

View file

@ -0,0 +1,522 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_inputbox.lua
*
* Original File by lil_Toady
*
**************************************]]
aInputForm = nil
local varOne, varTwo = nil, nil
function aInputBox ( title, message, default, action, vOne, vTwo, defaultNick, defaultReason )
if ( aInputForm == nil ) then
local x, y = guiGetScreenSize()
aInputForm = guiCreateWindow ( x / 2 - 150, y / 2 - 64, 300, 170, "", false )
guiWindowSetSizable ( aInputForm, false )
aInputLabel = guiCreateLabel ( 20, 24, 270, 15, "", false, aInputForm )
guiLabelSetHorizontalAlign ( aInputLabel, "center" )
aInputValue = guiCreateEdit ( 35, 47, 230, 24, "", false, aInputForm )
aInputOk = guiCreateButton ( 90, 80, 55, 17, "Ok", false, aInputForm )
aInputCancel = guiCreateButton ( 150, 80, 55, 17, "Cancel", false, aInputForm )
guiSetProperty ( aInputForm, "AlwaysOnTop", "true" )
aInputAction = nil
addEventHandler ( "onClientGUIClick", aInputForm, aInputBoxClick )
--Register With Admin Form
aRegister ( "InputBox", aInputForm, aInputBox, aInputBoxClose )
end
if not action or action ~= "banSerial" and action ~= "banIP" then
guiSetSize(aInputForm, 300, 170, false)
guiSetPosition(aInputOk, 90, 80, false)
guiSetPosition(aInputCancel, 150, 80, false)
if isElement(banSerialLbl) then destroyElement(banSerialLbl) end
if isElement(banNickEdit) then destroyElement(banNickEdit) end
if isElement(banReasonEdit) then destroyElement(banReasonEdit) end
if isElement(banSerialCombo) then destroyElement(banSerialCombo) end
if isElement(banDurationLbl) then destroyElement(banDurationLbl) end
if isElement(durationEdit) then destroyElement(durationEdit) end
else
guiSetSize(aInputForm, 300, 210, false)
guiSetPosition(aInputOk, 90, 180, false)
guiSetPosition(aInputCancel, 150, 180, false)
-- time duration:
if not isElement(banSerialCombo) then
banSerialCombo = guiCreateComboBox ( 180, 80, 120, 100, "Perm", false, aInputForm )
guiComboBoxAddItem(banSerialCombo, "Mins")
guiComboBoxAddItem(banSerialCombo, "Hours")
guiComboBoxAddItem(banSerialCombo, "Days")
guiComboBoxAddItem(banSerialCombo, "Perm")
end
if not isElement(durationEdit) then
durationEdit = guiCreateEdit ( 110, 80, 60, 24, "", false, aInputForm )
end
guiSetText(durationEdit, "")
if not isElement(banDurationLbl) then
banDurationLbl = guiCreateLabel ( 40, 83, 50, 15, "Duration:", false, aInputForm )
guiLabelSetHorizontalAlign ( banDurationLbl, "center" )
end
if not isElement(banSerialLbl) then
banSerialLbl = guiCreateLabel ( 20, 110, 270, 15, "Enter player nick & reason", false, aInputForm )
guiLabelSetHorizontalAlign ( banSerialLbl, "center" )
end
if not isElement(banNickEdit) then
banNickEdit = guiCreateEdit ( 35, 130, 60, 24, "", false, aInputForm )
end
guiSetText(banNickEdit, defaultNick or "Nick")
if not isElement(banReasonEdit) then
banReasonEdit = guiCreateEdit ( 100, 130, 165, 24, "", false, aInputForm )
end
guiSetText(banReasonEdit, defaultReason or "Reason")
end
guiSetText ( aInputForm, title )
guiSetText ( aInputLabel, message )
guiSetText ( aInputValue, default )
aHideFloaters()
guiSetVisible ( aInputForm, true )
guiBringToFront ( aInputForm )
aInputAction = action
varOne = vOne
varTwo = vTwo
end
addEventHandler("onClientGUIClick", guiRoot,
function()
if source == banNickEdit then
if guiGetText(banNickEdit) == "Nick" then
guiSetText(banNickEdit, "")
end
elseif source == banReasonEdit then
if guiGetText(banReasonEdit) == "Reason" then
guiSetText(banReasonEdit, "")
end
end
end
)
function aInputBoxClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceInput ) ) ) then
if ( aInputForm ) then
removeEventHandler ( "onClientGUIClick", aInputForm, aInputBoxClick )
aInputAction = nil
destroyElement ( aInputForm )
aInputForm = nil
end
else
guiSetVisible ( aInputForm, false )
end
end
function aInputBoxClick ( button )
if ( button == "left" ) then
if ( source == aInputOk ) then
if (aInputAction == "kickPlayer") then
triggerServerEvent("aPlayer", localPlayer, varOne, "kick", guiGetText(aInputValue))
elseif (aInputAction == "setHealth") then
triggerServerEvent("aPlayer", localPlayer, varOne, "sethealth", guiGetText(aInputValue))
elseif (aInputAction == "setArmor") then
triggerServerEvent("aPlayer", localPlayer, varOne, "setarmour", guiGetText(aInputValue))
elseif (aInputAction == "setNick") then
triggerServerEvent("aPlayer", localPlayer, varOne, "setnick", guiGetText(aInputValue))
elseif (aInputAction == "shout") then
triggerServerEvent("aPlayer", localPlayer, varOne, "shout", guiGetText(aInputValue))
elseif (aInputAction == "setMoney") then
triggerServerEvent("aPlayer", localPlayer, varOne, "setmoney", guiGetText(aInputValue))
elseif (aInputAction == "setDimension") then
triggerServerEvent("aPlayer", localPlayer, varOne, "setdimension", guiGetText(aInputValue))
elseif (aInputAction == "setCurrentAmmo") then
aSetCurrentAmmo(guiGetText(aInputValue))
elseif (aInputAction == "setGameType") then
triggerServerEvent("aServer", localPlayer, "setgame", guiGetText(aInputValue))
elseif (aInputAction == "setMapName") then
triggerServerEvent("aServer", localPlayer, "setmap", guiGetText(aInputValue))
elseif (aInputAction == "setWelcome") then
triggerServerEvent("aServer", localPlayer, "setwelcome", guiGetText(aInputValue))
elseif (aInputAction == "setServerPassword") then
triggerServerEvent("aServer", localPlayer, "setpassword", guiGetText(aInputValue))
elseif (aInputAction == "serverShutdown") then
triggerServerEvent("aServer", localPlayer, "shutdown", guiGetText(aInputValue))
elseif (aInputAction == "unbanIP") then
triggerServerEvent("aBans", localPlayer, "unbanip", guiGetText(aInputValue))
elseif (aInputAction == "unbanSerial") then
triggerServerEvent("aBans", localPlayer, "unbanserial", guiGetText(aInputValue))
elseif (aInputAction == "banIP") or (aInputAction == "banSerial") then
local theDuration = 0
local durType = guiGetText(banSerialCombo)
if durType and durType ~= "Perm" then
-- First validate entry, must be a number
local durEntry = tonumber(guiGetText(durationEdit))
if not durEntry or type(durEntry) ~= "number" then
return outputChatBox("* Error: Enter a valid numeric duration value", 255, 0, 0)
else
if durType == "Mins" then
theDuration = math.floor(math.abs(durEntry)) * 60
elseif durType == "Hours" then
theDuration = math.floor(math.abs(durEntry)) * 60 * 60
elseif durType == "Days" then
theDuration = math.floor(math.abs(durEntry)) * 24 * 60 * 60
end
end
end
if aInputAction == "banIP" then
triggerServerEvent("aBans", localPlayer, "banip", guiGetText(aInputValue), guiGetText(banNickEdit), guiGetText(banReasonEdit), theDuration)
elseif aInputAction == "banSerial" then
triggerServerEvent("aBans", localPlayer, "banserial", guiGetText(aInputValue), guiGetText(banNickEdit), guiGetText(banReasonEdit), theDuration)
end
elseif (aInputAction == "settingChange") then
triggerServerEvent("aAdmin", localPlayer, "settings", "change", varOne, varTwo, guiGetText(aInputValue))
elseif (aInputAction == "aclCreateGroup") then
triggerServerEvent("aAdmin", localPlayer, "aclcreate", "group", guiGetText(aInputValue))
elseif (aInputAction == "aclCreate") then
triggerServerEvent("aAdmin", localPlayer, "aclcreate", "acl", guiGetText(aInputValue))
elseif (aInputAction == "aclAddObject") then
triggerServerEvent("aAdmin", localPlayer, "acladd", "object", varOne, guiGetText(aInputValue))
elseif (aInputAction == "aclAddRight") then
triggerServerEvent("aAdmin", localPlayer, "acladd", "right", varOne, guiGetText(aInputValue))
end
aInputAction = nil
aInputBoxClose ( false )
elseif ( source == aInputCancel ) then
aInputAction = nil
aInputBoxClose ( false )
end
end
end
--
-- Ban input box
--
aBanInputForm = nil
local aBanDurations = {}
function aBanInputBox ( player )
-- parse 'bandurations' setting
local durations = {}
table.insert( durations, "Custom:" )
for i,dur in ipairs( split( g_Prefs.bandurations, string.byte(',') ) ) do
if tonumber( dur ) then
table.insert( durations, tonumber( dur ) )
end
end
-- destroy form if number of durations has changed
if #aBanDurations ~= #durations then
if aBanInputForm then
_widgets["BanInputBox"] = nil
destroyElement( aBanInputForm )
aBanInputForm = nil
end
end
aBanDurations = durations
if ( aBanInputForm == nil ) then
local height1 = 100
local height2 = math.floor( #aBanDurations * 1.02 * 15 ) + 20
local height = math.max(height1,height2)
local x, y = guiGetScreenSize()
aBanInputForm = guiCreateWindow ( x / 2 - 150, y / 2 - 64, 400, height + 130, "", false )
guiWindowSetSizable ( aBanInputForm, false )
guiSetAlpha(aBanInputForm, 1)
y = 24
aBanInputLabel = guiCreateLabel ( 20, y, 270, 15, "", false, aBanInputForm )
guiLabelSetHorizontalAlign ( aBanInputLabel, "center" )
y = y + 23
aBanInputValue = guiCreateEdit ( 35, y, 230, 24, "", false, aBanInputForm )
y = y + 33
aBanInputRadioSet1bg = guiCreateTabPanel( 10, y, 120, 100, false, aBanInputForm)
aBanInputRadioSet1 = guiCreateStaticImage(0,0,1,1, 'client\\images\\empty.png', true, aBanInputRadioSet1bg)
guiSetAlpha ( aBanInputRadioSet1bg, 0.3 )
guiSetProperty ( aBanInputRadioSet1, 'InheritsAlpha', 'false' )
aBanInputRadio1Label = guiCreateLabel ( 10, 20, 270, 15, "Type:", false, aBanInputRadioSet1 )
aBanInputRadio1A = guiCreateRadioButton ( 50, 20, 50, 15, "IP", false, aBanInputRadioSet1 )
aBanInputRadio1B = guiCreateRadioButton ( 50, 35, 120, 15, "Serial", false, aBanInputRadioSet1 )
aBanInputRadioSet2bg = guiCreateTabPanel( 135, y, 260, height2, false, aBanInputForm)
aBanInputRadioSet2 = guiCreateStaticImage(0,0,1,1, 'client\\images\\empty.png', true, aBanInputRadioSet2bg)
guiSetAlpha ( aBanInputRadioSet2bg, 0.3 )
guiSetProperty ( aBanInputRadioSet2, 'InheritsAlpha', 'false' )
local yy = 5
aBanInputRadio2Label = guiCreateLabel ( 10, yy, 270, 15, "Duration:", false, aBanInputRadioSet2 )
aBanInputRadio2s = {}
for i,dur in ipairs(aBanDurations) do
aBanInputRadio2s[i] = guiCreateRadioButton ( 70, yy, 90, 15, "-", false, aBanInputRadioSet2 )
yy = yy + 15
end
customDuration = guiCreateEdit ( 138, 3, 50, 24, "", false, aBanInputRadioSet2 )
customType = guiCreateComboBox ( 190, 4, 65, 80, "Mins", false, aBanInputRadioSet2 )
guiComboBoxAddItem(customType, "Mins")
guiComboBoxAddItem(customType, "Hours")
guiComboBoxAddItem(customType, "Days")
y = y + height + 10
aBanInputOk = guiCreateButton ( 90, y, 55, 17, "Ok", false, aBanInputForm )
aBanInputCancel = guiCreateButton ( 150, y, 55, 17, "Cancel", false, aBanInputForm )
y = y + 30
guiSetSize ( aBanInputForm, guiGetSize ( aBanInputForm, false ), y, false )
guiSetProperty ( aBanInputForm, "AlwaysOnTop", "true" )
aBanInputPlayer = nil
addEventHandler ( "onClientGUIClick", aBanInputForm, aBanInputBoxClick )
addEventHandler ( "onClientGUIAccepted", aBanInputValue, aBanInputBoxAccepted )
--Register With Admin Form
aRegister ( "BanInputBox", aBanInputForm, aBanInputBox, aBanInputBoxClose )
end
-- update duration values in the form
for i,dur in ipairs(aBanDurations) do
if dur == "Custom:" then
guiSetText ( aBanInputRadio2s[i], "Custom:" )
else
guiSetText ( aBanInputRadio2s[i], dur>0 and secondsToTimeDesc(dur) or "Permanent" )
end
end
guiSetText ( aBanInputForm, "Ban player " .. string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "" ))
guiSetText ( aBanInputLabel, "Enter the ban reason" )
aHideFloaters()
guiSetVisible ( aBanInputForm, true )
guiBringToFront ( aBanInputForm )
aBanInputPlayer = player
end
function aBanInputBoxClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceInput ) ) ) then
if ( aBanInputForm ) then
removeEventHandler ( "onClientGUIClick", aBanInputForm, aBanInputBoxClick )
removeEventHandler ( "onClientGUIAccepted", aBanInputValue, aBanInputBoxAccepted )
aBanInputPlayer = nil
destroyElement ( aBanInputForm )
aBanInputForm = nil
end
else
guiSetVisible ( aBanInputForm, false )
end
end
function aBanInputBoxAccepted ()
aBanInputBoxFinish()
end
function aBanInputBoxClick ( button )
if ( button == "left" ) then
if ( source == aBanInputOk ) then
aBanInputBoxFinish()
aBanInputPlayer = nil
aBanInputBoxClose ( false )
elseif ( source == aBanInputCancel ) then
aBanInputPlayer = nil
aBanInputBoxClose ( false )
end
end
end
function aBanInputBoxFinish ()
-- Get options
local bUseIP = guiRadioButtonGetSelected( aBanInputRadio1A )
local bUseSerial = guiRadioButtonGetSelected( aBanInputRadio1B )
-- Get duration
local seconds = false
for i,dur in ipairs(aBanDurations) do
if guiRadioButtonGetSelected( aBanInputRadio2s[i] ) then
if guiGetText(aBanInputRadio2s[i]) == "Custom:" then
if guiComboBoxGetItemText(customType, guiComboBoxGetSelected(customType)) == "Mins" then
seconds = guiGetText(customDuration) * 60
elseif guiComboBoxGetItemText(customType, guiComboBoxGetSelected(customType)) == "Hours" then
seconds = guiGetText(customDuration) * 3600
elseif guiComboBoxGetItemText(customType, guiComboBoxGetSelected(customType)) == "Days" then
seconds = guiGetText(customDuration) * 86400
end
else
seconds = dur
end
end
end
-- Get reason
local reason = guiGetText ( aBanInputValue )
-- Validate settings
if not bUseIP and not bUseSerial then
aMessageBox ( "error", "No type selected!" )
return
end
if seconds == false then
aMessageBox ( "error", "No duration selected!" )
return
end
-- Send ban info to the server
triggerServerEvent ( "aPlayer", localPlayer, aBanInputPlayer, "ban", reason, seconds, bUseSerial )
-- Clear input
guiSetText ( aBanInputValue, "" )
for i,dur in ipairs(aBanDurations) do
guiRadioButtonSetSelected( aBanInputRadio2s[i], false )
end
end
--
-- Mute input box
--
aMuteInputForm = nil
local aMuteDurations = {}
function aMuteInputBox ( player )
-- parse 'mutedurations' setting
local durations = {}
for i,dur in ipairs( split( g_Prefs.mutedurations, string.byte(',') ) ) do
if tonumber( dur ) then
table.insert( durations, tonumber( dur ) )
end
end
-- destroy form if number of durations has changed
if #aMuteDurations ~= #durations then
if aMuteInputForm then
_widgets["MuteInputBox"] = nil
destroyElement( aMuteInputForm )
aMuteInputForm = nil
end
end
aMuteDurations = durations
if ( aMuteInputForm == nil ) then
local x, y = guiGetScreenSize()
aMuteInputForm = guiCreateWindow ( x / 2 - 150, y / 2 - 64, 300, 150 + #aMuteDurations * 15, "", false )
guiWindowSetSizable ( aMuteInputForm, false )
guiSetAlpha(aMuteInputForm, 1)
y = 24
aMuteInputLabel = guiCreateLabel ( 20, y, 270, 15, "", false, aMuteInputForm )
guiLabelSetHorizontalAlign ( aMuteInputLabel, "center" )
y = y + 23
aMuteInputValue = guiCreateEdit ( 35, y, 230, 24, "", false, aMuteInputForm )
y = y + 33
local height2 = math.floor( #aMuteDurations * 1.02 * 15 ) + 20
aMuteInputRadioSet2bg = guiCreateTabPanel( 55, y, 300-55*2, height2, false, aMuteInputForm)
aMuteInputRadioSet2 = guiCreateStaticImage(0,0,1,1, 'client\\images\\empty.png', true, aMuteInputRadioSet2bg)
guiSetAlpha ( aMuteInputRadioSet2bg, 0.3 )
guiSetProperty ( aMuteInputRadioSet2, 'InheritsAlpha', 'false' )
local yy = 5
aMuteInputRadio2Label = guiCreateLabel ( 10, yy, 270, 15, "Duration:", false, aMuteInputRadioSet2 )
aMuteInputRadio2s = {}
for i,dur in ipairs(aMuteDurations) do
aMuteInputRadio2s[i] = guiCreateRadioButton ( 70, yy, 120, 15, "-", false, aMuteInputRadioSet2 )
yy = yy + 15
end
y = y + height2 + 10
aMuteInputOk = guiCreateButton ( 90, y, 55, 17, "Ok", false, aMuteInputForm )
aMuteInputCancel = guiCreateButton ( 150, y, 55, 17, "Cancel", false, aMuteInputForm )
y = y + 30
guiSetSize ( aMuteInputForm, guiGetSize ( aMuteInputForm, false ), y, false )
guiSetProperty ( aMuteInputForm, "AlwaysOnTop", "true" )
aMuteInputPlayer = nil
addEventHandler ( "onClientGUIClick", aMuteInputForm, aMuteInputBoxClick )
addEventHandler ( "onClientGUIAccepted", aMuteInputValue, aMuteInputBoxFinish )
--Register With Admin Form
aRegister ( "MuteInputBox", aMuteInputForm, aMuteInputBox, aMuteInputBoxClose )
end
-- update duration values in the form
for i,dur in ipairs(aMuteDurations) do
guiSetText ( aMuteInputRadio2s[i], dur>0 and secondsToTimeDesc(dur) or "Until reconnect" )
end
guiSetText ( aMuteInputForm, "Mute player " .. removeColorCoding(getPlayerName(player)) )
guiSetText ( aMuteInputLabel, "Enter the mute reason" )
aHideFloaters()
guiSetVisible ( aMuteInputForm, true )
guiBringToFront ( aMuteInputForm )
aMuteInputPlayer = player
end
function aMuteInputBoxClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceInput ) ) ) then
if ( aMuteInputForm ) then
removeEventHandler ( "onClientGUIClick", aMuteInputForm, aMuteInputBoxClick )
removeEventHandler ( "onClientGUIAccepted", aMuteInputValue, aMuteInputBoxFinish )
aMuteInputPlayer = nil
destroyElement ( aMuteInputForm )
aMuteInputForm = nil
end
else
guiSetVisible ( aMuteInputForm, false )
end
end
function aMuteInputBoxClick ( button )
if ( button == "left" ) then
if ( source == aMuteInputOk ) then
aMuteInputBoxFinish()
aMuteInputPlayer = nil
aMuteInputBoxClose ( false )
elseif ( source == aMuteInputCancel ) then
aMuteInputPlayer = nil
aMuteInputBoxClose ( false )
end
end
end
function aMuteInputBoxFinish ()
-- Get duration
local seconds = false
for i,dur in ipairs(aMuteDurations) do
if guiRadioButtonGetSelected( aMuteInputRadio2s[i] ) then
seconds = dur
end
end
-- Get reason
local reason = guiGetText ( aMuteInputValue )
-- Validate settings
if seconds == false then
aMessageBox ( "error", "No duration selected!" )
return
end
-- Send mute info to the server
triggerServerEvent ( "aPlayer", localPlayer, aMuteInputPlayer, "mute", reason, seconds )
-- Clear input
guiSetText ( aMuteInputValue, "" )
for i,dur in ipairs(aMuteDurations) do
guiRadioButtonSetSelected( aMuteInputRadio2s[i], false )
end
end

View file

@ -0,0 +1,80 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_interior.lua
*
* Original File by lil_Toady
*
**************************************]]
aInteriorForm = nil
function aPlayerInterior ( player )
if ( aInteriorForm == nil ) then
local x, y = guiGetScreenSize()
aInteriorForm = guiCreateWindow ( x / 2 - 110, y / 2 - 150, 220, 300, "Player Interior Management", false )
aInteriorList = guiCreateGridList ( 0.03, 0.08, 0.94, 0.73, true, aInteriorForm )
guiGridListAddColumn( aInteriorList, "World", 0.2 )
guiGridListAddColumn( aInteriorList, "Description", 0.75 )
aInteriorSelect = guiCreateButton ( 0.03, 0.82, 0.94, 0.075, "Select", true, aInteriorForm )
aInteriorCancel = guiCreateButton ( 0.03, 0.90, 0.94, 0.075, "Cancel", true, aInteriorForm )
local node = xmlLoadFile ( "conf\\interiors.xml" )
if ( node ) then
local interiors = 0
while ( xmlFindChild ( node, "interior", interiors ) ~= false ) do
local interior = xmlFindChild ( node, "interior", interiors )
local row = guiGridListAddRow ( aInteriorList )
guiGridListSetItemText ( aInteriorList, row, 1, xmlNodeGetAttribute ( interior, "world" ), false, true )
guiGridListSetItemText ( aInteriorList, row, 2, xmlNodeGetAttribute ( interior, "id" ), false, false )
interiors = interiors + 1
end
xmlUnloadFile ( node )
end
addEventHandler ( "onClientGUIDoubleClick", aInteriorForm, aClientInteriorDoubleClick )
addEventHandler ( "onClientGUIClick", aInteriorForm, aClientInteriorClick )
--Register With Admin Form
aRegister ( "PlayerInterior", aInteriorForm, aPlayerInterior, aPlayerInteriorClose )
end
aInteriorSelectPointer = player
guiSetVisible ( aInteriorForm, true )
guiBringToFront ( aInteriorForm )
end
function aPlayerInteriorClose ( destroy )
if ( destroy ) then
if ( aInteriorForm ) then
removeEventHandler ( "onClientGUIDoubleClick", aInteriorForm, aClientInteriorDoubleClick )
removeEventHandler ( "onClientGUIClick", aInteriorForm, aClientInteriorClick )
destroyElement ( aInteriorForm )
aInteriorForm = nil
end
else
guiSetVisible ( aInteriorForm, false )
end
end
function aClientInteriorDoubleClick ( button )
if ( button == "left" ) then
if ( source == aInteriorList ) then
if ( guiGridListGetSelectedItem ( aInteriorList ) ~= -1 ) then
triggerServerEvent ( "aPlayer", localPlayer, aInteriorSelectPointer, "setinterior", guiGridListGetItemText ( aInteriorList, guiGridListGetSelectedItem ( aInteriorList ), 2 ) )
aPlayerInteriorClose ( false )
end
end
end
end
function aClientInteriorClick ( button )
if ( button == "left" ) then
if ( source == aInteriorSelect ) then
if ( guiGridListGetSelectedItem ( aInteriorList ) ~= -1 ) then
triggerServerEvent ( "aPlayer", localPlayer, aInteriorSelectPointer, "setinterior", guiGridListGetItemText ( aInteriorList, guiGridListGetSelectedItem ( aInteriorList ), 2 ) )
guiSetVisible ( aInteriorForm, false )
end
elseif ( source == aInteriorCancel ) then
aPlayerInteriorClose ( false )
end
end
end

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,174 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_maps.lua
*
* Original File by eXo|Flobu
*
**************************************]]
aGamemodeMapTable = {}
function createMapTab()
aTabMap = {}
aTabMap.Tab = guiCreateTab ( "Maps", aTabPanel, "maps" )
aTabMap.MapListSearch = guiCreateEdit ( 0.03, 0.05, 0.31, 0.04, "", true, aTabMap.Tab )
guiCreateStaticImage ( 0.34, 0.05, 0.035, 0.04, "client\\images\\search.png", true, aTabMap.Tab )
aTabMap.MapList = guiCreateGridList ( 0.03, 0.10, 0.35, 0.80, true, aTabMap.Tab )
guiGridListAddColumn( aTabMap.MapList, "Map Name", 2)
guiGridListAddColumn( aTabMap.MapList, "Resource Name", 1)
guiGridListAddColumn( aTabMap.MapList, "Gamemode", 0.5)
aTabMap.Start = guiCreateButton ( 0.45, 0.05, 0.3, 0.04, "Start Gamemode with Map", true, aTabMap.Tab )
aTabMap.CurMap = guiCreateLabel ( 0.46, 0.15, 0.40, 0.035, "Current Map: N/A", true, aTabMap.Tab )
aTabMap.CurGamemode = guiCreateLabel ( 0.46, 0.2, 0.40, 0.035, "Current Gamemode: N/A", true, aTabMap.Tab )
aTabMap.NextMap = guiCreateButton ( 0.45, 0.35, 0.3, 0.04, "Set Next Map", true, aTabMap.Tab )
aTabMap.Delete = guiCreateButton ( 0.45, 0.40, 0.3, 0.04, "Delete Map", true, aTabMap.Tab )
aTabMap.Revert = guiCreateButton ( 0.45, 0.45, 0.3, 0.04, "Revert Map", true, aTabMap.Tab )
guiSetVisible(aTabMap.Delete, false)
guiSetVisible(aTabMap.Revert, false)
aTabMap.RefreshList = guiCreateButton ( 0.03, 0.91, 0.35, 0.04, "Refresh list", true, aTabMap.Tab )
addEventHandler ("onClientGUIClick", aAdminForm, guiClick)
addEventHandler ("onClientGUIDoubleClick", aAdminForm, guiDoubleClick)
addEventHandler ("onClientGUIChanged", aAdminForm, guiChanged)
end
function loadMaps(gamemodeMapTable, gamemode1, map)
guiSetText(aTabMap.CurMap,"Current Map: ".. tostring ( map or "N/A" ) )
guiSetText(aTabMap.CurGamemode,"Current Gamemode: ".. tostring ( gamemode1 or "N/A" ) );
if gamemodeMapTable then
aGamemodeMapTable = gamemodeMapTable
for id,gamemode in pairs (gamemodeMapTable) do
guiGridListSetItemText ( aTabMap.MapList, guiGridListAddRow ( aTabMap.MapList ), 1, gamemode.name, true, false )
if #gamemode.maps == 0 and gamemode.name ~= "no gamemode" and gamemode.name ~= "deleted maps" then
local row = guiGridListAddRow ( aTabMap.MapList )
guiGridListSetItemText ( aTabMap.MapList, row, 1, gamemode.name, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 2, gamemode.resname, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 3, gamemode.resname, false, false )
else
for id2,map2 in ipairs (gamemode.maps) do
local row = guiGridListAddRow ( aTabMap.MapList )
guiGridListSetItemText ( aTabMap.MapList, row, 1, map2.name, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 2, map2.resname, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 3, gamemode.resname, false, false )
end
end
end
end
end
addEvent("getMaps_c", true)
addEventHandler("getMaps_c", localPlayer, loadMaps)
function guiClick(button)
if button == "left" then
if ( getElementParent ( source ) == aTabMap.Tab ) then
if source == aTabMap.RefreshList then
guiGridListClear(aTabMap.MapList)
triggerServerEvent("getMaps_s", localPlayer, true)
end
if ( source ~= aTabMap.MapListSearch ) and guiGridListGetSelectedItem ( aTabMap.MapList ) == -1 then
aMessageBox ( "error", "No map selected!" )
end
local mapName = guiGridListGetItemText ( aTabMap.MapList, guiGridListGetSelectedItem( aTabMap.MapList ), 1 )
local mapResName = guiGridListGetItemText ( aTabMap.MapList, guiGridListGetSelectedItem( aTabMap.MapList ), 2 )
local gamemode = guiGridListGetItemText ( aTabMap.MapList, guiGridListGetSelectedItem( aTabMap.MapList ), 3 )
if source == aTabMap.MapList then
if gamemode == "race" then
guiSetEnabled(aTabMap.NextMap, true)
else
guiSetEnabled(aTabMap.NextMap, false)
end
elseif source == aTabMap.Start then
triggerServerEvent("startGamemodeMap_s", localPlayer, gamemode, mapResName)
elseif source == aTabMap.NextMap then
if gamemode == "race" then
triggerServerEvent("setNextMap_s", localPlayer, mapName)
end
elseif source == aTabMap.Delete then
aMessageBox ( "question", "Are you sure to delete '"..mapName.."'?", "deleteMap", mapResName, mapName )
elseif source == aTabMap.Revert then
triggerServerEvent("deleteRevertMap_s", localPlayer, false, mapResName, mapName)
end
end
end
end
function guiDoubleClick(button)
if button == "left" then
if ( getElementParent ( source ) == aTabMap.Tab ) then
local mapResName = guiGridListGetItemText ( aTabMap.MapList, guiGridListGetSelectedItem( aTabMap.MapList ), 2 )
local gamemode = guiGridListGetItemText ( aTabMap.MapList, guiGridListGetSelectedItem( aTabMap.MapList ), 3 )
if source == aTabMap.MapList then
triggerServerEvent("startGamemodeMap_s", localPlayer, gamemode, mapResName)
end
end
end
end
function guiChanged()
guiGridListClear(aTabMap.MapList)
local text = string.lower(guiGetText(source))
if ( text == "" ) then
for id,gamemode in pairs (aGamemodeMapTable) do
guiGridListSetItemText ( aTabMap.MapList, guiGridListAddRow ( aTabMap.MapList ), 1, gamemode.name, true, false )
if #gamemode.maps == 0 and gamemode.name ~= "no gamemode" and gamemode.name ~= "deleted maps" then
local row = guiGridListAddRow ( aTabMap.MapList )
guiGridListSetItemText ( aTabMap.MapList, row, 1, gamemode.name, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 2, gamemode.resname, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 3, gamemode.resname, false, false )
else
for id2,map in ipairs (gamemode.maps) do
local row = guiGridListAddRow ( aTabMap.MapList )
guiGridListSetItemText ( aTabMap.MapList, row, 1, map.name, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 2, map.resname, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 3, gamemode.resname, false, false )
end
end
end
else
for id,gamemode in pairs (aGamemodeMapTable) do
local gameModeRow = guiGridListAddRow ( aTabMap.MapList )
local noMaps = true
guiGridListSetItemText ( aTabMap.MapList, gameModeRow, 1, gamemode.name, true, false )
if #gamemode.maps == 0 and gamemode.name ~= "no gamemode" and gamemode.name ~= "deleted maps" then
if string.find(string.lower(gamemode.name.." "..gamemode.resname), text, 1, true) then
local row = guiGridListAddRow ( aTabMap.MapList )
guiGridListSetItemText ( aTabMap.MapList, row, 1, gamemode.name, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 2, gamemode.resname, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 3, gamemode.resname, false, false )
noMaps = false
end
else
for id2,map in ipairs (gamemode.maps) do
if string.find(string.lower(map.name.." "..map.resname), text, 1, true) then
local row = guiGridListAddRow ( aTabMap.MapList )
guiGridListSetItemText ( aTabMap.MapList, row, 1, map.name, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 2, map.resname, false, false )
guiGridListSetItemText ( aTabMap.MapList, row, 3, gamemode.resname, false, false )
noMaps = false
end
end
end
if noMaps then
guiGridListRemoveRow(aTabMap.MapList, gameModeRow)
end
end
end
end
addEvent("deleteRevertMap_c", true)
addEventHandler("deleteRevertMap_c", localPlayer,
function(success, delete, mapName)
if success then
guiGridListClear(aTabMap.MapList)
triggerServerEvent("getMaps_s", localPlayer, true)
if delete then
aMessageBox ( "info", "Map '"..mapName.."' deleted successfully!" )
else
aMessageBox ( "info", "Map '"..mapName.."' reverted successfully!" )
end
else
aMessageBox ( "error", "cant delete/revert!" )
end
end
)

View file

@ -0,0 +1,121 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_message.lua
*
* Original File by lil_Toady
*
**************************************]]
aViewMessageForm = nil
local aSuspectInfo = nil
local viewID
function aViewMessage ( id )
if ( aSuspectInfo and viewID and viewID ~= id ) then
destroyElement(aSuspectInfo)
aSuspectInfo = nil
end
viewID = id
if ( aViewMessageForm == nil ) then
local x, y = guiGetScreenSize()
aViewMessageForm = guiCreateWindow ( x / 2 - 150, y / 2 - 129, 300, 258, "", false )
guiCreateLabel ( 0.05, 0.10, 0.30, 0.09, "Category:", true, aViewMessageForm )
guiCreateLabel ( 0.05, 0.18, 0.30, 0.09, "Time:", true, aViewMessageForm )
guiCreateLabel ( 0.05, 0.26, 0.30, 0.09, "By:", true, aViewMessageForm )
aViewMessageLabelSuspect = guiCreateLabel ( 0.05, 0.34, 0.30, 0.09, "Suspect:", true, aViewMessageForm )
aViewMessageSuspect = guiCreateButton ( 0.40, 0.34, 0.55, 0.07, "View info", true, aViewMessageForm )
aViewMessageCategory = guiCreateLabel ( 0.40, 0.10, 0.55, 0.09, "", true, aViewMessageForm )
aViewMessageTime = guiCreateLabel ( 0.40, 0.18, 0.55, 0.09, "", true, aViewMessageForm )
aViewMessageAuthor = guiCreateLabel ( 0.40, 0.26, 0.55, 0.09, "", true, aViewMessageForm )
aViewMessageText = guiCreateMemo ( 0.05, 0.42, 0.90, 0.44, "", true, aViewMessageForm )
guiMemoSetReadOnly ( aViewMessageText, true )
aViewMessageCloseB = guiCreateButton ( 0.77, 0.86, 0.20, 0.09, "Close", true, aViewMessageForm )
addEventHandler ( "onClientGUIClick", aViewMessageForm, aClientMessageClick )
addEventHandler ( "onClientGUIClick", aViewMessageSuspect, aViewSuspectInfo )
--Register With Admin Form
aRegister ( "Message", aViewMessageForm, aViewMessage, aViewMessageClose )
end
if ( _messages[id] ) then
guiSetText ( aViewMessageCategory, _messages[id].category )
guiSetText ( aViewMessageForm, _messages[id].subject )
guiSetText ( aViewMessageTime, _messages[id].time )
guiSetText ( aViewMessageAuthor, removeColorCoding( _messages[id].author ) )
guiSetText ( aViewMessageText, _messages[id].text )
guiSetVisible ( aViewMessageForm, true )
local isVisible = _messages[id].suspect ~= nil
guiSetVisible ( aViewMessageLabelSuspect, isVisible )
guiSetVisible ( aViewMessageSuspect, isVisible )
guiBringToFront ( aViewMessageForm )
triggerServerEvent ( "aMessage", localPlayer, "read", id )
end
end
function aViewSuspectInfo ( button )
if ( button == "left" ) then
if ( source == aViewMessageSuspect ) then
if ( aSuspectInfo == nil ) then
local suspectInfo = _messages[viewID].suspect
if ( suspectInfo ) then
local x, y = guiGetScreenSize()
aSuspectInfo = guiCreateWindow(x / 2 - 145, y / 2 - 192.5, 290, 385, "Player information", false)
local btnClose = guiCreateButton(0.365, 0.88, 0.27, 0.10, "Close", true, aSuspectInfo)
addEventHandler("onClientGUIClick", btnClose, function()
destroyElement(aSuspectInfo)
aSuspectInfo = nil
end, false)
local displayInfo = {
'Nickname: '.. removeColorCoding(suspectInfo.name),
'Account name: '.. getSensitiveText(suspectInfo.username),
'IP: '.. getSensitiveText(suspectInfo.ip),
'Serial: '.. getSensitiveText(suspectInfo.serial),
'MTA version: '.. suspectInfo.version,
'\nChat log:\n' .. suspectInfo.chatLog,
}
local text = table.concat(displayInfo, '\n')
local infoMemo = guiCreateMemo(0.04, 0.1, 0.96, 0.75, text, true, aSuspectInfo)
guiMemoSetReadOnly(infoMemo, true)
else
aMessageBox ( "error", "This report does have any suspect information." )
end
end
end
end
end
function aViewMessageClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceMessage ) ) ) then
if ( aViewMessageForm ) then
removeEventHandler ( "onClientGUIClick", aViewMessageForm, aClientMessageClick )
if ( aViewMessageSuspect ) then
removeEventHandler ( "onClientGUIClick", aViewMessageSuspect, aViewSuspectInfo )
end
destroyElement ( aViewMessageForm )
aViewMessageForm = nil
destroyElement(aSuspectInfo)
aSuspectInfo = nil
end
else
if aViewMessageForm then guiSetVisible ( aViewMessageForm, false ) end
if aSuspectInfo then
destroyElement ( aSuspectInfo )
aSuspectInfo = nil
end
end
end
function aClientMessageClick ( button )
if ( button == "left" ) then
if ( source == aViewMessageCloseB ) then
aViewMessageClose ( false )
end
end
end

View file

@ -0,0 +1,161 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_messagebox.lua
*
* Original File by lil_Toady
*
**************************************]]
aMessageForm = nil
local varOne, varTwo, varThree
function aMessageBox ( type, message, action, vOne, vTwo, vThree )
local x, y = guiGetScreenSize()
if ( aMessageForm == nil ) then
aMessageForm = guiCreateWindow ( x / 2 - 150, y / 2 - 64, 300, 110, "", false )
guiWindowSetSizable ( aMessageForm, false )
aMessageWarning = guiCreateStaticImage ( 10, 32, 60, 60, "client\\images\\warning.png", false, aMessageForm )
aMessageQuestion = guiCreateStaticImage ( 10, 32, 60, 60, "client\\images\\question.png", false, aMessageForm )
aMessageError = guiCreateStaticImage ( 10, 32, 60, 60, "client\\images\\error.png", false, aMessageForm )
aMessageInfo = guiCreateStaticImage ( 10, 32, 60, 60, "client\\images\\info.png", false, aMessageForm )
aMessageLabel = guiCreateLabel ( 100, 32, 180, 64, "", false, aMessageForm )
guiLabelSetHorizontalAlign ( aMessageLabel, "center",true )
aMessageYes = guiCreateButton ( 120, 70, 55, 17, "Yes", false, aMessageForm )
aMessageNo = guiCreateButton ( 180, 70, 55, 17, "No", false, aMessageForm )
aMessageOk = guiCreateButton ( 160, 70, 55, 17, "Ok", false, aMessageForm )
guiSetProperty ( aMessageForm, "AlwaysOnTop", "true" )
aMessageAction = nil
bindKey ( "enter", "down", aMessageBoxAccept )
bindKey ( "n", "down", aMessageBoxAccept )
addEventHandler ( "onClientGUIClick", aMessageForm, aMessageBoxClick )
--Register With Admin Form
aRegister ( "MessageBox", aMessageForm, aMessageBox, aMessageBoxClose )
end
guiSetText ( aMessageForm, type )
guiSetText ( aMessageLabel, tostring ( message ) )
local width = guiLabelGetTextExtent ( aMessageLabel )
if ( width > 180 ) then
guiSetSize ( aMessageForm, 500, 120, false )
guiSetSize ( aMessageLabel, 350, 100, false )
else
guiSetSize ( aMessageForm, 300, 120, false )
guiSetSize ( aMessageLabel, 150, 30, false )
end
local sx, sy = guiGetSize ( aMessageForm, false )
guiSetPosition ( aMessageOk, sx / 2 - 22, 90, false )
guiSetPosition ( aMessageForm, x / 2 - sx / 2, y / 2 - sy / 2, false )
guiBringToFront ( aMessageForm )
guiSetVisible ( aMessageWarning, false )
guiSetVisible ( aMessageQuestion, false )
guiSetVisible ( aMessageError, false )
guiSetVisible ( aMessageInfo, false )
guiSetVisible ( aMessageYes, false )
guiSetVisible ( aMessageNo, false )
guiSetVisible ( aMessageOk, false )
aHideFloaters()
guiSetVisible ( aMessageForm, true )
if ( type == "warning" ) then guiSetVisible ( aMessageWarning, true )
elseif ( type == "question" ) then guiSetVisible ( aMessageQuestion, true )
elseif ( type == "error" ) then guiSetVisible ( aMessageError, true )
else guiSetVisible ( aMessageInfo, true ) end
if ( ( action ~= "" ) and ( action ~= nil ) and ( action ~= false ) ) then
guiSetVisible ( aMessageYes, true )
guiSetVisible ( aMessageNo, true )
aMessageAction = action
varOne, varTwo, varThree = vOne, vTwo, vThree
else
guiSetVisible ( aMessageOk, true )
end
end
function aMessageBoxClose ( destroy )
if ( ( destroy ) or ( aPerformanceMessage and guiCheckBoxGetSelected ( aPerformanceMessage ) ) ) then
if ( aMessageForm ) then
unbindKey ( "enter", "down", aMessageBoxAccept )
unbindKey ( "n", "down", aMessageBoxAccept )
removeEventHandler ( "onClientGUIClick", aMessageForm, aMessageBoxClick )
aMessageAction = nil
destroyElement ( aMessageForm )
aMessageForm = nil
end
else
if aMessageForm then guiSetVisible ( aMessageForm, false ) end
end
end
function aMessageBoxAccept ( key, state )
if ( guiGetVisible ( aMessageForm ) ) then
if ( guiGetVisible ( aMessageOk ) ) then
if ( key == "enter" ) then
aMessageAction = nil
aMessageBoxClose ( false )
end
else
if ( key == "enter" ) then
if ( aMessageAction ~= nil ) then
runMessageAction(aMessageAction)
end
aMessageAction = nil
aMessageBoxClose ( false )
elseif ( key == "n" ) then
aMessageAction = nil
aMessageBoxClose ( false )
end
end
end
end
function aMessageBoxClick ( button )
if ( button == "left" ) then
if ( source == aMessageYes ) then
if ( aMessageAction ~= nil ) then
runMessageAction(aMessageAction)
end
aMessageAction = nil
aMessageBoxClose ( false )
elseif ( ( source == aMessageNo ) or ( source == aMessageOk ) ) then
aMessageAction = nil
aMessageBoxClose ( false )
end
end
end
function runMessageAction(action)
if (action == "aclDestroyGroup") then
triggerServerEvent("aAdmin", localPlayer, "acldestroy", "group", varOne)
elseif (action == "aclDestroy") then
triggerServerEvent("aAdmin", localPlayer, "acldestroy", "acl", varOne)
elseif (action == "revokeAdmin") then
triggerServerEvent("aPlayer", localPlayer, varOne, "setgroup", false)
elseif (action == "giveAdmin") then
triggerServerEvent("aPlayer", localPlayer, varOne, "setgroup", true)
elseif (action == "stopDelete") then
triggerServerEvent("aResource", localPlayer, varOne, "delete")
elseif (action == "stopAll") then
triggerServerEvent("aResource", localPlayer, nil, "stopall")
elseif (action == "unbanSerial") then
triggerServerEvent("aBans", localPlayer, "unbanserial", varOne)
elseif (action == "unbanIP") then
triggerServerEvent("aBans", localPlayer, "unbanip", varOne)
elseif (action == "unmute") then
triggerServerEvent("aPlayer", localPlayer, varOne, "mute")
elseif (action == "deleteMap") then
triggerServerEvent("deleteRevertMap_s", localPlayer, true, varOne, varTwo)
elseif (action == "spectatorClose") then
aSpectator.Close(false)
elseif (action == "deleteTeam") then
triggerServerEvent("aTeam", localPlayer, "destroyteam", varOne)
elseif (action == "updatePlayerACLGroup") then
aPermissions.PerformAction(varOne, varTwo, varThree)
end
end
function aHideFloaters()
if aMessagesForm then guiSetVisible ( aMessagesForm, false ) end -- admin messages
if aMessageForm then guiSetVisible ( aMessageForm, false ) end -- message box
if aInputForm then guiSetVisible ( aInputForm, false ) end
if aBanInputForm then guiSetVisible ( aBanInputForm, false ) end
if aMuteInputForm then guiSetVisible ( aMuteInputForm, false ) end
end

View file

@ -0,0 +1,136 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_messages.lua
*
* Original File by lil_Toady
*
**************************************]]
aMessagesForm = nil
_messages = nil
function aViewMessages ( player )
if ( aMessagesForm == nil ) then
local x, y = guiGetScreenSize()
aMessagesForm = guiCreateWindow ( x / 2 - 250, y / 2 - 125, 620, 250, "View Messages", false )
aMessagesList = guiCreateGridList ( 0.02, 0.09, 0.82, 0.85, true, aMessagesForm )
guiGridListAddColumn( aMessagesList, "#", 0.08 )
guiGridListAddColumn( aMessagesList, "Subject", 0.46 )
guiGridListAddColumn( aMessagesList, "Date", 0.23 )
guiGridListAddColumn( aMessagesList, "Author", 0.19 )
aMessagesRead = guiCreateButton ( 0.86, 0.15, 0.12, 0.09, "Read", true, aMessagesForm )
aMessagesDelete = guiCreateButton ( 0.86, 0.25, 0.12, 0.09, "Delete", true, aMessagesForm )
aMessagesBanSerial = guiCreateButton ( 0.86, 0.40, 0.12, 0.09, "Ban serial", true, aMessagesForm )
aMessagesBanIP = guiCreateButton ( 0.86, 0.50, 0.12, 0.09, "Ban IP", true, aMessagesForm )
aMessagesRefresh = guiCreateButton ( 0.86, 0.65, 0.12, 0.09, "Refresh", true, aMessagesForm )
aMessagesClose = guiCreateButton ( 0.86, 0.85, 0.12, 0.09, "Close", true, aMessagesForm )
addEventHandler ( "aMessage", root, aMessagesSync )
addEventHandler ( "onClientGUIClick", aMessagesForm, aClientMessagesClick )
addEventHandler ( "onClientGUIDoubleClick", aMessagesForm, aClientMessagesDoubleClick )
guiSetEnabled( aMessagesBanSerial, false )
guiSetEnabled( aMessagesBanIP, false )
--Register With Admin Form
aRegister ( "Messages", aMessagesForm, aViewMessages, aViewMessagesClose )
end
aHideFloaters()
guiSetVisible ( aMessagesForm, true )
guiBringToFront ( aMessagesForm )
triggerServerEvent ( "aMessage", localPlayer, "get" )
end
function aViewMessagesClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceMessage ) ) ) then
if ( aMessagesForm ) then
removeEventHandler ( "aMessage", root, aMessagesSync )
removeEventHandler ( "onClientGUIClick", aMessagesForm, aClientMessagesClick )
removeEventHandler ( "onClientGUIDoubleClick", aMessagesForm, aClientMessagesDoubleClick )
destroyElement ( aMessagesForm )
aMessagesForm = nil
end
else
guiSetVisible ( aMessagesForm, false )
end
end
function aMessagesSync ( action, data, isReportDisabled )
if ( action == "get" ) then
_messages = data
guiGridListClear ( aMessagesList )
for id=#data,1,-1 do
local message = data[id]
local row = guiGridListAddRow ( aMessagesList )
guiGridListSetItemText ( aMessagesList, row, 1, tostring ( id ), false, false )
if ( message.read ) then guiGridListSetItemText ( aMessagesList, row, 2, message.subject, false, false )
else guiGridListSetItemText ( aMessagesList, row, 2, "* "..message.subject, false, false ) end
guiGridListSetItemText ( aMessagesList, row, 3, message.time, false, false )
guiGridListSetItemText ( aMessagesList, row, 4, removeColorCoding(message.author), false, false )
end
guiSetText(aMessagesForm, (isReportDisabled ~= "true" and "View Messages (reports are disabled)" or "View Messages"))
end
end
function aClientMessagesDoubleClick ( button )
if ( button == "left" ) then
if ( source == aMessagesList ) then
local row = guiGridListGetSelectedItem ( aMessagesList )
if ( row ~= -1 ) then
local id = guiGridListGetItemText ( aMessagesList, row, 1 )
aViewMessage ( tonumber ( id ) )
end
end
end
end
function aClientMessagesClick ( button )
if ( button == "left" ) then
if ( source == aMessagesClose ) then
aViewMessagesClose ( false )
elseif ( source == aMessagesRefresh ) then
triggerServerEvent ( "aMessage", localPlayer, "get" )
elseif ( source == aMessagesRead ) then
local row = guiGridListGetSelectedItem ( aMessagesList )
if ( row == -1 ) then aMessageBox ( "Warning", "No message selected!", nil )
else
local id = guiGridListGetItemText ( aMessagesList, row, 1 )
aViewMessage ( tonumber ( id ) )
end
elseif ( source == aMessagesDelete ) then
local row = guiGridListGetSelectedItem ( aMessagesList )
if ( row == -1 ) then aMessageBox ( "Warning", "No message selected!" )
else
local id = guiGridListGetItemText ( aMessagesList, row, 1 )
triggerServerEvent ( "aMessage", localPlayer, "delete", tonumber ( id ) )
end
elseif ( source == aMessagesBanSerial ) then
local data = _messages[tonumber ( guiGridListGetItemText ( aMessagesList, guiGridListGetSelectedItem ( aMessagesList ), 1 ) )]
aInputBox ( "Add Serial Ban", "Enter Serial to be banned", data.suspect.serial, "banSerial", _, _, data.suspect.name, data.category )
elseif ( source == aMessagesBanIP ) then
local data = _messages[tonumber ( guiGridListGetItemText ( aMessagesList, guiGridListGetSelectedItem ( aMessagesList ), 1 ) )]
aInputBox ( "Add IP Ban", "Enter IP to be banned", data.suspect.ip, "banIP", _, _, data.suspect.name, data.category )
elseif ( source == aMessagesList ) then
local row = guiGridListGetSelectedItem ( aMessagesList )
if ( row == -1 ) then
guiSetEnabled( aMessagesBanSerial, false )
guiSetEnabled( aMessagesBanIP, false )
else
local id = tonumber(guiGridListGetItemText ( aMessagesList, row, 1 ))
local suspectInfo = _messages[id].suspect
if ( suspectInfo ) then
if ( hasPermissionTo ( "command.banserial" ) ) then
guiSetEnabled( aMessagesBanSerial, true )
end
if ( hasPermissionTo ( "command.banip" ) ) then
guiSetEnabled( aMessagesBanIP, true )
end
else
guiSetEnabled( aMessagesBanSerial, false )
guiSetEnabled( aMessagesBanIP, false )
end
end
end
end
end

View file

@ -0,0 +1,85 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_moddetails.lua
*
**************************************]]
aModdetailsForm = nil
local modDetailsPlayer = nil
local currentModDetails
function aViewModdetails ( player )
modDetailsPlayer = player
if ( aModdetailsForm == nil ) then
local x, y = guiGetScreenSize()
aModdetailsForm = guiCreateWindow ( x / 2 - 250, y / 2 - 125, 500, 350, "View Mod Details", false )
guiWindowSetSizable( aModdetailsForm, false )
aModdetailsList = guiCreateGridList ( 0.02, 0.09, 0.72, 0.85, true, aModdetailsForm )
guiGridListAddColumn( aModdetailsList, "Filename", 0.3 )
guiGridListAddColumn( aModdetailsList, "Modification", 0.60 )
aModdetailsCopy = guiCreateButton ( 0.76, 0.71, 0.32, 0.05, "Copy", true, aModdetailsForm )
aModdetailsRefresh = guiCreateButton ( 0.76, 0.78, 0.32, 0.05, "Refresh", true, aModdetailsForm )
aModdetailsClose = guiCreateButton ( 0.76, 0.85, 0.32, 0.05, "Close", true, aModdetailsForm )
addEventHandler ( "aModdetails", resourceRoot, aModdetailsSync )
addEventHandler ( "onClientGUIClick", aModdetailsForm, aClientModdetailsClick )
--Register With Admin Form
aRegister ( "Moddetails", aModdetailsForm, aViewModdetails, aViewModdetailsClose )
end
guiSetText( aModdetailsForm, "Mod details for: '" .. tostring(getPlayerName(modDetailsPlayer)) .."'" )
aHideFloaters()
guiSetVisible ( aModdetailsForm, true )
guiBringToFront ( aModdetailsForm )
triggerServerEvent ( "aModdetails", resourceRoot, "get", modDetailsPlayer )
end
function aViewModdetailsClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceMessage ) ) ) then
if ( aModdetailsForm ) then
removeEventHandler ( "aModdetails", resourceRoot, aModdetailsSync )
removeEventHandler ( "onClientGUIClick", aModdetailsForm, aClientModdetailsClick )
destroyElement ( aModdetailsForm )
aModdetailsForm = nil
end
else
guiSetVisible ( aModdetailsForm, false )
end
currentModDetails = nil
end
function aModdetailsSync ( action, list, player )
if player ~= modDetailsPlayer then
return
end
if ( action == "get" ) then
currentModDetails = list
if not aModdetailsList then
aModdetailsList = guiCreateGridList ( 0.02, 0.09, 0.72, 0.85, true, aModdetailsForm )
guiGridListAddColumn( aModdetailsList, "Filename", 0.3 )
guiGridListAddColumn( aModdetailsList, "Modification", 0.60 )
else
guiGridListClear ( aModdetailsList )
end
for filename, mods in pairs( list ) do
for _, mod in ipairs(mods) do
local row = guiGridListAddRow ( aModdetailsList )
guiGridListSetItemText ( aModdetailsList, row, 1, tostring(filename), false, false )
guiGridListSetItemText ( aModdetailsList, row, 2, tostring(mod.name), false, false )
end
end
end
end
function aClientModdetailsClick ( button )
if ( button == "left" ) then
if ( source == aModdetailsClose ) then
aViewModdetailsClose ( false )
elseif ( source == aModdetailsRefresh ) then
triggerServerEvent ( "aModdetails", resourceRoot, "get", modDetailsPlayer )
elseif ( source == aModdetailsCopy ) then
setClipboard ( toJSON ( currentModDetails ) )
outputChatBox("* Player mod details copied to clipboard.", 255, 100, 70)
end
end
end

View file

@ -0,0 +1,59 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_performance.lua
*
* Original File by lil_Toady
*
**************************************]]
aPerformanceForm = nil
function aPerformance ()
if ( aPerformanceForm == nil ) then
local x, y = guiGetScreenSize()
aPerformanceForm = guiCreateWindow ( x / 2 - 160, y / 2 - 100, 320, 320, "Admin Performance Options", false )
aPerformanceLabel = guiCreateLabel ( 0.03, 0.87, 0.74, 0.18, "It's recomended to unload the widgets you do not often use to save RAM", true, aPerformanceForm )
guiLabelSetHorizontalAlign ( aPerformanceLabel, "left", true )
guiLabelSetColor ( aPerformanceLabel, 255, 0, 0 )
aPerformanceSpectator = guiCreateCheckBox ( 0.05, 0.10, 0.90, 0.08, "Unload spectator when not used", false, true, aPerformanceForm )
aPerformanceEditor = guiCreateCheckBox ( 0.05, 0.18, 0.90, 0.08, "Unload map editor when not used", false, true, aPerformanceForm )
aPerformanceTeam = guiCreateCheckBox ( 0.05, 0.26, 0.90, 0.08, "Unload Team Form when not used", false, true, aPerformanceForm )
aPerformanceSkin = guiCreateCheckBox ( 0.05, 0.34, 0.90, 0.08, "Unload Skin Form when not used", false, true, aPerformanceForm )
aPerformanceStats = guiCreateCheckBox ( 0.05, 0.42, 0.90, 0.08, "Unload Stats Form when not used", false, true, aPerformanceForm )
aPerformanceVehicle = guiCreateCheckBox ( 0.05, 0.50, 0.90, 0.08, "Unload Vehicle Form when not used", false, true, aPerformanceForm )
aPerformanceBan = guiCreateCheckBox ( 0.05, 0.58, 0.90, 0.08, "Unload Ban Form when not used", false, true, aPerformanceForm )
guiCreateStaticImage ( 0.05, 0.68, 0.60, 0.003, "client\\images\\dot.png", true, aPerformanceForm )
aPerformanceInput = guiCreateCheckBox ( 0.05, 0.70, 0.90, 0.08, "Unload Input Box when not used", false, true, aPerformanceForm )
aPerformanceMessage = guiCreateCheckBox ( 0.05, 0.78, 0.90, 0.08, "Unload Message Box when not used", false, true, aPerformanceForm )
aPerformanceOk = guiCreateButton ( 0.79, 0.90, 0.18, 0.08, "Ok", true, aPerformanceForm )
addEventHandler ( "onClientGUIClick", aPerformanceForm, aClientPerformanceClick )
guiSetVisible ( aPerformanceForm, false )
--Register With Admin Form
aRegister ( "Performance", aPerformanceForm, aPerformance, aPerformanceClose )
else
guiSetVisible ( aPerformanceForm, true )
guiBringToFront ( aPerformanceForm )
end
end
function aPerformanceClose ( destroy )
if ( destroy ) then
removeEventHandler ( "onClientGUIClick", aPerformanceForm, aClientPerformanceClick )
destroyElement ( aPerformanceForm )
aPerformanceForm = nil
else
guiSetVisible ( aPerformanceForm, false )
end
end
function aClientPerformanceClick ( button )
if ( button == "left" ) then
if ( source == aPerformanceOk ) then
aPerformanceClose ()
end
end
end

View file

@ -0,0 +1,137 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* client\gui\admin_permissions.lua
*
* Original File by lil_Toady
*
**************************************]]
aPermissions = {
Form = nil,
SelectedPlayer = nil,
}
addEvent('aPermissionsSync', true)
addEvent('aOnPermissionsChange', true)
function aPermissions.Show(player)
if (not aPermissions.Form) then
local x, y = guiGetScreenSize()
aPermissions.Form = guiCreateWindow(x / 2 - 200, y / 2 - 125, 400, 250, '', false)
guiSetAlpha(aPermissions.Form, 1)
aPermissions.LabelYourPerms = guiCreateLabel(0.03, 0.1, 0.35, 0.07, '', true, aPermissions.Form)
aPermissions.PlayerGroups = guiCreateGridList(0.03, 0.18, 0.35, 0.68, true, aPermissions.Form)
guiGridListAddColumn(aPermissions.PlayerGroups, "Group Name", 0.85)
aPermissions.RemoveGroup = guiCreateButton(0.39, 0.18, 0.075, 0.68, '>\n>\n>', true, aPermissions.Form)
guiSetEnabled(aPermissions.RemoveGroup, false)
aPermissions.LabelAllPerms = guiCreateLabel(0.62, 0.1, 0.35, 0.07, "Available groups:", true, aPermissions.Form)
aPermissions.AllGroups = guiCreateGridList(0.62, 0.18, 0.35, 0.68, true, aPermissions.Form)
guiGridListAddColumn(aPermissions.AllGroups, "Group Name", 0.85)
aPermissions.AddGroup = guiCreateButton(0.535, 0.18, 0.075, 0.68, '<\n<\n<', true, aPermissions.Form)
guiSetEnabled(aPermissions.AddGroup, false)
aPermissions.Update = guiCreateButton(0.03, 0.88, 0.435, 0.09, "Refresh", true, aPermissions.Form)
aPermissions.Hide = guiCreateButton(0.535, 0.88, 0.435, 0.09, "Close", true, aPermissions.Form)
addEventHandler('aPermissionsSync', localPlayer, aPermissions.onSync)
addEventHandler('aOnPermissionsChange', localPlayer, aPermissions.Refresh)
addEventHandler("onClientGUIClick", aPermissions.Form, aPermissions.onClick)
--Register With Admin Form
aRegister("PlayerPermissions", aPermissions.Form, aPermissions.Show, aPermissions.Close)
end
guiSetText(aPermissions.Form, ("Manage %s's permissions"):format(getPlayerName(player)))
guiSetText(aPermissions.LabelYourPerms, ("%s's groups:"):format(getPlayerName(player)))
aPermissions.SelectedPlayer = player
aPermissions.Refresh()
guiSetVisible(aPermissions.Form, true)
guiBringToFront(aPermissions.Form)
end
function aPermissions.onSync(targetPlayer, permissions)
if (targetPlayer == aPermissions.SelectedPlayer) then
guiGridListClear(aPermissions.PlayerGroups)
guiGridListClear(aPermissions.AllGroups)
for group, state in pairs(permissions) do
local gridlist = state and aPermissions.PlayerGroups or aPermissions.AllGroups
guiGridListAddRow(gridlist, group)
end
end
end
function aPermissions.Close(destroy)
if (destroy) then
if (aPermissions.Form) then
destroyElement(aPermissions.Form)
aPermissions.Form = nil
removeEventHandler('aPermissionsSync', localPlayer, aPermissions.onSync)
removeEventHandler('aOnPermissionsChange', localPlayer, aPermissions.Refresh)
end
else
guiSetVisible(aPermissions.Form, false)
end
aPermissions.SelectedPlayer = nil
end
function aPermissions.onClick(button)
if (button == 'left') then
if (source == aPermissions.Hide) then
aPermissions.Close()
elseif (source == aPermissions.Update) then
aPermissions.Refresh()
elseif (source == aPermissions.RemoveGroup) then
aPermissions.ConfirmChange(false)
elseif (source == aPermissions.AddGroup) then
aPermissions.ConfirmChange(true)
elseif (source == aPermissions.AllGroups) then
guiSetEnabled(aPermissions.AddGroup, guiGridListGetSelectedItem(aPermissions.AllGroups) > -1)
elseif (source == aPermissions.PlayerGroups) then
guiSetEnabled(aPermissions.RemoveGroup, guiGridListGetSelectedItem(aPermissions.PlayerGroups) > -1)
end
end
end
function aPermissions.ConfirmChange(add)
local player = aPermissions.SelectedPlayer
if (not isElement(player)) then
aPermissions.Close(false)
aMessageBox ( "error", "Player not found!")
return
end
local gridlist = add and aPermissions.AllGroups or aPermissions.PlayerGroups
local selected = guiGridListGetSelectedItem(gridlist)
if (selected <= -1) then
return
end
local groupName = guiGridListGetItemText(gridlist, selected, 1)
local str = add and 'Are you sure you want to add "%s" to the "%s" group?' or 'Are you sure you want to remove "%s" from the "%s" group?'
str = str:format(getPlayerName(player), groupName)
return aMessageBox ( "question", str, "updatePlayerACLGroup", player, groupName, add)
end
function aPermissions.PerformAction(player, groupName, newState)
local playerAccount = player and aPlayers[player] and aPlayers[player]['accountname']
if playerAccount and (playerAccount ~= 'guest') then
triggerServerEvent('aAdmin', localPlayer, newState and 'acladd' or 'aclremove', 'object', groupName, 'user.'..playerAccount, true)
end
end
function aPermissions.Refresh()
local player = aPermissions.SelectedPlayer
if isElement(player) and aPermissions.PlayerGroups and aPermissions.AllGroups then
guiGridListClear(aPermissions.PlayerGroups)
guiGridListClear(aPermissions.AllGroups)
triggerServerEvent('aAdmin', localPlayer, "sync", "playeraclgroups", player)
end
end

View file

@ -0,0 +1,173 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_report.lua
*
* Original File by lil_Toady
*
**************************************]]
aReportForm = nil
local reportCategories
local aSelectPlayer = nil
function aReport ( )
if ( aReportForm == nil ) then
reportCategories = {}
for i,cat in ipairs( split( g_Prefs.reportCategories, string.byte(',') ) ) do
table.insert ( reportCategories, { subject = cat } )
end
for i,cat in ipairs( split( g_Prefs.playerReportCategories, string.byte(',') ) ) do
table.insert ( reportCategories, { subject = cat, playerReport = true } )
end
local x, y = guiGetScreenSize()
aReportForm = guiCreateWindow ( x / 2 - 150, y / 2 - 170, 300, 340, "Contact Admin", false )
guiCreateLabel ( 0.05, 0.11, 0.20, 0.07, "Category:", true, aReportForm )
guiCreateLabel ( 0.05, 0.19, 0.20, 0.07, "Subject:", true, aReportForm )
guiCreateLabel ( 0.05, 0.34, 0.20, 0.07, "Message:", true, aReportForm )
aReportLblPlayer = guiCreateLabel ( 0.05, 0.27, 0.20, 0.07, "Player:", true, aReportForm )
aReportBtnPlayer = guiCreateButton ( 0.75, 0.27, 0.20, 0.07, "Select", true, aReportForm )
aReportCategory = guiCreateEdit ( 0.30, 0.10, 0.65, 0.07, "Question", true, aReportForm )
guiEditSetReadOnly ( aReportCategory, true )
aReportDropDown = guiCreateStaticImage ( 0.86, 0.10, 0.09, 0.07, "client\\images\\dropdown.png", true, aReportForm )
guiBringToFront ( aReportDropDown )
aReportCategories = guiCreateGridList ( 0.30, 0.10, 0.65, 0.28, true, aReportForm )
guiGridListAddColumn( aReportCategories, "", 0.85 )
guiSetVisible ( aReportCategories, false )
for a=1, #reportCategories do
guiGridListSetItemText ( aReportCategories, guiGridListAddRow ( aReportCategories ), 1, reportCategories[a].subject, false, false )
end
guiSetText( aReportCategory, reportCategories[1].subject )
aReportSubject = guiCreateEdit ( 0.30, 0.18, 0.65, 0.07, "", true, aReportForm )
aReportPlayer = guiCreateLabel ( 0.30, 0.27, 0.50, 0.07, "", true, aReportForm )
aReportMessage = guiCreateMemo ( 0.05, 0.41, 0.90, 0.42, "", true, aReportForm )
aReportAccept = guiCreateButton ( 0.40, 0.88, 0.25, 0.09, "Send", true, aReportForm )
aReportCancel = guiCreateButton ( 0.70, 0.88, 0.25, 0.09, "Cancel", true, aReportForm )
if ( not reportCategories[1].playerReport ) then
guiSetVisible ( aReportPlayer, false )
guiSetVisible ( aReportLblPlayer, false )
guiSetVisible ( aReportBtnPlayer, false )
end
addEventHandler ( "onClientGUIClick", aReportForm, aClientReportClick )
addEventHandler ( "onClientGUIDoubleClick", aReportForm, aClientReportDoubleClick )
end
guiBringToFront ( aReportForm )
showCursor ( true )
end
addEventHandler( "aClientReports", root, aReport )
function aReportClose ( )
if ( aReportForm ) then
removeEventHandler ( "onClientGUIClick", aReportForm, aClientReportClick )
removeEventHandler ( "onClientGUIDoubleClick", aReportForm, aClientReportDoubleClick )
destroyElement ( aReportForm )
aReportForm = nil
showCursor ( false )
end
end
function aReportSelectPlayer ( )
if ( aSelectPlayer == nil ) then
local x, y = guiGetScreenSize ( )
aSelectPlayer = guiCreateWindow ( x / 2 - 155, y / 2 - 250, 310, 500, "Select player", false)
local playerList = guiCreateGridList(0.03, 0.06, 0.97, 0.78, true, aSelectPlayer)
local searchBox = guiCreateEdit(0.115, 0.86, 0.77, 0.06, "", true, aSelectPlayer)
addEventHandler ( "onClientGUIChanged", searchBox, function ( )
guiGridListClear ( playerList )
local text = guiGetText ( source )
for _, player in pairs ( getElementsByType ( "player" ) ) do
local playerName = getPlayerName ( player )
if ( string.find ( string.upper ( playerName ), string.upper ( text ), 1, true ) ) then
guiGridListSetItemText ( playerList, guiGridListAddRow ( playerList ), 1, playerName, false, false )
end
end
end )
guiGridListAddColumn ( playerList, "Player name", 0.85 )
for _, player in pairs (getElementsByType("player")) do
guiGridListSetItemText(playerList, guiGridListAddRow(playerList), 1, getPlayerName(player), false, false)
end
local btnSelectPlayer = guiCreateButton(0.57, 0.93, 0.33, 0.05, "Select", true, aSelectPlayer)
addEventHandler ( "onClientGUIClick", btnSelectPlayer, function ( )
guiSetText ( aReportPlayer, guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) )
destroyElement ( aSelectPlayer )
aSelectPlayer = nil
end, false )
local btnClose = guiCreateButton(0.10, 0.93, 0.33, 0.05, "Close", true, aSelectPlayer)
addEventHandler ( "onClientGUIClick", btnClose, function ( )
destroyElement ( aSelectPlayer )
aSelectPlayer = nil
end, false )
end
end
function aClientReportDoubleClick ( button )
if ( button == "left" ) then
if ( source == aReportCategories ) then
if ( guiGridListGetSelectedItem ( aReportCategories ) ~= -1 ) then
local cat = guiGridListGetItemText ( aReportCategories, guiGridListGetSelectedItem ( aReportCategories ), 1 )
guiSetText ( aReportCategory, cat )
for i=1, #reportCategories do
if ( reportCategories[i].subject == cat ) then
if ( reportCategories[i].playerReport ) then
guiSetVisible ( aReportPlayer, true )
guiSetVisible ( aReportLblPlayer, true )
guiSetVisible ( aReportBtnPlayer, true )
else
guiSetVisible ( aReportPlayer, false )
guiSetVisible ( aReportLblPlayer, false )
guiSetVisible ( aReportBtnPlayer, false )
end
end
end
guiSetVisible ( aReportCategories, false )
end
end
end
end
function aClientReportClick ( button )
if ( source == aReportCategory ) then
guiBringToFront ( aReportDropDown )
end
if ( source ~= aReportCategories ) then
guiSetVisible ( aReportCategories, false )
end
if ( button == "left" ) then
if ( source == aReportAccept ) then
if ( ( string.len ( guiGetText ( aReportSubject ) ) < 1 ) or ( string.len ( guiGetText ( aReportMessage ) ) < 5 ) ) then
aMessageBox ( "error", "Subject/Message missing." )
else
local tableOut = {}
if ( guiGetVisible ( aReportPlayer ) ) then
local text = guiGetText ( aReportPlayer )
if ( text ~= "" ) then
tableOut.suspect = text
end
end
aMessageBox ( "info", "Your message has been submitted and will be processed as soon as possible." )
setTimer ( aMessageBoxClose, 3000, 1, true )
tableOut.category = guiGetText ( aReportCategory )
tableOut.subject = guiGetText ( aReportSubject )
tableOut.message = guiGetText ( aReportMessage )
triggerServerEvent ( "aMessage", localPlayer, "new", tableOut )
aReportClose ()
end
--elseif ( source == aReportSubject ) then
--elseif ( source == aReportMessage ) then
elseif ( source == aReportCancel ) then
aReportClose ()
elseif ( source == aReportDropDown ) then
guiBringToFront ( aReportCategories )
guiSetVisible ( aReportCategories, true )
elseif ( source == aReportBtnPlayer ) then
aReportSelectPlayer ( )
end
end
end

View file

@ -0,0 +1,156 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_screenshot.lua
*
* Original File by MCvarial
*
**************************************]]
aScreenShotWindows = {}
aScreenShotForm = nil
function aPlayerScreenShot (player)
if aScreenShotForm == nil then
local x,y = guiGetScreenSize()
aScreenShotForm = guiCreateWindow ( x / 2 - 300, y / 2 - 125, 600, 250, "Screenshot Management", false )
aScreenShotList = guiCreateGridList ( 0.03, 0.08, 0.70, 0.90, true, aScreenShotForm )
aScreenShotNew = guiCreateButton ( 0.75, 0.08, 0.42, 0.09, "Take New", true, aScreenShotForm, "takescreenshot" )
aScreenShotDelete = guiCreateButton ( 0.75, 0.18, 0.42, 0.09, "Delete", true, aScreenShotForm, "deletescreenshot" )
aScreenShotView = guiCreateButton ( 0.75, 0.28, 0.42, 0.09, "View", true, aScreenShotForm, "viewscreenshot" )
aScreenShotRefresh = guiCreateButton ( 0.75, 0.38, 0.42, 0.09, "Refresh", true, aScreenShotForm, "listscreenshots" )
aScreenShotClose = guiCreateButton ( 0.75, 0.88, 0.42, 0.09, "Close", true, aScreenShotForm )
guiGridListAddColumn(aScreenShotList,"Player",0.31 )
guiGridListAddColumn(aScreenShotList,"Admin",0.31 )
guiGridListAddColumn(aScreenShotList,"Date",0.27 )
addEventHandler("onClientGUIClick",aScreenShotForm,aScreenShotsClick)
addEventHandler("onClientGUIDoubleClick",aScreenShotForm,aScreenShotsDoubleClick)
aRegister("PlayerScreenShot",aScreenShotForm,aPlayerScreenShot,aPlayerScreenShotClose)
end
guiSetVisible(aScreenShotForm,true)
guiBringToFront(aScreenShotForm)
aScreenShotsRefresh()
end
function aScreenShotsRefresh ()
if aScreenShotList then
guiGridListClear(aScreenShotList)
if hasPermissionTo("command.listscreenshots") then
triggerServerEvent("aScreenShot",localPlayer,"list")
end
end
end
function aPlayerScreenShotClose ()
if ( aScreenShotForm ) then
removeEventHandler ( "onClientGUIClick", aScreenShotForm, aScreenShotsClick )
removeEventHandler ( "onClientGUIDoubleClick", aScreenShotForm, aScreenShotsDoubleClick )
destroyElement ( aScreenShotForm )
aScreenShotForm,aScreenShotList,aScreenShotNew,aScreenShotDelete,aScreenShotView,aScreenShotRefresh,aScreenShotClose,aScreenShotForm = nil,nil,nil,nil,nil,nil,nil,nil
end
end
function aScreenShotsDoubleClick (button)
if button == "left" then
if source == aScreenShotList then
local row = guiGridListGetSelectedItem(aScreenShotList)
if row ~= -1 then
triggerServerEvent("aScreenShot",localPlayer,"view",guiGridListGetItemData(aScreenShotList,row,1),guiGridListGetItemText(aScreenShotList,row,1))
end
end
end
end
function aScreenShotsClick (button)
if button == "left" then
if source == aScreenShotClose then
aPlayerScreenShotClose()
elseif source == aScreenShotNew then
if guiGridListGetSelectedItem(aTab1.PlayerList ) == -1 then
aMessageBox("error","No player selected!")
else
local name = guiGridListGetItemPlayerName(aTab1.PlayerList,guiGridListGetSelectedItem(aTab1.PlayerList),1)
triggerServerEvent("aScreenShot",localPlayer,"new",getPlayerFromNick(name))
end
elseif source == aScreenShotDelete then
local row = guiGridListGetSelectedItem ( aScreenShotList )
if row ~= -1 then
triggerServerEvent("aScreenShot",localPlayer,"delete",guiGridListGetItemData(aScreenShotList,row,1))
guiGridListRemoveRow(aScreenShotList,row)
end
elseif source == aScreenShotRefresh then
aScreenShotsRefresh()
elseif source == aScreenShotView then
local row = guiGridListGetSelectedItem(aScreenShotList)
if row ~= -1 then
triggerServerEvent("aScreenShot",localPlayer,"view",guiGridListGetItemData(aScreenShotList,row,1),guiGridListGetItemText(aScreenShotList,row,1))
end
else
for player,gui in pairs (aScreenShotWindows) do
if gui.button == source or source == gui.screenshot then
destroyElement(gui.window)
aScreenShotWindows[player] = nil
end
end
end
end
end
addEvent("aClientScreenShot",true)
addEventHandler("aClientScreenShot",resourceRoot,
function (action,player,data,arg1,arg2,arg3)
if action == "new" then
local title
if type(player) == "string" then
title = player
elseif isElement(player) then
title = getPlayerName(player)
else
return
end
local x, y = guiGetScreenSize()
aScreenShotWindows[player] = {}
aScreenShotWindows[player].window = guiCreateWindow((x/2)-400,(y/2)-300,800,600,title,false)
aScreenShotWindows[player].label = guiCreateLabel(0,0,1,1,"Loading...",true,aScreenShotWindows[player].window)
aScreenShotWindows[player].button = guiCreateButton(0.93,0.95,0.6,0.4,"Close",true,aScreenShotWindows[player].window)
addEventHandler ( "onClientGUIClick", aScreenShotWindows[player].button, aScreenShotsClick )
guiLabelSetHorizontalAlign(aScreenShotWindows[player].label,"center")
guiLabelSetVerticalAlign(aScreenShotWindows[player].label,"center")
elseif action == "list" then
if not isElement(aScreenShotList) then return end
guiGridListClear ( aScreenShotList )
for i,screenshot in ipairs (data) do
local row = guiGridListAddRow(aScreenShotList)
guiGridListSetItemText(aScreenShotList,row,1,removeColorCoding(screenshot.player),false,false)
guiGridListSetItemText(aScreenShotList,row,2,removeColorCoding(screenshot.admin),false,false)
guiGridListSetItemText(aScreenShotList,row,3,screenshot.realtime,false,false)
guiGridListSetItemData(aScreenShotList,row,1,screenshot.id)
end
else
if not aScreenShotWindows[player] or not isElement(aScreenShotWindows[player].window) then return end
if action == "view" then
local time = tostring(getRealTime().timestamp)
local file = fileCreate("screenshots/"..time..".jpg")
fileWrite(file,data)
fileClose(file)
aScreenShotWindows[player].screenshot = guiCreateStaticImage(0,0,1,1,"screenshots/"..time..".jpg",true,aScreenShotWindows[player].window)
addEventHandler ( "onClientGUIClick", aScreenShotWindows[player].screenshot, aScreenShotsClick )
guiBringToFront(aScreenShotWindows[player].button)
if isElement(player) and isElement(aScreenShotList) then
local row = guiGridListAddRow(aScreenShotList)
guiGridListSetItemText(aScreenShotList,row,1,getPlayerName(player),false,false)
guiGridListSetItemText(aScreenShotList,row,2,arg1,false,false)
guiGridListSetItemText(aScreenShotList,row,3,arg2,false,false)
guiGridListSetItemData(aScreenShotList,row,1,arg3)
end
elseif action == "minimized" then
guiSetText(aScreenShotWindows[player].label,"Player is minimized, try again later")
elseif action == "disabled" then
guiSetText(aScreenShotWindows[player].label,"Player does not allow taking screenshots")
elseif action == "quit" then
guiSetText(aScreenShotWindows[player].label,"Player has quit")
end
end
end
)

View file

@ -0,0 +1,167 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_settings.lua
*
* Original File by ccw
*
**************************************]]
aSettingsForm = nil
aSettingsData = {}
function aManageSettings ( resName )
aSettingsData["settings"] = {}
aSettingsData["resName"] = resName
if ( aSettingsForm == nil ) then
local x, y = guiGetScreenSize()
aSettingsForm = guiCreateWindow ( x / 2 - 230, y / 2 - 250, 460, 500, "", false )
aSettingsTabPanel = guiCreateTabPanel ( 0.00, 0.05, 1, 0.95, true, aSettingsForm )
aSettingsTab = guiCreateTab ( "Players", aSettingsTabPanel, "players" )
aSettingsList = guiCreateGridList ( 0.03, 0.03, 0.94, 0.72, true, aSettingsTab )
guiGridListAddColumn( aSettingsList, "name", 0.50 )
guiGridListAddColumn( aSettingsList, "current", 0.25 )
guiGridListAddColumn( aSettingsList, "default", 0.25 )
aSettingsExit = guiCreateButton ( 0.80, 0.93, 0.17, 0.04, "Close", true, aSettingsTab )
aSettingDesc = guiCreateMemo ( 0.03, 0.80, 0.75, 0.17, "", true, aSettingsTab )
addEvent ( "aAdminSettings", true )
addEventHandler ( "aAdminSettings", localPlayer, aAdminSettings )
addEventHandler ( "onClientGUIClick", aSettingsForm, aClientSettingsClick )
addEventHandler ( "onClientGUIDoubleClick", aSettingsForm, aClientSettingsDoubleClick )
--Register With Admin Form
aRegister ( "SettingsManage", aSettingsForm, aManageSettings, aSettingsClose )
end
guiSetText( aSettingsTab, resName .. " Settings" )
guiSetText( aSettingDesc, "" )
guiMemoSetReadOnly ( aSettingDesc, true )
guiGridListClear( aSettingsList )
triggerServerEvent ( "aAdmin", localPlayer, "settings", "getall", resName )
guiSetVisible ( aSettingsForm, true )
guiBringToFront ( aSettingsForm )
end
function aSettingsClose ( destroy )
if ( destroy ) then
if ( aSettingsForm ) then
removeEventHandler ( "onClientGUIClick", aSettingsForm, aClientSettingsClick )
removeEventHandler ( "onClientGUIDoubleClick", aSettingsForm, aClientSettingsDoubleClick )
destroyElement ( aSettingsForm )
aSettingsForm = nil
end
else
guiSetVisible ( aSettingsForm, false )
end
end
function aAdminSettings ( type, resName, settingstable )
-- Update gridlist
if aSettingsData["resName"] ~= resName then
outputDebugString( "aAdminSettings: Error for aSettingsData['resName'] ~= resName with " .. resName )
return
end
if type == "change" then
triggerServerEvent ( "aAdmin", localPlayer, "settings", "getall", resName )
elseif type == "getall" then
aSettingsData["settings"] = settingstable
local rowindex = { [1] = 0 }
-- get groups
local groups = {}
local groupnameList = {}
for name,value in pairs(aSettingsData["settings"]) do
local groupname = aSettingsData["settings"][name].group or ' '
if not groups[groupname] then
groups[groupname] = {}
table.insert(groupnameList,groupname)
end
table.insert(groups[groupname],name)
end
-- sort groupnames
table.sort(groupnameList, function(a,b) return(a < b) end)
-- for each group
for _,groupname in ipairs(groupnameList) do
local namesList = groups[groupname]
-- sort names
table.sort(namesList, function(a,b) return(a < b) end)
-- Add to gridlist using sorted names
local row = guiGridListAddRowMaybe( aSettingsList, rowindex )
guiGridListSetItemText ( aSettingsList, row, 1, string.sub(groupname,1,1)=='_' and string.sub(groupname,2) or groupname, true, false )
for i,name in ipairs(namesList) do
local value = aSettingsData["settings"][name]
row = guiGridListAddRowMaybe( aSettingsList, rowindex )
guiGridListSetItemText ( aSettingsList, row, 1, tostring(value.friendlyname or name), false, false )
guiGridListSetItemText ( aSettingsList, row, 2, tostring(value.current), false, false )
guiGridListSetItemText ( aSettingsList, row, 3, tostring(value.default), false, false )
guiGridListSetItemData ( aSettingsList, row, 1, tostring(name) )
end
end
guiGridListRemoveLastRows( aSettingsList, guiGridListGetRowCount( aSettingsList ) - rowindex[1] )
end
end
function guiGridListAddRowMaybe ( aSettingsList, rowindex )
local row
if rowindex[1] < guiGridListGetRowCount( aSettingsList ) then
row = rowindex[1]
else
row = guiGridListAddRow( aSettingsList )
end
rowindex[1] = rowindex[1] + 1
return row
end
function guiGridListRemoveLastRows ( aSettingsList, amount )
for i=1,amount do
guiGridListRemoveRow( aSettingsList, guiGridListGetRowCount( aSettingsList ) - 1 )
end
end
function aClientSettingsDoubleClick ( button )
if ( button == "left" ) then
if ( source == aSettingsList ) then
local row = guiGridListGetSelectedItem ( aSettingsList )
if ( row ~= -1 ) then
local name = tostring( guiGridListGetItemData ( aSettingsList, row, 1 ) )
if not aSettingsData["settings"][name] then
outputDebugString( "aClientSettingsDoubleClick: Error with " .. name )
return
end
local friendlyname = aSettingsData["settings"][name].friendlyname
friendlyname = friendlyname or name
local current = aSettingsData["settings"][name].current
current = current == nil and "" or current
aInputBox ( "Change setting",
"Enter new value for '".. friendlyname .."'",
tostring(current),
"settingChange", aSettingsData["resName"], name )
end
end
end
end
function aClientSettingsClick ( button )
if ( button == "left" ) then
if ( source == aSettingsExit ) then
aSettingsClose ( false )
end
if ( source == aSettingsList ) then
local row = guiGridListGetSelectedItem ( aSettingsList )
if ( row ~= -1 ) then
local name = tostring( guiGridListGetItemData ( aSettingsList, row, 1 ) )
if not aSettingsData["settings"][name] then
outputDebugString( "aClientSettingsClick: Error with " .. name )
return
end
local desc = aSettingsData["settings"][name].desc or ''
local accept = aSettingsData["settings"][name].accept
local examples = aSettingsData["settings"][name].examples
if examples then
desc = desc .. '\n[Examples: ' .. examples .. ']'
elseif accept and accept ~= '*' then
desc = desc .. '\n[Values: ' .. accept .. ']'
end
guiSetText( aSettingDesc, desc )
end
end
end
end

View file

@ -0,0 +1,164 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_skin.lua
*
* Original File by lil_Toady
*
* Thanks to:
* Talidan and Slothman for Skins list
*
**************************************]]
aSkins = {}
aSkinForm = nil
aSkinSelect = nil
function aPlayerSkin ( player )
if ( aSkinForm == nil ) then
local x, y = guiGetScreenSize()
aSkinForm = guiCreateWindow ( x / 2 - 140, y / 2 - 125, 280, 250, "Player Skin Select", false )
aSkinLabel = guiCreateLabel ( 0.03, 0.09, 0.94, 0.07, "Select a skin from the list or enter the id", true, aSkinForm )
guiLabelSetHorizontalAlign ( aSkinLabel, "center" )
guiLabelSetColor ( aSkinLabel, 255, 0, 0 )
aSkinGroups = guiCreateCheckBox ( 0.03, 0.90, 0.70, 0.09, "Sort by groups", false, true, aSkinForm )
if ( aGetSetting ( "skinsGroup" ) ) then guiCheckBoxSetSelected ( aSkinGroups, true ) end
aSkinList = guiCreateGridList ( 0.03, 0.18, 0.70, 0.71, true, aSkinForm )
guiGridListAddColumn( aSkinList, "ID", 0.20 )
guiGridListAddColumn( aSkinList, "", 0.75 )
aSkins = aLoadSkins ( )
aListSkins ( iif ( guiCheckBoxGetSelected ( aSkinGroups ), 2, 1 ) )
aSkinID = guiCreateEdit ( 0.75, 0.18, 0.27, 0.09, "0", true, aSkinForm )
guiEditSetMaxLength ( aSkinID, 3 )
aSkinAccept = guiCreateButton ( 0.75, 0.28, 0.27, 0.09, "Select", true, aSkinForm, "setskin" )
aSkinCancel = guiCreateButton ( 0.75, 0.88, 0.27, 0.09, "Cancel", true, aSkinForm )
addEventHandler ( "onClientGUIClick", aSkinForm, aClientSkinClick )
addEventHandler ( "onClientGUIDoubleClick", aSkinForm, aClientSkinDoubleClick )
--Register With Admin Form
aRegister ( "PlayerSkin", aSkinForm, aPlayerSkin, aPlayerSkinClose )
end
aSkinSelect = player
guiSetVisible ( aSkinForm, true )
guiBringToFront ( aSkinForm )
end
function aPlayerSkinClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceSkin ) ) ) then
if ( aSkinForm ) then
removeEventHandler ( "onClientGUIClick", aSkinForm, aClientSkinClick )
removeEventHandler ( "onClientGUIDoubleClick", aSkinForm, aClientSkinDoubleClick )
aSkins = {}
destroyElement ( aSkinForm )
aStatsForm = nil
end
else
guiSetVisible ( aSkinForm, false )
end
end
function aClientSkinDoubleClick ( button )
if ( button == "left" ) then
if ( source == aSkinList ) then
if ( guiGridListGetSelectedItem ( aSkinList ) ~= -1 ) then
local id = tonumber ( guiGridListGetItemText ( aSkinList, guiGridListGetSelectedItem ( aSkinList ), 1 ) )
triggerServerEvent ( "aPlayer", localPlayer, aSkinSelect, "setskin", id )
aPlayerSkinClose ( false )
end
end
end
end
function aClientSkinClick ( button )
if ( button == "left" ) then
if ( source == aSkinAccept ) then
if ( tonumber ( guiGetText ( aSkinID ) ) ) then
triggerServerEvent ( "aPlayer", localPlayer, aSkinSelect, "setskin", tonumber ( guiGetText ( aSkinID ) ) )
aPlayerSkinClose ( false )
else
if ( guiGridListGetSelectedItem ( aSkinList ) ~= -1 ) then
local id = tonumber ( guiGridListGetItemText ( aSkinList, guiGridListGetSelectedItem ( aSkinList ), 1 ) )
guiSetVisible ( aSkinForm, false )
triggerServerEvent ( "aPlayer", localPlayer, aSkinSelect, "setskin", id )
else
aMessageBox ( "warning", "No player selected/Invalid ID!" )
end
end
elseif ( source == aSkinList ) then
if ( guiGridListGetSelectedItem ( aSkinList ) ~= -1 ) then
local id = guiGridListGetItemText ( aSkinList, guiGridListGetSelectedItem ( aSkinList ), 1 )
guiSetText ( aSkinID, id )
end
elseif ( source == aSkinCancel ) then
aPlayerSkinClose ( false )
elseif ( source == aSkinGroups ) then
if ( guiCheckBoxGetSelected ( aSkinGroups ) ) then aListSkins ( 2 )
else aListSkins ( 1 ) end
end
end
end
function aLoadSkins ()
local table = {}
local node = xmlLoadFile ( "conf\\skins.xml" )
if ( node ) then
local groups = 0
while ( xmlFindChild ( node, "group", groups ) ~= false ) do
local group = xmlFindChild ( node, "group", groups )
local groupn = xmlNodeGetAttribute ( group, "name" )
table[groupn] = {}
local skins = 0
while ( xmlFindChild ( group, "skin", skins ) ~= false ) do
local skin = xmlFindChild ( group, "skin", skins )
local id = #table[groupn] + 1
table[groupn][id] = {}
table[groupn][id]["model"] = xmlNodeGetAttribute ( skin, "model" )
table[groupn][id]["name"] = xmlNodeGetAttribute ( skin, "name" )
skins = skins + 1
end
groups = groups + 1
end
xmlUnloadFile ( node )
end
return table
end
function aListSkins ( mode )
aSetSetting ( "skinsGroup", iif ( mode == 1, false, true ) )
guiGridListClear ( aSkinList )
if ( mode == 1 ) then --Normal
local skins = {}
for name, group in pairs ( aSkins ) do
if (name ~= "Special" or name == "Special" and getVersion().number >= 272) then
for i, skin in pairs ( group ) do
local id = tonumber ( skin["model"] )
skins[id] = skin["name"]
end
end
end
local i = 0
while ( i <= 312 ) do
if ( skins[i] ~= nil ) then
local row = guiGridListAddRow ( aSkinList )
guiGridListSetItemText ( aSkinList, row, 1, tostring ( i ), false, true )
guiGridListSetItemText ( aSkinList, row, 2, skins[i], false, false )
end
i = i + 1
end
guiGridListSetSortingEnabled ( aSkinList, true )
else --Groups
for name, group in pairs ( aSkins ) do
if (name ~= "Special" or name == "Special" and getVersion().number >= 272) then
local row = guiGridListAddRow ( aSkinList )
guiGridListSetItemText ( aSkinList, row, 2, name, true, false )
for id, skin in ipairs ( aSkins[name] ) do
row = guiGridListAddRow ( aSkinList )
guiGridListSetItemText ( aSkinList, row, 1, skin["model"], false, true )
guiGridListSetItemText ( aSkinList, row, 2, skin["name"], false, false )
end
end
end
guiGridListSetSortingEnabled ( aSkinList, false )
end
end

View file

@ -0,0 +1,332 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_spectator.lua
*
* Original File by lil_Toady
*
**************************************]]
aSpectator = { Offset = 5, AngleX = 0, AngleZ = 30, Spectating = nil }
function aSpectate ( player )
if ( player == localPlayer ) then
aMessageBox ( "error", "Can not spectate yourself" )
return
end
if not aSpectator.Interior and not aSpectator.Dimension then
aSpectator.Interior = getElementInterior( localPlayer )
aSpectator.Dimension = getElementDimension( localPlayer )
end
aSpectator.Spectating = player
setElementFrozen ( localPlayer, true )
setElementInterior( localPlayer, getElementInterior( player ) )
setElementDimension( localPlayer, getElementDimension( player ) )
if ( ( not aSpectator.Actions ) or ( not guiGetVisible ( aSpectator.Actions ) ) ) then
aSpectator.Initialize ()
end
end
function aSpectator.Initialize ()
if ( aSpectator.Actions == nil ) then
local x, y = guiGetScreenSize()
aSpectator.Actions = guiCreateWindow ( x - 190, y / 2 - 200, 160, 400, "Actions", false )
aSpectator.Ban = guiCreateButton ( 0.10, 0.09, 0.80, 0.05, "Ban", true, aSpectator.Actions )
aSpectator.Kick = guiCreateButton ( 0.10, 0.15, 0.80, 0.05, "Kick", true, aSpectator.Actions )
aSpectator.Freeze = guiCreateButton ( 0.10, 0.21, 0.80, 0.05, "Freeze", true, aSpectator.Actions )
aSpectator.SetSkin = guiCreateButton ( 0.10, 0.27, 0.80, 0.05, "Set Skin", true, aSpectator.Actions )
aSpectator.SetHealth = guiCreateButton ( 0.10, 0.33, 0.80, 0.05, "Set Health", true, aSpectator.Actions )
aSpectator.SetArmour = guiCreateButton ( 0.10, 0.39, 0.80, 0.05, "Set Armour", true, aSpectator.Actions )
aSpectator.SetStats = guiCreateButton ( 0.10, 0.45, 0.80, 0.05, "Set Stats", true, aSpectator.Actions )
aSpectator.Slap = guiCreateButton ( 0.10, 0.51, 0.80, 0.05, "Slap! "..aCurrentSlap.."hp", true, aSpectator.Actions )
aSpectator.Slaps = guiCreateGridList ( 0.10, 0.51, 0.80, 0.48, true, aSpectator.Actions )
guiGridListAddColumn( aSpectator.Slaps, "", 0.85 )
guiSetVisible ( aSpectator.Slaps, false )
local i = 0
while i <= 10 do
guiGridListSetItemText ( aSpectator.Slaps, guiGridListAddRow ( aSpectator.Slaps ), 1, tostring ( i * 10 ), false, false )
i = i + 1
end
aSpectator.CollideWithWalls = guiCreateCheckBox ( 0.08, 0.8, 0.84, 0.04, "Collide with walls", true, true, aSpectator.Actions )
aSpectator.Skip = guiCreateCheckBox ( 0.08, 0.85, 0.84, 0.04, "Skip dead players", true, true, aSpectator.Actions )
guiCreateLabel ( 0.08, 0.89, 0.84, 0.04, "____________________", true, aSpectator.Actions )
aSpectator.Back = guiCreateButton ( 0.10, 0.93, 0.80, 0.05, "Back", true, aSpectator.Actions )
aSpectator.Players = guiCreateWindow ( 30, y / 2 - 200, 160, 400, "Players", false )
guiWindowSetSizable ( aSpectator.Players, false )
aSpectator.PlayerList = guiCreateGridList ( 0.03, 0.07, 0.94, 0.92, true, aSpectator.Players )
guiGridListAddColumn( aSpectator.PlayerList, "Player Name", 0.85 )
for id, player in ipairs ( getElementsByType ( "player" ) ) do
local row = guiGridListAddRow ( aSpectator.PlayerList )
guiGridListSetItemPlayerName ( aSpectator.PlayerList, row, 1, getPlayerName ( player ), false, false )
if ( player == aSpectator.Spectating ) then guiGridListSetSelectedItem ( aSpectator.PlayerList, row, 1 ) end
end
aSpectator.Prev = guiCreateButton ( x / 2 - 100, y - 50, 70, 30, "< Previous", false )
aSpectator.Next = guiCreateButton ( x / 2 + 30, y - 50, 70, 30, "Next >", false )
addEventHandler ( "onClientGUIClick", root, aSpectator.ClientClick )
addEventHandler ( "onClientGUIDoubleClick", root, aSpectator.ClientDoubleClick )
aRegister ( "Spectator", aSpectator.Actions, aSpectator.ShowGUI, aSpectator.Close )
end
bindKey ( "arrow_l", "down", aSpectator.SwitchPlayer, -1 )
bindKey ( "arrow_r", "down", aSpectator.SwitchPlayer, 1 )
bindKey ( "mouse_wheel_up", "down", aSpectator.MoveOffset, -1 )
bindKey ( "mouse_wheel_down", "down", aSpectator.MoveOffset, 1 )
bindKey ( "mouse2", "both", aSpectator.Cursor )
toggleControl ( "fire", false )
toggleControl ( "aim_weapon", false )
addEventHandler ( "onClientPlayerWasted", root, aSpectator.PlayerCheck )
addEventHandler ( "onClientPlayerQuit", root, aSpectator.PlayerCheck )
addEventHandler ( "onClientCursorMove", root, aSpectator.CursorMove )
addEventHandler ( "onClientPreRender", root, aSpectator.Render )
guiSetVisible ( aSpectator.Actions, true )
guiSetVisible ( aSpectator.Players, true )
guiSetVisible ( aSpectator.Next, true )
guiSetVisible ( aSpectator.Prev, true )
aAdminMenuClose ( false )
end
function aSpectator.Cursor ( key, state )
if state == "down" then
showCursor(true)
else
showCursor(false)
end
end
function aSpectator.Close ( destroy )
if ( aSpectator.Spectating ) then
unbindKey ( "arrow_l", "down", aSpectator.SwitchPlayer, -1 )
unbindKey ( "arrow_r", "down", aSpectator.SwitchPlayer, 1 )
unbindKey ( "mouse_wheel_up", "down", aSpectator.MoveOffset, -1 )
unbindKey ( "mouse_wheel_down", "down", aSpectator.MoveOffset, 1 )
unbindKey ( "mouse2", "both", aSpectator.Cursor )
toggleControl ( "fire", true )
toggleControl ( "aim_weapon", true )
removeEventHandler ( "onClientPlayerWasted", root, aSpectator.PlayerCheck )
removeEventHandler ( "onClientPlayerQuit", root, aSpectator.PlayerCheck )
removeEventHandler ( "onClientCursorMove", root, aSpectator.CursorMove )
removeEventHandler ( "onClientPreRender", root, aSpectator.Render )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceSpectator ) ) ) then
if ( aSpectator.Actions ) then
removeEventHandler ( "onClientGUIClick", root, aSpectator.ClientClick )
removeEventHandler ( "onClientGUIDoubleClick", root, aSpectator.ClientDoubleClick )
destroyElement ( aSpectator.Actions )
destroyElement ( aSpectator.Players )
destroyElement ( aSpectator.Next )
destroyElement ( aSpectator.Prev )
aSpectator.Actions = nil
end
else
guiSetVisible ( aSpectator.Actions, false )
guiSetVisible ( aSpectator.Players, false )
guiSetVisible ( aSpectator.Next, false )
guiSetVisible ( aSpectator.Prev, false )
end
setCameraTarget ( localPlayer )
setElementInterior( localPlayer, aSpectator.Interior )
setElementDimension( localPlayer, aSpectator.Dimension )
local x, y, z = getElementPosition(localPlayer)
setElementPosition(localPlayer, x, y, z+1)
setElementVelocity (localPlayer, 0, 0, 0)
setElementFrozen ( localPlayer, false )
aSpectator.Spectating = nil
showCursor ( true )
aAdminMenu()
aSpectator.Dimension = nil
aSpectator.Interior = nil
end
end
function aSpectator.ClientDoubleClick ( button )
if ( source == aSpectator.Slaps ) then
if ( guiGridListGetSelectedItem ( aSpectator.Slaps ) ~= -1 ) then
aCurrentSlap = guiGridListGetItemText ( aSpectator.Slaps, guiGridListGetSelectedItem ( aSpectator.Slaps ), 1 )
guiSetText ( aTab1.Slap, "Slap! "..aCurrentSlap.."hp" )
guiSetText ( aSpectator.Slap, "Slap! "..aCurrentSlap.."hp" )
end
guiSetVisible ( aSpectator.Slaps, false )
end
end
function aSpectator.ClientClick ( button )
if ( source == aSpectator.Slaps ) then return end
guiSetVisible ( aSpectator.Slaps, false )
if ( button == "left" ) then
if ( source == aSpectator.Back ) then aSpectator.Close ( false )
elseif ( source == aSpectator.Ban ) then triggerEvent ( "onClientGUIClick", aTab1.Ban, "left" )
elseif ( source == aSpectator.Kick ) then triggerEvent ( "onClientGUIClick", aTab1.Kick, "left" )
elseif ( source == aSpectator.Freeze ) then triggerEvent ( "onClientGUIClick", aTab1.Freeze, "left" )
elseif ( source == aSpectator.SetSkin ) then triggerEvent ( "onClientGUIClick", aTab1.SetSkin, "left" )
elseif ( source == aSpectator.SetHealth ) then triggerEvent ( "onClientGUIClick", aTab1.SetHealth, "left" )
elseif ( source == aSpectator.SetArmour ) then triggerEvent ( "onClientGUIClick", aTab1.SetArmour, "left" )
elseif ( source == aSpectator.SetStats ) then triggerEvent ( "onClientGUIClick", aTab1.SetStats, "left" )
elseif ( source == aSpectator.Slap ) then triggerEvent ( "onClientGUIClick", aTab1.Slap, "left" )
elseif ( source == aSpectator.Next ) then aSpectator.SwitchPlayer ( 1 )
elseif ( source == aSpectator.Prev ) then aSpectator.SwitchPlayer ( -1 )
elseif ( source == aSpectator.PlayerList ) then
if ( guiGridListGetSelectedItem ( source ) ~= -1 ) then
aSpectate ( getPlayerFromNick ( guiGridListGetItemPlayerName ( source, guiGridListGetSelectedItem ( source ), 1 ) ) )
end
end
elseif ( button == "right" ) then
if ( source == aSpectator.Slap ) then
guiSetVisible ( aSpectator.Slaps, true )
else
local show = not isCursorShowing()
guiSetVisible ( aSpectator.Actions, show )
guiSetVisible ( aSpectator.Players, show )
guiSetVisible ( aSpectator.Next, show )
guiSetVisible ( aSpectator.Prev, show )
showCursor ( show )
end
end
end
function aSpectator.PlayerCheck ()
if ( source == aSpectator.Spectating ) then
aSpectator.SwitchPlayer ( 1 )
end
end
function aSpectator.SwitchPlayer ( inc, arg, inc2 )
if ( not tonumber ( inc ) ) then inc = inc2 end
if ( not tonumber ( inc ) ) then return end
local players
if ( guiCheckBoxGetSelected ( aSpectator.Skip ) ) then
players = aSpectator.GetAlive()
else
players = getElementsByType ( "player" )
end
if ( #players <= 0 ) then
aMessageBox ( "question", "Nobody to spectate, exit spectator?", "spectatorClose" )
return
end
local current = 1
for id, player in ipairs ( players ) do
if ( player == aSpectator.Spectating ) then
current = id
end
end
local next = ( ( current - 1 + inc ) % #players ) + 1
if ( next == current ) then
aMessageBox ( "question", "Nobody else to spectate, exit spectator?", "spectatorClose" )
return
end
aSpectator.Spectating = players[next]
setElementFrozen ( localPlayer, true )
setElementInterior( localPlayer, getElementInterior( aSpectator.Spectating ) )
setElementDimension( localPlayer, getElementDimension( aSpectator.Spectating ) )
end
function aSpectator.CursorMove ( rx, ry, x, y )
if ( not isCursorShowing() ) then
local sx, sy = guiGetScreenSize ()
aSpectator.AngleX = ( aSpectator.AngleX + ( x - sx / 2 ) / 10 ) % 360
aSpectator.AngleZ = ( aSpectator.AngleZ + ( y - sy / 2 ) / 10 ) % 360
if ( aSpectator.AngleZ > 180 ) then
if ( aSpectator.AngleZ < 315 ) then aSpectator.AngleZ = 315 end
else
if ( aSpectator.AngleZ > 45 ) then aSpectator.AngleZ = 45 end
end
end
end
function aSpectator.Render ()
local sx, sy = guiGetScreenSize ()
if ( not aSpectator.Spectating ) then
dxDrawText ( "Nobody to spectate", sx - 170, 200, sx - 170, 200, tocolor ( 255, 0, 0, 255 ), 1 )
return
end
local x, y, z = getElementPosition ( aSpectator.Spectating )
if ( not x ) then
dxDrawText ( "Error recieving coordinates", sx - 170, 200, sx - 170, 200, tocolor ( 255, 0, 0, 255 ), 1 )
return
end
local offset = aSpectator.Offset
if guiCheckBoxGetSelected(aSpectator.CollideWithWalls) then
local nearest_hit = aSpectator.CheckCollision(x, y, z)
if nearest_hit and (nearest_hit < offset) then
offset = nearest_hit
end
end
local ox, oy, oz
ox = x - math.sin ( math.rad ( aSpectator.AngleX ) ) * offset
oy = y - math.cos ( math.rad ( aSpectator.AngleX ) ) * offset
oz = z + math.tan ( math.rad ( aSpectator.AngleZ ) ) * offset
setCameraMatrix ( ox, oy, oz, x, y, z )
dxDrawText ( "Spectating: "..getPlayerName ( aSpectator.Spectating ), sx - 170, 200, sx - 170, 200, tocolor ( 255, 255, 255, 255 ), 1 )
if ( _DEBUG ) then
dxDrawText ( "DEBUG:\nAngleX: "..aSpectator.AngleX.."\nAngleZ: "..aSpectator.AngleZ.."\n\nOffset: "..aSpectator.Offset.."\nX: "..ox.."\nY: "..oy.."\nZ: "..oz.."\nDist: "..getDistanceBetweenPoints3D ( x, y, z, ox, oy, oz ), sx - 170, sy - 180, sx - 170, sy - 180, tocolor ( 255, 255, 255, 255 ), 1 )
else
if ( isCursorShowing () ) then
dxDrawText ( "Tip: mouse2 - toggle free camera mode", 20, sy - 50, 20, sy - 50, tocolor ( 255, 255, 255, 255 ), 1 )
else
dxDrawText ( "Tip: Use mouse scroll to zoom in/out", 20, sy - 50, 20, sy - 50, tocolor ( 255, 255, 255, 255 ), 1 )
end
end
end
local checks = {
{-1, -0.5},
{-1, 0.5},
{1, 0.5},
{1, -0.5},
}
function aSpectator.CheckCollision(x, y, z)
local nearest_distance
for k, v in ipairs(checks) do
local xx, yy, zz = getPositionFromOffset(getCamera(), v[1], 0, v[2])
local hit, hitx, hity, hitz = processLineOfSight(xx, yy, zz, x, y, z, true, true, false, true, true, false, false, false, (getPedOccupiedVehicle(localPlayer) or nil))
if hit then
local dist = getDistanceBetweenPoints3D(x, y, z, hitx, hity, hitz)
if (dist <= (nearest_distance or math.huge)) then
nearest_distance = dist
end
end
end
return nearest_distance or false
end
function aSpectator.MoveOffset ( key, state, inc )
if ( not isCursorShowing() ) then
aSpectator.Offset = aSpectator.Offset + tonumber ( inc )
if ( aSpectator.Offset > 70 ) then aSpectator.Offset = 70
elseif ( aSpectator.Offset < 2 ) then aSpectator.Offset = 2 end
end
end
function aSpectator.GetAlive ()
local alive = {}
for id, player in ipairs ( getElementsByType ( "player" ) ) do
if ( not isPedDead ( player ) ) then
table.insert ( alive, player )
end
end
return alive
end
function getPositionFromOffset(element, x, y, z)
local matrix = getElementMatrix(element)
local offX = x * matrix[1][1] + y * matrix[2][1] + z * matrix[3][1] + matrix[4][1]
local offY = x * matrix[1][2] + y * matrix[2][2] + z * matrix[3][2] + matrix[4][2]
local offZ = x * matrix[1][3] + y * matrix[2][3] + z * matrix[3][3] + matrix[4][3]
return offX, offY, offZ
end

View file

@ -0,0 +1,130 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_stats.lua
*
* Original File by lil_Toady
*
**************************************]]
aStatsForm = nil
local aStatsGUI = {}
function aPlayerStats ( player )
if ( aStatsForm == nil ) then
local x, y = guiGetScreenSize()
aStatsForm = guiCreateWindow ( x / 2 - 230, y / 2 - 200, 460, 400, "Player Stats Management", false )
guiCreateHeader ( 0.05, 0.06, 0.20, 0.05, "Weapon Skills:", true, aStatsForm )
local weapons = { "Pistol", "Silenced Pistol", "Desert Eagle", "Shotgun", "Sawn off", "Spaz12", "Uzi", "MP5", "AK47", "M4", "Sniper" }
local weapon = 1
while weapon <= 11 do
local stat = weapon + 68
aStatsGUI[stat] = {}
local label = guiCreateLabel ( 0.05, 0.06 + 0.07 * weapon, 0.20, 0.07, weapons[weapon]..":", true, aStatsForm )
guiLabelSetHorizontalAlign ( label, "right", false )
aStatsGUI[stat]["value"] = guiCreateEdit ( 0.26, 0.05 + 0.07 * weapon, 0.11, 0.06, "0", true, aStatsForm )
guiEditSetMaxLength ( aStatsGUI[stat]["value"], 4 )
aStatsGUI[stat]["button"] = guiCreateButton ( 0.37, 0.05 + 0.07 * weapon, 0.10, 0.06, "Set", true, aStatsForm, "setstat" )
weapon = weapon + 1
end
guiCreateStaticImage ( 0.50, 0.12, 0.0025, 0.75, "client\\images\\dot.png", true, aStatsForm )
guiCreateHeader ( 0.60, 0.06, 0.20, 0.05, "Body:", true, aStatsForm )
local bodys = { "Fat", "Stamina", "Muscles", "Health" }
local body = 1
while body <= 4 do
local stat = body + 20
aStatsGUI[stat] = {}
local label = guiCreateLabel ( 0.50, 0.06 + 0.07 * body, 0.20, 0.07, bodys[body]..":", true, aStatsForm )
guiLabelSetHorizontalAlign ( label, "right", false )
aStatsGUI[stat]["value"] = guiCreateEdit ( 0.71, 0.05 + 0.07 * body, 0.11, 0.06, "0", true, aStatsForm )
guiEditSetMaxLength ( aStatsGUI[stat]["value"], 4 )
aStatsGUI[stat]["button"] = guiCreateButton ( 0.82, 0.05 + 0.07 * body, 0.10, 0.06, "Set", true, aStatsForm, "setstat" )
body = body + 1
end
local label = guiCreateLabel ( 0.50, 0.61, 0.20, 0.07, "Fighting Style:", true, aStatsForm )
guiLabelSetHorizontalAlign ( label, "right", false )
aStatsGUI[300] = {}
aStatsGUI[300]["value"] = guiCreateEdit ( 0.71, 0.60, 0.11, 0.06, "4", true, aStatsForm )
guiEditSetMaxLength ( aStatsGUI[300]["value"], 2 )
aStatsGUI[300]["button"] = guiCreateButton ( 0.82, 0.60, 0.10, 0.06, "Set", true, aStatsForm )
guiCreateLabel ( 0.55, 0.67, 0.35, 0.07, "Accepted values: 4-7, 15, 16", true, aStatsForm )
guiCreateLabel ( 0.05, 0.93, 0.60, 0.05, "* Only numerical values from 0 to 1000 accepted", true, aStatsForm )
aStatsClose = guiCreateButton ( 0.80, 0.90, 0.14, 0.09, "Close", true, aStatsForm )
addEventHandler ( "onClientGUIClick", aStatsForm, aClientStatsClick )
addEventHandler ( "onClientGUIChanged", aStatsForm, aClientStatsChanged )
addEventHandler ( "onClientGUIAccepted", aStatsForm, aClientStatsAccepted )
--Register With Admin Form
aRegister ( "PlayerStats", aStatsForm, aPlayerStats, aPlayerStatsClose )
end
aStatsSelect = player
guiSetVisible ( aStatsForm, true )
guiBringToFront ( aStatsForm )
end
function aPlayerStatsClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceStats ) ) ) then
if ( aStatsForm ) then
removeEventHandler ( "onClientGUIClick", aStatsForm, aClientStatsClick )
removeEventHandler ( "onClientGUIChanged", aStatsForm, aClientStatsChanged )
removeEventHandler ( "onClientGUIAccepted", aStatsForm, aClientStatsAccepted )
destroyElement ( aStatsForm )
aStatsForm = nil
end
else
guiSetVisible ( aStatsForm, false )
end
end
function aClientStatsClick ( button )
if ( button == "left" ) then
if ( source == aStatsClose ) then
aPlayerStatsClose ( false )
else
for id, element in pairs ( aStatsGUI ) do
if ( element["button"] == source ) then
local value = tonumber ( guiGetText ( element["value"] ) )
if ( ( value ) and ( value >= 0 ) and ( value <= 1000 ) ) then
triggerServerEvent ( "aPlayer", localPlayer, aStatsSelect, "setstat", id, value )
else
aMessageBox ( "error", "Not numerical value (0-1000)" )
end
return
end
end
end
end
end
function aClientStatsChanged ()
for id, element in pairs ( aStatsGUI ) do
if ( element["value"] == source ) then
if ( guiGetText ( source ) ~= "" ) then
local input = tonumber ( guiGetText ( source ) )
if ( not input ) then
guiSetText ( source, string.gsub ( guiGetText ( source ), "[^%d]", "" ) )
elseif ( input > 1000 ) then
guiSetText ( source, "1000" )
elseif ( input < 0 ) then
guiSetText ( source, "0" )
end
end
return
end
end
end
function aClientStatsAccepted ()
for id, element in pairs ( aStatsGUI ) do
if ( element["value"] == source ) then
local value = tonumber ( guiGetText ( element["value"] ) )
if ( ( value ) and ( value >= 0 ) and ( value <= 1000 ) ) then
triggerServerEvent ( "aPlayer", localPlayer, aStatsSelect, "setstat", id, value )
else
aMessageBox ( "error", "Not numerical value (0-1000)" )
end
return
end
end
end

View file

@ -0,0 +1,157 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_team.lua
*
* Original File by lil_Toady
*
**************************************]]
aTeamForm = nil
aTeamSelect = nil
function aPlayerTeam ( player )
if ( aTeamForm == nil ) then
local x, y = guiGetScreenSize()
aTeamForm = guiCreateWindow ( x / 2 - 150, y / 2 - 125, 300, 250, "Player Team Management", false )
aTeamLabel = guiCreateLabel ( 0.03, 0.09, 0.94, 0.07, "Select a team from the list or create a new one", true, aTeamForm )
guiLabelSetHorizontalAlign ( aTeamLabel, "center" )
guiLabelSetColor ( aTeamLabel, 255, 0, 0 )
aTeamList = guiCreateGridList ( 0.03, 0.18, 0.50, 0.71, true, aTeamForm )
guiGridListAddColumn( aTeamList, "Teams", 0.85 )
aTeamRefresh = guiCreateButton ( 0.03, 0.90, 0.50, 0.08, "Refresh", true, aTeamForm )
aTeamNew = guiCreateButton ( 0.55, 0.18, 0.42, 0.09, "New Team", true, aTeamForm, "createteam" )
aTeamDelete = guiCreateButton ( 0.55, 0.28, 0.42, 0.09, "Delete Team", true, aTeamForm, "destroyteam" )
aTeamShowColor = guiCreateCheckBox ( 0.55, 0.38, 0.42, 0.09, "Show Teamcolor", true, true, aTeamForm )
aTeamNameLabel = guiCreateLabel ( 0.55, 0.19, 0.42, 0.07, "Team Name:", true, aTeamForm )
aTeamColor = guiCreateLabel ( 0.55, 0.37, 0.42, 0.11, "Color:", true, aTeamForm )
aTeamR = guiCreateLabel ( 0.70, 0.37, 0.42, 0.11, "R:", true, aTeamForm )
aTeamG = guiCreateLabel ( 0.70, 0.48, 0.42, 0.11, "G:", true, aTeamForm )
aTeanB = guiCreateLabel ( 0.70, 0.59, 0.42, 0.11, "B:", true, aTeamForm )
aTeamName = guiCreateEdit ( 0.55, 0.26, 0.42, 0.10, "", true, aTeamForm )
aTeamRed = guiCreateEdit ( 0.80, 0.36, 0.15, 0.10, "0", true, aTeamForm )
aTeamGreen = guiCreateEdit ( 0.80, 0.47, 0.15, 0.10, "0", true, aTeamForm )
aTeamBlue = guiCreateEdit ( 0.80, 0.58, 0.15, 0.10, "0", true, aTeamForm )
aTeamCreate = guiCreateButton ( 0.55, 0.73, 0.20, 0.09, "Create", true, aTeamForm, "createteam" )
aTeamCancel = guiCreateButton ( 0.77, 0.73, 0.20, 0.09, "Cancel", true, aTeamForm )
aTeamAccept = guiCreateButton ( 0.55, 0.88, 0.20, 0.09, "Select", true, aTeamForm )
aTeamClose = guiCreateButton ( 0.77, 0.88, 0.20, 0.09, "Close", true, aTeamForm )
aTeamRemove = guiCreateButton ( 0.55, 0.78, 0.42, 0.09, "Remove From Team", true, aTeamForm )
addEventHandler ( "onClientGUIClick", aTeamForm, aClientTeamClick )
addEventHandler ( "onClientGUIDoubleClick", aTeamForm, aClientTeamDoubleClick )
--Register With Admin Form
aRegister ( "PlayerTeam", aTeamForm, aPlayerTeam, aPlayerTeamClose )
end
aTeamSelect = player
aTeamsRefresh ()
guiSetVisible ( aTeamForm, true )
guiBringToFront ( aTeamForm )
aNewTeamShow ( false )
end
function aPlayerTeamClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceTeam ) ) ) then
if ( aTeamForm ) then
removeEventHandler ( "onClientGUIClick", aTeamForm, aClientTeamClick )
removeEventHandler ( "onClientGUIDoubleClick", aTeamForm, aClientTeamDoubleClick )
destroyElement ( aTeamForm )
aTeamForm = nil
end
else
guiSetVisible ( aTeamForm, false )
end
end
function aClientTeamDoubleClick ( button )
if ( button == "left" ) then
if ( source == aTeamList ) then
if ( guiGridListGetSelectedItem ( aTeamList ) ~= -1 ) then
local team = guiGridListGetItemText ( aTeamList, guiGridListGetSelectedItem ( aTeamList ), 1 )
triggerServerEvent ( "aPlayer", localPlayer, aTeamSelect, "setteam", getTeamFromName ( team ) )
aPlayerTeamClose ( false )
end
end
end
end
function aClientTeamClick ( button )
if ( button == "left" ) then
if ( source == aTeamNew ) then
aNewTeamShow ( true )
elseif ( source == aTeamRefresh or source == aTeamShowColor ) then
aTeamsRefresh()
elseif ( source == aTeamDelete ) then
if ( guiGridListGetSelectedItem ( aTeamList ) == -1 ) then
aMessageBox ( "warning", "No team selected!" )
else
local team = guiGridListGetItemText ( aTeamList, guiGridListGetSelectedItem ( aTeamList ), 1 )
aMessageBox ( "question", "Are you sure to delete \""..team.."\"?", "deleteTeam", team )
end
setTimer ( aTeamsRefresh, 2000, 1 )
elseif ( source == aTeamCreate ) then
local team = guiGetText ( aTeamName )
if ( ( team == nil ) or ( team == false ) or ( team == "" ) ) then
aMessageBox ( "warning", "Enter the team name!" )
elseif ( getTeamFromName ( team ) ) then
aMessageBox ( "error", "A team with this name already exists" )
else
triggerServerEvent ( "aTeam", localPlayer, "createteam", team, guiGetText ( aTeamRed ), guiGetText ( aTeamGreen ), guiGetText ( aTeamBlue ) )
aNewTeamShow ( false )
end
setTimer ( aTeamsRefresh, 2000, 1 )
--elseif ( source == aTeamName ) then
elseif ( source == aTeamCancel ) then
aNewTeamShow ( false )
elseif ( source == aTeamAccept ) then
if ( guiGridListGetSelectedItem ( aTeamList ) == -1 ) then
aMessageBox ( "warning", "No team selected!" )
else
local team = guiGridListGetItemText ( aTeamList, guiGridListGetSelectedItem ( aTeamList ), 1 )
triggerServerEvent ( "aPlayer", localPlayer, aTeamSelect, "setteam", getTeamFromName ( team ) )
guiSetVisible ( aTeamForm, false )
end
elseif ( source == aTeamClose ) then
aPlayerTeamClose ( false )
elseif ( source == aTeamRemove ) then
if getPlayerTeam( aTeamSelect ) then
triggerServerEvent ( "aPlayer", localPlayer, aTeamSelect, "removefromteam", nil )
else
aMessageBox( "warning", "This player is not in a team!")
end
end
end
end
function aNewTeamShow ( bool )
guiSetVisible ( aTeamNew, not bool )
guiSetVisible ( aTeamDelete, not bool )
guiSetVisible ( aTeamShowColor, not bool )
guiSetVisible ( aTeamNameLabel, bool )
guiSetVisible ( aTeamName, bool )
guiSetVisible ( aTeamColor, bool )
guiSetVisible ( aTeamR, bool )
guiSetVisible ( aTeamG, bool )
guiSetVisible ( aTeanB, bool )
guiSetVisible ( aTeamRed, bool )
guiSetVisible ( aTeamGreen, bool )
guiSetVisible ( aTeamBlue, bool )
guiSetVisible ( aTeamCreate, bool )
guiSetVisible ( aTeamCancel, bool )
guiSetVisible ( aTeamRemove, not bool )
end
function aTeamsRefresh ()
if ( aTeamList ) then
guiGridListClear ( aTeamList )
local showColor = guiCheckBoxGetSelected ( aTeamShowColor )
for id, team in ipairs ( getElementsByType ( "team" ) ) do
local row = guiGridListAddRow ( aTeamList )
guiGridListSetItemText ( aTeamList, row, 1, getTeamName ( team ), false, false )
if showColor then
guiGridListSetItemColor ( aTeamList, row, 1, getTeamColor ( team ) )
end
end
end
end

View file

@ -0,0 +1,305 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_stats.lua
*
* Original File by lil_Toady
*
**************************************]]
aVehicleForm = nil
aVehicleCustomizePlayer = nil
aVehicleCustomizeVehicle = nil
aVehicleUpgrades = {}
aUpgradeNames = {}
function aVehicleCustomize ( player )
if ( aVehicleForm == nil ) then
local x, y = guiGetScreenSize()
aVehicleForm = guiCreateWindow ( x / 2 - 300, y / 2 - 150, 600, 450, "Vehicle Customizations", false )
local node = xmlLoadFile ( "conf\\upgrades.xml" )
if ( node ) then
local upgrades = 0
while ( xmlFindChild ( node, "upgrade", upgrades ) ~= false ) do
local upgrade = xmlFindChild ( node, "upgrade", upgrades )
local id = tonumber ( xmlNodeGetAttribute ( upgrade, "id" ) )
local name = xmlNodeGetAttribute ( upgrade, "name" )
aUpgradeNames[id] = name
upgrades = upgrades + 1
end
xmlUnloadFile ( node )
end
local c = 1
for i = 1, 17 do
if ( i ~= 12 ) then
guiCreateLabel ( 0.05, 0.05 * ( c + 1 ), 0.15, 0.05, getVehicleUpgradeSlotName ( i - 1 )..":", true, aVehicleForm )
aVehicleUpgrades[c] = {}
aVehicleUpgrades[c].id = i - 1
aVehicleUpgrades[c].edit = guiCreateEdit ( 0.25, 0.05 * ( c + 1 ), 0.27, 0.048, "", true, aVehicleForm )
aVehicleUpgrades[c].drop = guiCreateStaticImage ( 0.485, 0.05 * ( c + 1 ), 0.035, 0.048, "client\\images\\dropdown.png", true, aVehicleForm )
aVehicleUpgrades[c].list = guiCreateGridList ( 0.25, 0.05 * ( c + 1 ), 0.27, 0.25, true, aVehicleForm )
aVehicleUpgrades[c].label = guiCreateLabel ( 0.54, 0.05 * ( c + 1 ), 0.05, 0.07, "(0)", true, aVehicleForm )
guiEditSetReadOnly ( aVehicleUpgrades[c].edit, true )
guiGridListAddColumn( aVehicleUpgrades[c].list, "Upgrade ID", 0.90 )
guiSetVisible ( aVehicleUpgrades[c].list, false )
c = c + 1
end
end
aVehicleUpgradeAll = guiCreateButton ( 0.04, 0.92, 0.15, 0.05, "Upgrade All", true, aVehicleForm )
aVehicleRemoveAll = guiCreateButton ( 0.20, 0.92, 0.15, 0.05, "Remove All", true, aVehicleForm )
aVehicleUpgrade = guiCreateButton ( 0.375, 0.92, 0.20, 0.05, "Upgrade Selected", true, aVehicleForm )
guiCreateStaticImage ( 0.60, 0.10, 0.002, 0.80, "client\\images\\dot.png", true, aVehicleForm )
guiCreateLabel ( 0.63, 0.10, 0.15, 0.05, "Paint job:", true, aVehicleForm )
aVehiclePaintjob = guiCreateEdit ( 0.79, 0.10, 0.09, 0.048, "0", true, aVehicleForm )
aVehiclePaintjobDrop = guiCreateStaticImage ( 0.845, 0.10, 0.035, 0.048, "client\\images\\dropdown.png", true, aVehicleForm )
aVehiclePaintjobList = guiCreateGridList ( 0.79, 0.10, 0.09, 0.25, true, aVehicleForm )
guiEditSetReadOnly ( aVehiclePaintjob, true )
guiGridListAddColumn( aVehiclePaintjobList, "", 0.65 )
guiSetVisible ( aVehiclePaintjobList, false )
for i = 0, 3 do guiGridListSetItemText ( aVehiclePaintjobList, guiGridListAddRow ( aVehiclePaintjobList ), 1, tostring ( i ), false, false ) end
aVehiclePaintjobSet = guiCreateButton ( 0.90, 0.10, 0.07, 0.048, "Set", true, aVehicleForm )
guiCreateLabel ( 0.63, 0.15, 0.15, 0.05, "Vehicle Color:", true, aVehicleForm )
guiCreateLabel ( 0.63, 0.20, 0.15, 0.05, "Color1:", true, aVehicleForm )
guiCreateLabel ( 0.63, 0.25, 0.15, 0.05, "Color2:", true, aVehicleForm )
guiCreateLabel ( 0.63, 0.30, 0.15, 0.05, "Color3:", true, aVehicleForm )
guiCreateLabel ( 0.63, 0.35, 0.15, 0.05, "Color4:", true, aVehicleForm )
aVehicleColor1 = guiCreateEdit ( 0.79, 0.20, 0.13, 0.048, "#000000", true, aVehicleForm ) guiEditSetMaxLength ( aVehicleColor1, 7 )
aVehicleColor2 = guiCreateEdit ( 0.79, 0.25, 0.13, 0.048, "#000000", true, aVehicleForm ) guiEditSetMaxLength ( aVehicleColor2, 7 )
aVehicleColor3 = guiCreateEdit ( 0.79, 0.30, 0.13, 0.048, "#000000", true, aVehicleForm ) guiEditSetMaxLength ( aVehicleColor3, 7 )
aVehicleColor4 = guiCreateEdit ( 0.79, 0.35, 0.13, 0.048, "#000000", true, aVehicleForm ) guiEditSetMaxLength ( aVehicleColor4, 7 )
--aVehicleColorScheme = guiCreateButton ( 0.63, 0.41, 0.20, 0.05, "View color IDs", true, aVehicleForm )
aVehicleColorSet = guiCreateButton ( 0.84, 0.41, 0.14, 0.05, "Set", true, aVehicleForm )
guiCreateLabel ( 0.63, 0.5, 0.15, 0.05, "Lights Color:", true, aVehicleForm )
aLightsColor = guiCreateEdit ( 0.79, 0.5, 0.13, 0.048, "#ffffff", true, aVehicleForm ) guiEditSetMaxLength ( aLightsColor, 7 )
aLightsColorSet = guiCreateButton ( 0.93, 0.5, 0.05, 0.05, "Set", true, aVehicleForm )
aVehicleUpgradeNames = guiCreateCheckBox ( 0.63, 0.7, 0.30, 0.04, "Show upgrade names", false, true, aVehicleForm )
if ( aGetSetting ( "aVehicleUpgradeNames" ) ) then guiCheckBoxSetSelected ( aVehicleUpgradeNames, true ) end
aVehicleClose = guiCreateButton ( 0.86, 0.92, 0.19, 0.05, "Close", true, aVehicleForm )
aVehicleColorForm = guiCreateWindow ( x / 2 - 280, y / 2 - 150, 540, 215, "Vehicle Color Scheme", false )
guiCreateStaticImage ( 0.01, 0.08, 0.98, 0.80, "client\\images\\colorscheme.png", true, aVehicleColorForm )
guiCreateLabel ( 0.63, 0.61, 0.15, 0.05, "License Plate:", true, aVehicleForm )
aLicensePlate = guiCreateEdit ( 0.79, 0.61, 0.13, 0.048, "", true, aVehicleForm ) guiEditSetMaxLength ( aLicensePlate, 8 )
aLicensePlateSet = guiCreateButton ( 0.93, 0.61, 0.05, 0.05, "Set", true, aVehicleForm )
aVehicleColorClose = guiCreateButton ( 0.86, 0.86, 0.19, 0.15, "Close", true, aVehicleColorForm )
guiSetVisible ( aVehicleColorForm, false )
guiSetVisible ( aVehicleForm, false )
addEventHandler ( "onClientGUIDoubleClick", aVehicleForm, aClientVehicleDoubleClick )
addEventHandler ( "onClientGUIClick", aVehicleForm, aClientVehicleClick )
addEventHandler ( "onClientGUIClick", aVehicleColorClose, aClientVehicleClick )
--Register With Admin Form
aRegister ( "VehicleCustomize", aVehicleForm, aVehicleCustomize, aVehicleCustomizeClose )
end
local vehicle = getPedOccupiedVehicle ( player )
if ( vehicle ) then
local update = true
if ( isElement ( aVehicleCustomizeVehicle ) ) then
if ( getElementModel ( aVehicleCustomizeVehicle ) == getElementModel ( vehicle ) ) then
update = false
end
end
guiSetText ( aVehicleForm, "Vehicle Customizations ("..tostring ( getVehicleName ( vehicle ) )..")" )
aVehicleCustomizePlayer = player
aVehicleCustomizeVehicle = vehicle
if ( update ) then aVehicleCheckUpgrades ( vehicle ) end
aVehicleCheckCurrentUpgrades ( vehicle )
guiSetVisible ( aVehicleForm, true )
guiBringToFront ( aVehicleForm )
end
end
function aVehicleCustomizeClose ( destroy )
if ( ( destroy ) or ( guiCheckBoxGetSelected ( aPerformanceVehicle ) ) ) then
if ( aVehicleForm ) then
removeEventHandler ( "onClientGUIClick", aVehicleForm, aClientVehicleClick )
removeEventHandler ( "onClientGUIDoubleClick", aVehicleForm, aClientVehicleDoubleClick )
removeEventHandler ( "onClientGUIClick", aVehicleColorClose, aClientVehicleClick )
destroyElement ( aVehicleForm )
destroyElement ( aVehicleColorForm )
aVehicleCustomizePlayer = nil
aVehicleCustomizeVehicle = nil
aVehicleForm = nil
aVehicleUpgrades = {}
end
else
guiSetVisible ( aVehicleForm, false )
guiSetVisible ( aVehicleColorForm, false )
end
end
function aVehicleCheckUpgrades ( vehicle )
if ( vehicle ) then
for slot, v in ipairs ( aVehicleUpgrades ) do
guiGridListClear ( aVehicleUpgrades[slot].list )
local row = guiGridListAddRow ( aVehicleUpgrades[slot].list )
guiGridListSetItemText ( aVehicleUpgrades[slot].list, row, 1, "", false, false )
local upgrades = getVehicleCompatibleUpgrades ( vehicle, aVehicleUpgrades[slot].id )
guiSetText ( aVehicleUpgrades[slot].label, "("..#upgrades..")" )
guiSetText ( aVehicleUpgrades[slot].edit, "" )
if ( getVehicleUpgradeOnSlot ( vehicle, aVehicleUpgrades[slot].id ) > 0 ) then
if ( guiCheckBoxGetSelected ( aVehicleUpgradeNames ) ) then
guiSetText ( aVehicleUpgrades[slot].edit, tostring ( aUpgradeNames[getVehicleUpgradeOnSlot ( vehicle, aVehicleUpgrades[slot].id )] ) )
else
guiSetText ( aVehicleUpgrades[slot].edit, tostring ( getVehicleUpgradeOnSlot ( vehicle, aVehicleUpgrades[slot].id ) ) )
end
end
for i, upgrade in ipairs ( upgrades ) do
local row2 = guiGridListAddRow ( aVehicleUpgrades[slot].list )
if ( guiCheckBoxGetSelected ( aVehicleUpgradeNames ) ) then
guiGridListSetItemText ( aVehicleUpgrades[slot].list, row2, 1, tostring ( aUpgradeNames[tonumber(upgrade)] ), false, false )
else
guiGridListSetItemText ( aVehicleUpgrades[slot].list, row2, 1, tostring ( upgrade ), false, false )
end
end
end
else
outputChatBox ( "You must be in a vehicle.", 255, 0, 0 )
end
end
function aVehicleCheckCurrentUpgrades ( vehicle )
if ( vehicle and isElement( vehicle ) ) then
for slot, v in ipairs ( aVehicleUpgrades ) do
if ( getVehicleUpgradeOnSlot ( vehicle, aVehicleUpgrades[slot].id ) > 0 ) then
if ( guiCheckBoxGetSelected ( aVehicleUpgradeNames ) ) then
guiSetText ( aVehicleUpgrades[slot].edit, tostring ( aUpgradeNames[getVehicleUpgradeOnSlot ( vehicle, aVehicleUpgrades[slot].id )] ) )
else
guiSetText ( aVehicleUpgrades[slot].edit, tostring ( getVehicleUpgradeOnSlot ( vehicle, aVehicleUpgrades[slot].id ) ) )
end
else
guiSetText ( aVehicleUpgrades[slot].edit, "" )
end
end
end
end
function aGetVehicleUpgradeFromName ( uname )
for id, name in pairs ( aUpgradeNames ) do
if ( name == uname ) then
return id
end
end
return false
end
function aClientVehicleDoubleClick ( button )
if ( button == "left" ) then
if ( source == aVehiclePaintjobList ) then
if ( guiGridListGetSelectedItem ( source ) ~= -1 ) then
local paintjob = guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )
guiSetText ( aVehiclePaintjob, tostring ( paintjob ) )
end
guiSetVisible ( source, false )
else
for id, element in ipairs ( aVehicleUpgrades ) do
if ( source == element.list ) then
if ( guiGridListGetSelectedItem ( source ) ~= -1 ) then
local upgrade = guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )
guiSetText ( element.edit, tostring ( upgrade ) )
end
guiSetVisible ( source, false )
return
end
end
end
end
end
function aClientVehicleClick ( button )
if ( source ~= aVehiclePaintjobList ) then guiSetVisible ( aVehiclePaintjobList, false ) end
if ( button == "left" ) then
for id, element in ipairs ( aVehicleUpgrades ) do
if ( source ~= element.list ) then guiSetVisible ( element.list, false ) end
if ( source == element.edit ) then
guiBringToFront ( element.drop )
elseif ( source == element.drop ) then
guiSetVisible ( element.list, true )
guiBringToFront ( element.list )
end
end
if ( source == aVehiclePaintjob ) then
guiBringToFront ( aVehiclePaintjobDrop )
elseif ( source == aVehicleClose ) then
aVehicleCustomizeClose ( false )
elseif ( source == aVehicleColorClose ) then
guiSetVisible ( aVehicleColorForm, false )
elseif ( source == aVehicleColorSet ) then
triggerServerEvent ( "aVehicle", localPlayer, aVehicleCustomizePlayer, "setcolor", { guiGetText ( aVehicleColor1 ), guiGetText ( aVehicleColor2 ), guiGetText ( aVehicleColor3 ), guiGetText ( aVehicleColor4 ) } )
elseif ( source == aLightsColorSet ) then
triggerServerEvent ( "aVehicle", localPlayer, aVehicleCustomizePlayer, "setlights", { guiGetText ( aLightsColor ) } )
elseif ( source == aLicensePlateSet ) then
triggerServerEvent ( "aVehicle", localPlayer, aVehicleCustomizePlayer, "setplates", { guiGetText ( aLicensePlate ) } )
elseif ( source == aVehicleUpgradeAll ) then
triggerServerEvent ( "aVehicle", localPlayer, aVehicleCustomizePlayer, "customize", { "all" } )
setTimer ( aVehicleCheckCurrentUpgrades, 2000, 1, aVehicleCustomizeVehicle )
elseif ( source == aVehicleRemoveAll ) then
triggerServerEvent ( "aVehicle", localPlayer, aVehicleCustomizePlayer, "customize", { "remove" } )
setTimer ( aVehicleCheckCurrentUpgrades, 2000, 1, aVehicleCustomizeVehicle )
elseif ( source == aVehiclePaintjobSet ) then
triggerServerEvent ( "aVehicle", localPlayer, aVehicleCustomizePlayer, "setpaintjob", tonumber ( guiGetText ( aVehiclePaintjob ) ) )
elseif ( source == aVehiclePaintjobDrop ) then
guiSetVisible ( aVehiclePaintjobList, true )
guiBringToFront ( aVehiclePaintjobList )
elseif ( source == aVehicleUpgradeNames ) then
aVehicleCheckUpgrades ( aVehicleCustomizeVehicle )
aSetSetting ( "aVehicleUpgradeNames", guiCheckBoxGetSelected ( aVehicleUpgradeNames ) )
elseif source == aVehicleColor1 then
openPicker("vehicleColor1", guiGetText(aVehicleColor1), "Set vehicle color")
elseif source == aVehicleColor2 then
openPicker("vehicleColor2", guiGetText(aVehicleColor2), "Set vehicle color")
elseif source == aVehicleColor3 then
openPicker("vehicleColor3", guiGetText(aVehicleColor3), "Set vehicle color")
elseif source == aVehicleColor4 then
openPicker("vehicleColor4", guiGetText(aVehicleColor4), "Set vehicle color")
elseif source == aLightsColor then
openPicker("lightsColor", "#ffffff", "Set lights color")
elseif ( source == aVehicleUpgrade ) then
local tableOut = {}
for id, element in ipairs ( aVehicleUpgrades ) do
local upgrade = guiGetText ( element.edit )
if ( upgrade ) and ( upgrade ~= "" ) then
if ( guiCheckBoxGetSelected ( aVehicleUpgradeNames ) ) then
upgrade = aGetVehicleUpgradeFromName ( upgrade )
if ( upgrade ) then
table.insert ( tableOut, upgrade )
end
else
table.insert ( tableOut, tonumber ( upgrade ) )
end
end
end
triggerServerEvent ( "aVehicle", localPlayer, aVehicleCustomizePlayer, "customize", tableOut )
setTimer ( aVehicleCheckCurrentUpgrades, 2000, 1, aVehicleCustomizeVehicle )
end
end
end
addEvent("onColorPickerOK", true)
addEventHandler("onColorPickerOK", root,
function (id, hex)
if id == "vehicleColor1" then
guiSetText(aVehicleColor1, hex)
elseif id == "vehicleColor2" then
guiSetText(aVehicleColor2, hex)
elseif id == "vehicleColor3" then
guiSetText(aVehicleColor3, hex)
elseif id == "vehicleColor4" then
guiSetText(aVehicleColor4, hex)
elseif id == "lightsColor" then
guiSetText(aLightsColor, hex)
end
end)

View file

@ -0,0 +1,173 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* gui\admin_warp.lua
*
* Original File by lil_Toady
*
**************************************]]
aWarpForm = nil
aWarpToPositionForm = nil
function aPlayerWarp ( player )
if ( aWarpForm == nil ) then
local x, y = guiGetScreenSize()
aWarpForm = guiCreateWindow ( x / 2 - 110, y / 2 - 150, 200, 330, "Player Warp Management", false )
aWarpList = guiCreateGridList ( 0.03, 0.08, 0.94, 0.64, true, aWarpForm )
guiGridListAddColumn( aWarpList, "Player", 0.9 )
aWarpSelect = guiCreateButton ( 0.03, 0.74, 0.94, 0.07, "Select", true, aWarpForm )
aWarpToPosition = guiCreateButton ( 0.03, 0.82, 0.94, 0.07, "To position", true, aWarpForm )
aWarpCancel = guiCreateButton ( 0.03, 0.90, 0.94, 0.07, "Cancel", true, aWarpForm )
addEventHandler ( "onClientGUIDoubleClick", aWarpForm, aClientWarpDoubleClick )
addEventHandler ( "onClientGUIClick", aWarpForm, aClientWarpClick )
--Register With Admin Form
aRegister ( "PlayerWarp", aWarpForm, aPlayerWarp, aPlayerWarpClose )
end
aWarpSelectPointer = player
guiGridListClear ( aWarpList )
for id, plr in ipairs ( getElementsByType ( "player" ) ) do
if ( plr ~= aWarpSelectPointer ) then
guiGridListSetItemPlayerName ( aWarpList, guiGridListAddRow ( aWarpList ), 1, getPlayerName ( plr ), false, false )
end
end
guiSetVisible ( aWarpForm, true )
guiBringToFront ( aWarpForm )
end
function aPlayerWarpClose ( destroy )
if ( destroy ) then
if ( aWarpForm ) then
removeEventHandler ( "onClientGUIDoubleClick", aWarpForm, aClientWarpDoubleClick )
removeEventHandler ( "onClientGUIClick", aWarpForm, aClientWarpClick )
destroyElement ( aWarpForm )
aWarpForm = nil
end
else
guiSetVisible ( aWarpForm, false )
end
end
function aPlayerWarpToPosition ( )
if ( aWarpToPositionForm == nil ) then
local x, y = guiGetScreenSize()
local h = y * 0.75
aWarpToPositionForm = guiCreateWindow ( x / 2 - h / 2, y / 2 - h / 2, h, h + 40, "Player Warp To Position", false )
aWarpToPositionMap = guiCreateStaticImage ( 10, 25, h - 20, h - 20, "client/images/map.png", false, aWarpToPositionForm )
aWarpToPositionTeleport = guiCreateButton ( 10, h + 10, 80, 25, "Teleport", false, aWarpToPositionForm )
aWarpToPositionCancel = guiCreateButton ( h - 90, h + 10, 80, 25, "Cancel", false, aWarpToPositionForm )
aWarpToPositionX = guiCreateEdit ( 100, h + 10, 80, 25, "0", false, aWarpToPositionForm )
aWarpToPositionY = guiCreateEdit ( 185, h + 10, 80, 25, "0", false, aWarpToPositionForm )
aWarpToPositionZ = guiCreateEdit ( 270, h + 10, 80, 25, "3", false, aWarpToPositionForm )
addEventHandler ( "onClientGUIDoubleClick", aWarpToPositionForm, aClientWarpDoubleClick )
addEventHandler ( "onClientGUIClick", aWarpToPositionForm, aClientWarpClick )
--Register With Admin Form
aRegister ( "PlayerWarpToPosition", aWarpToPositionForm, aPlayerWarpToPosition, aPlayerWarpToPositionClose )
end
guiSetVisible ( aWarpToPositionForm, true )
guiBringToFront ( aWarpToPositionForm )
end
function aPlayerWarpToPositionClose ( destroy )
if ( destroy ) then
if ( aWarpToPositionForm ) then
removeEventHandler ( "onClientGUIDoubleClick", aWarpToPositionForm, aClientWarpDoubleClick )
removeEventHandler ( "onClientGUIClick", aWarpToPositionForm, aClientWarpClick )
destroyElement ( aWarpToPositionForm )
aWarpToPositionForm = nil
end
else
guiSetVisible ( aWarpToPositionForm, false )
end
end
local function calculatePosition ( absX, absY )
local x, y = guiGetPosition(aWarpToPositionForm, false)
x, y = x + 10, y + 25
local w, h = guiGetSize(aWarpToPositionMap, false)
local tpX, tpY = ( absX - x ) / w * 6000 - 3000, - ( ( absY - y ) / h * 6000 - 3000 )
local hit, _, _, tpZ = processLineOfSight ( tpX, tpY, 3000, tpX, tpY, -3000 )
tpZ = hit and tpZ or "auto"
guiSetText ( aWarpToPositionX, tpX ); guiSetText ( aWarpToPositionY, tpY ); guiSetText ( aWarpToPositionZ, tpZ )
return tpX, tpY, tpY
end
local function getTeleportPosition ( )
return guiGetText ( aWarpToPositionX ), guiGetText ( aWarpToPositionY ), guiGetText ( aWarpToPositionZ )
end
local function warpToPosition ( player, x, y, z )
if isElement(player) then
x, y, z = tonumber(x) or 0, tonumber(y) or 0, tonumber(z) or 0
local distance = getElementDistanceFromCentreOfMassToBaseOfModel ( player )
triggerServerEvent ( "aPlayer", localPlayer, player, "warpto", { x, y, z + distance + 0.25 } )
aPlayerWarpToPositionClose ( false )
aPlayerWarpClose ( false )
end
end
local function warpPlayerToPositionTrigger ( )
local x, y, z = getTeleportPosition ( )
if z == "auto" then
local target = getPedOccupiedVehicle(localPlayer) or localPlayer
fadeCamera ( false, 0 )
setElementFrozen ( target, true )
setCameraMatrix ( x, y, 0 )
setTimer ( function ( )
local hit, _, _, hitZ = processLineOfSight(x, y, 3000, x, y, -3000)
setCameraTarget ( localPlayer )
setElementFrozen ( target, false )
fadeCamera ( true, 0.1 )
if not hit then return end
warpToPosition ( aWarpSelectPointer, x, y, hitZ )
end, 100, 1 )
else
warpToPosition ( aWarpSelectPointer, x, y, z )
end
end
function aClientWarpDoubleClick ( button )
if ( button == "left" ) then
if ( source == aWarpList ) then
if ( guiGridListGetSelectedItem ( aWarpList ) ~= -1 ) then
if isElement(aWarpSelectPointer) then
triggerServerEvent ( "aPlayer", localPlayer, aWarpSelectPointer, "warpto", getPlayerFromNick ( guiGridListGetItemPlayerName ( aWarpList, guiGridListGetSelectedItem ( aWarpList ), 1 ) ) )
end
aPlayerWarpClose ( false )
end
elseif ( source == aWarpToPositionMap ) then
warpPlayerToPositionTrigger ( )
end
end
end
function aClientWarpClick ( button, state, absX, absY )
if ( button == "left" ) then
-- Player Warp Management
if ( source == aWarpSelect ) then
if ( guiGridListGetSelectedItem ( aWarpList ) ~= -1 ) then
if isElement(aWarpSelectPointer) then
triggerServerEvent ( "aPlayer", localPlayer, aWarpSelectPointer, "warpto", getPlayerFromNick ( guiGridListGetItemPlayerName ( aWarpList, guiGridListGetSelectedItem ( aWarpList ), 1 ) ) )
end
aPlayerWarpClose ( false )
end
elseif ( source == aWarpCancel ) then
aPlayerWarpClose ( false )
elseif ( source == aWarpToPosition ) then
aPlayerWarpToPosition ( )
-- Player Warp To Position Map
elseif ( source == aWarpToPositionMap ) then
calculatePosition ( absX, absY )
elseif ( source == aWarpToPositionTeleport ) then
warpPlayerToPositionTrigger ( )
elseif ( source == aWarpToPositionCancel ) then
aPlayerWarpToPositionClose ( false )
end
end
end

Binary file not shown.

After

(image error) Size: 11 KiB

Binary file not shown.

After

(image error) Size: 69 B

Binary file not shown.

After

(image error) Size: 315 B

Binary file not shown.

After

(image error) Size: 84 B

Binary file not shown.

After

(image error) Size: 8.2 KiB

Binary file not shown.

After

(image error) Size: 598 B

Binary file not shown.

After

(image error) Size: 215 B

Binary file not shown.

After

(image error) Size: 265 B

Binary file not shown.

After

(image error) Size: 239 B

Binary file not shown.

After

(image error) Size: 527 B

Binary file not shown.

After

(image error) Size: 560 B

Binary file not shown.

After

(image error) Size: 390 B

Binary file not shown.

After

(image error) Size: 348 B

Binary file not shown.

After

(image error) Size: 393 B

Binary file not shown.

After

(image error) Size: 194 B

Binary file not shown.

After

(image error) Size: 433 B

Binary file not shown.

After

(image error) Size: 146 B

Binary file not shown.

After

(image error) Size: 529 B

Binary file not shown.

After

(image error) Size: 253 B

Binary file not shown.

After

(image error) Size: 332 B

Binary file not shown.

After

(image error) Size: 137 B

Binary file not shown.

After

(image error) Size: 393 B

Binary file not shown.

After

(image error) Size: 260 B

Binary file not shown.

After

(image error) Size: 459 B

Binary file not shown.

After

(image error) Size: 443 B

Binary file not shown.

After

(image error) Size: 188 B

Binary file not shown.

After

(image error) Size: 88 B

Binary file not shown.

After

(image error) Size: 460 B

Binary file not shown.

After

(image error) Size: 98 B

Binary file not shown.

After

(image error) Size: 328 B

Binary file not shown.

After

(image error) Size: 504 B

Binary file not shown.

After

(image error) Size: 375 B

Binary file not shown.

After

(image error) Size: 527 B

Binary file not shown.

After

(image error) Size: 457 B

Binary file not shown.

After

(image error) Size: 481 B

Binary file not shown.

After

(image error) Size: 258 B

Binary file not shown.

After

(image error) Size: 437 B

Binary file not shown.

After

(image error) Size: 492 B

Binary file not shown.

After

(image error) Size: 398 B

Binary file not shown.

After

(image error) Size: 327 B

Binary file not shown.

After

(image error) Size: 173 B

Binary file not shown.

After

(image error) Size: 490 B

Binary file not shown.

After

(image error) Size: 329 B

Binary file not shown.

After

(image error) Size: 580 B

Binary file not shown.

After

(image error) Size: 502 B

Binary file not shown.

After

(image error) Size: 489 B

Binary file not shown.

After

(image error) Size: 505 B

Binary file not shown.

After

(image error) Size: 322 B

Binary file not shown.

After

(image error) Size: 328 B

Some files were not shown because too many files have changed in this diff Show more