Initial commit

This commit is contained in:
Jacob
2021-12-03 01:05:09 +00:00
commit c1add166a1
3511 changed files with 463300 additions and 0 deletions
+784
View File
@@ -0,0 +1,784 @@
local spawnedObjects = {}
_menuPool = NativeUI.CreatePool()
local mySteamID
local isAdmin = false
local isWhitelisted = false
Citizen.CreateThread(function()
while true do
Wait(1)
if _menuPool:IsAnyMenuOpen() then
_menuPool:ProcessMenus()
end
end
end)
--[[Citizen.CreateThread(function()
while true do
if IsControlJustReleased(0, 38) then
openMapMaker()
end
Citizen.Wait(1)
end
end)--]]
RegisterCommand(Config.Command, function(source, args, rawCommand)
if isWhitelisted then
openMapMaker()
end
end, false)
Citizen.CreateThread(function()
Citizen.Wait(500)
TriggerServerEvent('mapbuilder:getObjects')
end)
RegisterNetEvent('mapbuilder:receiveObjects')
AddEventHandler('mapbuilder:receiveObjects', function(result)
for k, v in pairs(result) do
local sObject = CreateObject(GetHashKey(v.objectHash), v.locX, v.locY, v.locZ, false, true, true)
Citizen.Wait(25)
SetEntityCoords(sObject, v.locX, v.locY, v.locZ)
SetEntityHeading(sObject, v.heading)
--PlaceObjectOnGroundProperly(sObject)
if tonumber(v.freeze) == 1 then
FreezeEntityPosition(sObject, true)
else
FreezeEntityPosition(sObject, false)
end
table.insert(spawnedObjects, result[k])
spawnedObjects[#spawnedObjects].entity = sObject
end
end)
local object = nil
local selectedObject = nil
local selectedObjectHash = nil
local objectHash = nil -- final object hash
local isFrozen = true
local mapmakerMenu
local spawnObject_sub
local enterObject
function openMapMaker()
_menuPool:Remove()
_menuPool = NativeUI.CreatePool()
collectgarbage()
local prefix = ''
if object == nil then
prefix = '~c~'
else
prefix = ''
end
mapmakerMenu = NativeUI.CreateMenu(Translation[Config.Locale]['menu_title'])
_menuPool:Add(mapmakerMenu)
local objectsInDistance = _menuPool:AddSubMenu(mapmakerMenu, Translation[Config.Locale]['get_object_distance'], '~b~')
mapmakerMenu.Items[1]:RightLabel('~o~→→→')
if #spawnedObjects > 0 then
for k, v in pairs(spawnedObjects) do
if v.createdBy == mySteamID or (isAdmin) then
local roundX = math.round(v.locX)
local roundY = math.round(v.locY)
local roundZ = math.round(v.locZ)
local roundHeading = math.round(v.heading)
local obj_sub
if Config.useNativeUIReloaded then
obj_sub = _menuPool:AddSubMenu(objectsInDistance.SubMenu, '~b~' .. v.comment .. ' ~s~| ' .. v.objectHash, '(~b~X ~s~= ' .. roundX .. ', ~b~Y ~s~= ' .. roundY .. ', ~b~Z~s~ = ' .. roundZ)
else
obj_sub = _menuPool:AddSubMenu(objectsInDistance, '~b~' .. v.comment .. ' ~s~| ' .. v.objectHash, '(~b~X ~s~= ' .. roundX .. ', ~b~Y ~s~= ' .. roundY .. ', ~b~Z~s~ = ' .. roundZ)
end
if isAdmin then
local teleport = NativeUI.CreateItem(Translation[Config.Locale]['obj_tp'], Translation[Config.Locale]['obj_tp_desc'])
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(teleport)
else
obj_sub:AddItem(teleport)
end
teleport.Activated = function(sender, index)
SetEntityCoords(PlayerPedId(), v.locX, v.locY, v.locZ)
end
end
local hide = NativeUI.CreateItem(Translation[Config.Locale]['obj_hide'], Translation[Config.Locale]['obj_hide_desc'])
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(hide)
else
obj_sub:AddItem(hide)
end
hide.Activated = function(sender, index)
if v.entity ~= nil then
DeleteObject(v.entity)
v.entity = nil
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
local replace = NativeUI.CreateItem(Translation[Config.Locale]['obj_replace'], Translation[Config.Locale]['obj_replace_desc'])
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(replace)
else
obj_sub:AddItem(replace)
end
replace.Activated = function(sender, index)
if v.entity == nil then
newObj = spawnObject(v.objectHash, v.locX, v.locY, v.locZ, v.heading, v.freeze)
v.entity = newObj
else
ShowNotification(Translation[Config.Locale]['obj_already_exists'])
end
end
local turn = NativeUI.CreateItem(Translation[Config.Locale]['turn_object'], '~b~')
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(turn)
else
obj_sub:AddItem(turn)
end
turn.Activated = function(sender, index)
if v.entity ~= nil then
if Config.useNativeUIReloaded then
turnObject(v.entity, obj_sub.SubMenu)
else
turnObject(v.entity, obj_sub)
end
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
local move = NativeUI.CreateItem(Translation[Config.Locale]['move_object'], '~b~')
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(move)
else
obj_sub:AddItem(move)
end
move.Activated = function(sender, index)
if v.entity ~= nil then
if Config.useNativeUIReloaded then
moveObject(v.entity, obj_sub.SubMenu)
else
moveObject(v.entity, obj_sub)
end
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
local moveUpandDown = NativeUI.CreateItem(Translation[Config.Locale]['moveupdown_object'], '~b~')
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(moveUpandDown)
else
obj_sub:AddItem(moveUpandDown)
end
moveUpandDown.Activated = function(sender, index)
if v.entity ~= nil then
if Config.useNativeUIReloaded then
moveUpDown(v.entity, obj_sub.SubMenu)
else
moveUpDown(v.entity, obj_sub)
end
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
local editMoveable = NativeUI.CreateCheckboxItem(Translation[Config.Locale]['set_moveable'], v.freeze, Translation[Config.Locale]['set_moveable_desc'])
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(editMoveable)
obj_sub.SubMenu.OnCheckboxChange = function(sender, item, checked)
if item == editMoveable then
if v.entity ~= nil then
isFrozen = checked
ShowNotification(Translation[Config.Locale]['moveable_state_changed'] .. tostring(checked))
FreezeEntityPosition(v.entity, isFrozen)
else
isFrozen = checked
--ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
end
else
obj_sub:AddItem(editMoveable)
obj_sub.OnCheckboxChange = function(sender, item, checked)
if item == editMoveable then
if object ~= nil then
isFrozen = checked
ShowNotification(Translation[Config.Locale]['moveable_state_changed'] .. tostring(checked))
FreezeEntityPosition(object, isFrozen)
else
isFrozen = checked
--ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
end
end
local permDelete = NativeUI.CreateItem(Translation[Config.Locale]['delete_object'], Translation[Config.Locale]['obj_permdelete_desc'])
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(permDelete)
else
obj_sub:AddItem(permDelete)
end
permDelete.Activated = function(sender, index)
TriggerServerEvent('mapbuilder:removeFromDatabase', v.id, v.objectHash)
TriggerServerEvent('mapbuilder:syncObjectRemove', v.id, v.objectHash)
ShowNotification(Translation[Config.Locale]['obj_removed'])
end
local save = NativeUI.CreateItem(Translation[Config.Locale]['obj_savechanges'], Translation[Config.Locale]['obj_savechanges_desc'])
if Config.useNativeUIReloaded then
obj_sub.SubMenu:AddItem(save)
else
obj_sub:AddItem(save)
end
save.Activated = function(sender, index)
local coords = GetEntityCoords(v.entity)
local heading = GetEntityHeading(v.entity)
TriggerServerEvent('mapbuilder:updateObject', v.id, coords, heading, isFrozen)
ShowNotification(Translation[Config.Locale]['obj_saved'])
--TriggerServerEvent('mapbuilder:saveToDatabase', selectedObject, coords, heading, isMoveable, desc)
--DeleteObject(object)
end
end
end
end
spawnObject_sub = _menuPool:AddSubMenu(mapmakerMenu, Translation[Config.Locale]['spawn_object'], '~b~Select an object!')
mapmakerMenu.Items[2]:RightLabel('~b~→→→')
enterObject = NativeUI.CreateItem(Translation[Config.Locale]['enter_objectname'], Translation[Config.Locale]['enter_objectname_desc'])
enterObject:RightLabel('~b~' .. Config.defaultObject)
selectedObject = Config.defaultObject
selectedObjectHash = GetHashKey(Config.defaultObject)
if Config.useNativeUIReloaded then
spawnObject_sub.SubMenu:AddItem(enterObject)
else
spawnObject_sub:AddItem(enterObject)
end
enterObject.Activated = function(sender, index)
if isAdmin then
if Config.useNativeUIReloaded then
spawnObject_sub.SubMenu:Visible(false)
else
spawnObject_sub:Visible(false)
end
--local objectInput = KeyboardInput(Translation[Config.Locale]['insert_here'], Translation[Config.Locale]['insert_placeholder'], 100)
ShowNotification(Translation[Config.Locale]['selectObject_help'])
end
end
local recommendObjects
if Config.useNativeUIReloaded then
recommendObjects = _menuPool:AddSubMenu(spawnObject_sub.SubMenu, Translation[Config.Locale]['recommend_objects'], Translation[Config.Locale]['recommend_objects_desc'])
spawnObject_sub.SubMenu.Items[2]:RightLabel('~o~→→→')
else
recommendObjects = _menuPool:AddSubMenu(spawnObject_sub, Translation[Config.Locale]['recommend_objects'], Translation[Config.Locale]['recommend_objects_desc'])
spawnObject_sub.Items[2]:RightLabel('~o~→→→')
end
for k, v in pairs(Config.recommendObjects) do
local recObjectItem = NativeUI.CreateItem(v.label, 'Select object ~b~' .. v.object)
if Config.useNativeUIReloaded then
recommendObjects.SubMenu:AddItem(recObjectItem)
recObjectItem.Activated = function(sender, index)
recommendObjects.SubMenu:Visible(false)
enterObject:RightLabel('~g~' .. v.object)
selectedObjectHash = GetHashKey(v.object)
selectedObject = v.object
spawnObject_sub.SubMenu:Visible(true)
end
else
recommendObjects:AddItem(recObjectItem)
recObjectItem.Activated = function(sender, index)
recommendObjects:Visible(false)
enterObject:RightLabel('~g~' .. v.object)
selectedObjectHash = GetHashKey(v.object)
selectedObject = v.object
spawnObject_sub:Visible(true)
end
end
end
local spawnObjectFinal = NativeUI.CreateItem(Translation[Config.Locale]['spawn_object_final'], Translation[Config.Locale]['spawn_object_final_desc'])
if Config.useNativeUIReloaded then
spawnObject_sub.SubMenu:AddItem(spawnObjectFinal)
else
spawnObject_sub:AddItem(spawnObjectFinal)
end
local moveObjectItem = NativeUI.CreateItem(Translation[Config.Locale]['move_object'], '~b~')
moveObjectItem:RightLabel(Translation[Config.Locale]['no_object'])
mapmakerMenu:AddItem(moveObjectItem)
moveObjectItem.Activated = function()
if object ~= nil then
moveObject(object, mapmakerMenu)
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
local turnObjectItem = NativeUI.CreateItem(Translation[Config.Locale]['turn_object'], '~b~')
turnObjectItem:RightLabel(Translation[Config.Locale]['no_object'])
mapmakerMenu:AddItem(turnObjectItem)
turnObjectItem.Activated = function(sender, index)
if object ~= nil then
turnObject(object, mapmakerMenu)
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
local moveUpandDownItem = NativeUI.CreateItem(Translation[Config.Locale]['moveupdown_object'], '~b~')
moveUpandDownItem:RightLabel(Translation[Config.Locale]['no_object'])
mapmakerMenu:AddItem(moveUpandDownItem)
moveUpandDownItem.Activated = function(sender, index)
if object ~= nil then
moveUpDown(object, mapmakerMenu)
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
local setMoveableItem = NativeUI.CreateCheckboxItem(Translation[Config.Locale]['set_moveable'], isFrozen, Translation[Config.Locale]['set_moveable_desc'])
mapmakerMenu:AddItem(setMoveableItem)
mapmakerMenu.OnCheckboxChange = function(sender, item, checked)
if item == setMoveableItem then
if object ~= nil then
isFrozen = checked
ShowNotification(Translation[Config.Locale]['moveable_state_changed'] .. tostring(checked))
FreezeEntityPosition(object, isFrozen)
else
isFrozen = checked
--ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
end
local desc = '-'
local commentItem = NativeUI.CreateItem(Translation[Config.Locale]['set_description'], Translation[Config.Locale]['set_description_desc'])
commentItem:RightLabel('~b~' .. desc)
mapmakerMenu:AddItem(commentItem)
commentItem.Activated = function(sender, index)
local descStr = KeyboardInput(Translation[Config.Locale]['set_description'], desc, 20)
if descStr ~= nil then
desc = descStr
commentItem:RightLabel('~b~' .. desc)
end
end
local deleteObjectItem = NativeUI.CreateItem(Translation[Config.Locale]['delete_object'], Translation[Config.Locale]['delete_object_desc'])
mapmakerMenu:AddItem(deleteObjectItem)
deleteObjectItem.Activated = function(sender, index)
if object ~= nil then
DeleteObject(object)
object = nil
turnObjectItem:RightLabel(Translation[Config.Locale]['no_object'])
moveObjectItem:RightLabel(Translation[Config.Locale]['no_object'])
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
local saveObject = NativeUI.CreateItem(Translation[Config.Locale]['save_object'], Translation[Config.Locale]['save_object_desc'])
mapmakerMenu:AddItem(saveObject)
saveObject.Activated = function(sender, index)
if object ~= nil then
local hashKey = GetHashKey(object)
local coords = GetEntityCoords(object)
local heading = GetEntityHeading(object)
TriggerServerEvent('mapbuilder:syncObject', objectHash, coords, heading, isFrozen)
TriggerServerEvent('mapbuilder:saveToDatabase', selectedObject, coords, heading, isFrozen, desc)
DeleteObject(object)
object = nil
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
end
end
spawnObjectFinal.Activated = function(sender, index)
if Config.useNativeUIReloaded then
spawnObject_sub.SubMenu:Visible(false)
else
spawnObject_sub:Visible(false)
end
playerCoords = GetEntityCoords(PlayerPedId())
playerHeading = GetEntityHeading(PlayerPedId())
if object ~= nil then
DeleteObject(object)
end
objectHash = selectedObjectHash
object = CreateObject(selectedObjectHash, playerCoords.x, playerCoords.y, playerCoords.z-1, false, true, true)
SetEntityHeading(object, playerHeading+180)
PlaceObjectOnGroundProperly(object)
FreezeEntityPosition(object, isFrozen)
-- turn mode
AddTextEntry('text',
Translation[Config.Locale]['controls'] ..'~n~~' .. Config.Controls.turnright.name .. '~' .. Translation[Config.Locale]['turn_right'] .. '~n~~'
.. Config.Controls.turnleft.name .. '~' .. Translation[Config.Locale]['turn_left'] .. '~n~~'
.. Config.Controls.fast.name .. '~' .. Translation[Config.Locale]['turn_fast'] .. '~n~~'
.. Config.Controls.slow.name .. '~' .. Translation[Config.Locale]['turn_slow'] .. '~n~~'
.. Config.Controls.finish.name .. '~' .. Translation[Config.Locale]['back_to_menu'] .. '~n~~'
)
while true do
Wait(0)
BeginTextCommandDisplayHelp('text')
EndTextCommandDisplayHelp(false, false, false, -1)
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.turnright.key) then
SetEntityHeading(object, GetEntityHeading(object)+0.1)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.turnright.key) then
SetEntityHeading(object, GetEntityHeading(object)+10)
elseif IsControlJustPressed(0, Config.Controls.turnright.key) then
SetEntityHeading(object, GetEntityHeading(object)+1)
end
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.turnleft.key) then
SetEntityHeading(object, GetEntityHeading(object)-0.1)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.turnleft.key) then
SetEntityHeading(object, GetEntityHeading(object)-10)
elseif IsControlJustPressed(0, Config.Controls.turnleft.key) then
SetEntityHeading(object, GetEntityHeading(object)-1)
end
if IsControlJustPressed(0, Config.Controls.finish.key) then
turnObjectItem:RightLabel('~g~')
moveObjectItem:RightLabel('~g~')
mapmakerMenu:Visible(true)
break
end
end
end
mapmakerMenu:Visible(not mapmakerMenu:Visible())
_menuPool:MouseControlsEnabled(false)
_menuPool:MouseEdgeEnabled(false)
_menuPool:ControlDisablingEnabled(false)
end
RegisterCommand("selectObject", function(source, args, rawCommand)
if GetHashKey(args[1]) ~= nil then
enterObject:RightLabel('~g~' .. args[1])
selectedObjectHash = GetHashKey(args[1])
selectedObject = args[1]
if Config.useNativeUIReloaded then
spawnObject_sub.SubMenu:Visible(true)
else
spawnObject_sub:Visible(true)
end
else
ShowNotification(Translation[Config.Locale]['invalid_object'])
if Config.useNativeUIReloaded then
spawnObject_sub.SubMenu:Visible(true)
else
spawnObject_sub:Visible(true)
end
end
end, false)
RegisterNetEvent('mapbuilder:spawnObject')
AddEventHandler('mapbuilder:spawnObject', function(hash, loc, heading, freeze)
local lastObj = CreateObject(hash, loc.x, loc.y, loc.z, false, true, true)
Citizen.Wait(25)
SetEntityCoords(lastObj, loc.x, loc.y, loc.z)
FreezeEntityPosition(lastObj, freeze)
SetEntityHeading(lastObj, heading)
--PlaceObjectOnGroundProperly(lastObj)
end)
RegisterNetEvent('mapbuilder:updateObject')
AddEventHandler('mapbuilder:updateObject', function(objectID, loc, heading, freeze)
for k, v in pairs(spawnedObjects) do
if v.id == objectID then
DeleteObject(v.entity)
local lastObj = CreateObject(GetHashKey(v.objectHash), loc.x, loc.y, loc.z, false, true, true)
Citizen.Wait(25)
SetEntityCoords(lastObj, loc.x, loc.y, loc.z)
FreezeEntityPosition(lastObj, freeze)
SetEntityHeading(lastObj, heading)
--PlaceObjectOnGroundProperly(lastObj)
v.entity = lastObj
v.locX = loc.x
v.locY = loc.y
v.locZ = loc.z
v.heading = heading
v.freeze = freeze
break
end
end
end)
function ShowNotification(text)
SetNotificationTextEntry('STRING')
AddTextComponentString(text)
DrawNotification(false, true)
end
function spawnObject(objectHash, locX, locY, locZ, heading, freeze)
local sObject = CreateObject(GetHashKey(objectHash), locX, locY, locZ, false, true, true)
Citizen.Wait(25)
SetEntityCoords(sObject, locX, locY, locZ)
SetEntityHeading(sObject, heading)
--PlaceObjectOnGroundProperly(sObject)
FreezeEntityPosition(sObject, freeze)
return sObject
end
--only for standalone
RegisterNetEvent('mapbuilder:getPerm')
AddEventHandler('mapbuilder:getPerm', function(steamID, whitelisted, admin)
isWhitelisted = whitelisted
isAdmin = admin
mySteamID = steamID
end)
RegisterNetEvent('mapbuilder:deleteObject')
AddEventHandler('mapbuilder:deleteObject', function(objectID, hash)
for k, v in pairs(spawnedObjects) do
if v.id == objectID then
if v.objectHash == hash then
DeleteObject(v.entity)
table.remove(spawnedObjects, k)
end
end
end
end)
function turnObject(objectRes, menu)
menu:Visible(false)
AddTextEntry('text',
Translation[Config.Locale]['controls'] ..'~n~~' .. Config.Controls.turnright.name .. '~' .. Translation[Config.Locale]['turn_right'] .. '~n~~'
.. Config.Controls.turnleft.name .. '~' .. Translation[Config.Locale]['turn_left'] .. '~n~~'
.. Config.Controls.fast.name .. '~' .. Translation[Config.Locale]['turn_fast'] .. '~n~~'
.. Config.Controls.slow.name .. '~' .. Translation[Config.Locale]['turn_slow'] .. '~n~~'
.. Config.Controls.finish.name .. '~' .. Translation[Config.Locale]['back_to_menu'] .. '~n~~'
)
while true do
Wait(0)
BeginTextCommandDisplayHelp('text')
EndTextCommandDisplayHelp(false, false, false, -1)
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.turnright.key) then
SetEntityHeading(objectRes, GetEntityHeading(objectRes)+0.1)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.turnright.key) then
SetEntityHeading(objectRes, GetEntityHeading(objectRes)+10)
elseif IsControlJustPressed(0, Config.Controls.turnright.key) then
SetEntityHeading(objectRes, GetEntityHeading(objectRes)+1)
end
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.turnleft.key) then
SetEntityHeading(objectRes, GetEntityHeading(objectRes)-0.1)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.turnleft.key) then
SetEntityHeading(objectRes, GetEntityHeading(objectRes)-10)
elseif IsControlJustPressed(0, Config.Controls.turnleft.key) then
SetEntityHeading(objectRes, GetEntityHeading(objectRes)-1)
end
if IsControlJustPressed(0, Config.Controls.finish.key) then
menu:Visible(true)
break
end
end
end
function moveObject(objectRes, menu)
menu:Visible(false)
AddTextEntry('text',
Translation[Config.Locale]['controls'] ..'~n~~' .. Config.Controls.moveright.name .. '~' .. Translation[Config.Locale]['move_right'] .. '~n~~'
.. Config.Controls.moveleft.name .. '~' .. Translation[Config.Locale]['move_left'] .. '~n~~'
.. Config.Controls.moveup.name .. '~' .. Translation[Config.Locale]['move_forward'] .. '~n~~'
.. Config.Controls.movedown.name .. '~' .. Translation[Config.Locale]['move_backwards'] .. '~n~~'
.. Config.Controls.fast.name .. '~' .. Translation[Config.Locale]['move_fast'] .. '~n~~'
.. Config.Controls.slow.name .. '~' .. Translation[Config.Locale]['move_slow'] .. '~n~~'
.. Config.Controls.finish.name .. '~' .. Translation[Config.Locale]['back_to_menu'] .. '~n~~'
)
while true do
Wait(0)
BeginTextCommandDisplayHelp('text')
EndTextCommandDisplayHelp(false, false, false, -1)
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.moveright.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x+0.1, coords.y, coords.z)
PlaceObjectOnGroundProperly(objectRes)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.moveright.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x+1, coords.y, coords.z)
PlaceObjectOnGroundProperly(objectRes)
elseif IsControlJustPressed(0, Config.Controls.moveright.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x+.05, coords.y, coords.z)
PlaceObjectOnGroundProperly(objectRes)
end
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.moveleft.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x-0.1, coords.y, coords.z)
PlaceObjectOnGroundProperly(objectRes)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.moveleft.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x-1, coords.y, coords.z)
PlaceObjectOnGroundProperly(objectRes)
elseif IsControlJustPressed(0, Config.Controls.moveleft.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x-0.5, coords.y, coords.z)
PlaceObjectOnGroundProperly(objectRes)
end
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.moveup.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y+0.1, coords.z)
PlaceObjectOnGroundProperly(objectRes)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.moveup.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y+1, coords.z)
PlaceObjectOnGroundProperly(objectRes)
elseif IsControlJustPressed(0, Config.Controls.moveup.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y+0.5, coords.z)
PlaceObjectOnGroundProperly(objectRes)
end
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.movedown.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y-0.1, coords.z)
PlaceObjectOnGroundProperly(objectRes)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.movedown.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y-1, coords.z)
PlaceObjectOnGroundProperly(objectRes)
elseif IsControlJustPressed(0, Config.Controls.movedown.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y-0.5, coords.z)
PlaceObjectOnGroundProperly(objectRes)
end
if IsControlJustPressed(0, Config.Controls.finish.key) then
menu:Visible(true)
break
end
end
end
function moveUpDown(objectRes, menu)
menu:Visible(false)
AddTextEntry('text',
Translation[Config.Locale]['controls'] ..'~n~~' .. Config.Controls.movehigher.name .. '~' .. Translation[Config.Locale]['move_higher'] .. '~n~~'
.. Config.Controls.movelower.name .. '~' .. Translation[Config.Locale]['move_lower'] .. '~n~~'
.. Config.Controls.fast.name .. '~' .. Translation[Config.Locale]['move_fast'] .. '~n~~'
.. Config.Controls.slow.name .. '~' .. Translation[Config.Locale]['move_slow'] .. '~n~~'
.. Config.Controls.finish.name .. '~' .. Translation[Config.Locale]['back_to_menu'] .. '~n~~'
)
while true do
Wait(0)
BeginTextCommandDisplayHelp('text')
EndTextCommandDisplayHelp(false, false, false, -1)
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.movehigher.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y, coords.z+0.025)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.movehigher.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y, coords.z+0.25)
elseif IsControlJustPressed(0, Config.Controls.movehigher.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y, coords.z+0.125)
end
if IsControlPressed(0, Config.Controls.slow.key) and IsControlJustPressed(0, Config.Controls.movelower.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y, coords.z-0.025)
elseif IsControlPressed(0, Config.Controls.fast.key) and IsControlJustPressed(0, Config.Controls.movelower.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y, coords.z-0.25)
elseif IsControlJustPressed(0, Config.Controls.movelower.key) then
local coords = GetEntityCoords(objectRes)
SetEntityCoords(objectRes, coords.x, coords.y, coords.z-0.125)
end
if IsControlJustPressed(0, Config.Controls.finish.key) then
menu:Visible(true)
break
end
end
end
function KeyboardInput(TextEntry, ExampleText, MaxStringLenght)
AddTextEntry('FMMC_KEY_TIP1', TextEntry)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP1", "", ExampleText, "", "", "", MaxStringLenght)
blockinput = true
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait(0)
end
if UpdateOnscreenKeyboard() ~= 2 then
local result = GetOnscreenKeyboardResult()
Citizen.Wait(500)
blockinput = false
return result
else
Citizen.Wait(500)
blockinput = false
return nil
end
end
+272
View File
@@ -0,0 +1,272 @@
Config = {}
Translation = {}
Config.Locale = 'en'
Config.useNativeUIReloaded = false -- if you want to disable NativeUIReloaded, you have to activate the dependency in fxmanifest.lua!
Config.Command = 'mapbuilder'
Config.defaultObject = 'prop_table_04_chr'
--only for standalone
Config.SteamWhitelist = {
'steam:11000010e6980a7'
}
-- whitelist can only spawn objects from the list
Config.AdminWhitelist = {
'steam:11000010ac71ad7'
}
-- admins can spawn every object and also use the teleport function
Config.Controls = {
-- turn controls
turnright = {
name = 'INPUT_CELLPHONE_RIGHT',
key = 175
},
turnleft = {
name = 'INPUT_CELLPHONE_LEFT',
key = 174
},
-- move controls
moveright = {
name = 'INPUT_CELLPHONE_RIGHT',
key = 175
},
moveleft = {
name = 'INPUT_CELLPHONE_LEFT',
key = 174
},
moveup = {
name = 'INPUT_FRONTEND_UP',
key = 172
},
movedown = {
name = 'INPUT_FRONTEND_DOWN',
key = 173
},
movehigher = {
name = 'INPUT_FRONTEND_UP',
key = 172
},
movelower = {
name = 'INPUT_FRONTEND_DOWN',
key = 173
},
-- general controls
fast = {
name = 'INPUT_FRONTEND_SELECT',
key = 217
},
slow = {
name = 'INPUT_FRONTEND_LS',
key = 209
},
finish = {
name = 'INPUT_CELLPHONE_CAMERA_EXPRESSION',
key = 186
},
}
Config.recommendObjects = {
{object = 'prop_table_para_comb_01', label = 'Table with umbrella'},
{object = 'prop_patio_lounger1', label = 'Patio lounger'},
{object = 'prop_patio_heater_01', label = 'Patio heater'},
{object = 'prop_parasol_01', label = 'Parasol'},
{object = 'prop_table_01', label = 'Table'},
{object = 'prop_table_04_chr', label = 'Chair'},
{object = 'prop_bbq_5', label = 'BBQ'},
}
Translation = {
['en'] = {
['menu_title'] = 'Map Builder',
['get_object_distance'] = 'Placed objects',
['controls'] = 'Controls',
['turn_right'] = ' ~s~to ~b~turn ~s~the object ~b~right',
['turn_left'] = ' ~s~to ~b~turn ~s~the object ~b~left',
['turn_fast'] = ' ~s~to ~b~turn ~s~the object ~b~faster',
['turn_slow'] = ' ~s~to ~b~turn ~s~the object ~b~slower',
['move_forward'] = ' ~s~to ~b~move ~s~the object ~b~forwards',
['move_backwards'] = ' ~s~to ~b~move ~s~the object ~b~backwards',
['move_right'] = ' ~s~to ~b~move ~s~the object ~b~right side',
['move_left'] = ' ~s~to ~b~move ~s~the object ~b~left side',
['move_fast'] = ' ~s~to ~b~move ~s~the object ~b~faster',
['move_slow'] = ' ~s~to ~b~move ~s~the object ~b~slower',
['move_higher'] = ' ~s~to ~b~move ~s~the object ~b~up',
['move_lower'] = ' ~s~to ~b~move ~s~the object ~b~down',
['back_to_menu'] = ' ~s~to go ~b~back ~s~to main menu',
['spawn_object'] = 'Spawn object',
['spawn_object_final'] = '~g~Spawn object',
['spawn_object_final_desc'] = '~g~Object will be created at your current location',
['move_object'] = 'Move object',
['turn_object'] = 'Turn object',
['delete_object'] = '~r~Delete object',
['delete_object_desc'] = 'Delete object from map',
['save_object'] = '~g~Save object',
['save_object_desc'] = 'Save object to your database',
['enter_objectname'] = 'Object:',
['enter_objectname_desc'] = 'Click to enter an object name',
['moveupdown_object'] = 'Move object up and down',
['obj_tp'] = 'Teleport',
['obj_tp_desc'] = 'Teleport to this object',
['obj_hide'] = 'Hide',
['obj_hide_desc'] = 'Hide this object (only for you)',
['obj_replace'] = '(Re-)Spawn',
['obj_replace_desc'] = 'Spawns this object again (Undo Hide)',
['obj_already_exists'] = '~r~The object is still there. Hide it first and then you could respawn it.',
['obj_permdelete_desc'] = 'The object will be permanently removed from database!',
['obj_removed'] = '~g~The object was removed from database.',
['obj_savechanges'] = '~g~Save changes.',
['obj_savechanges_desc'] = 'Your changes will be saved and applied for all players.',
['obj_saved'] = '~g~Your changes were saved!',
['set_moveable'] = 'Freeze object?',
['set_moveable_desc'] = 'Should it be possible to push/move this object?',
['moveable_state_changed'] = '~g~Freeze state changed to ~w~',
['set_description'] = 'Description',
['set_description_desc'] = 'Makes it easier to find your object in the menu.',
['recommend_objects'] = 'Recommend objects',
['recommend_objects_desc'] = 'List of useful objects',
['selectObject_help'] = 'Now enter your object using ~y~/selectObject [~g~OBJECT~y~]~s~.',
['invalid_object'] = '~r~Invalid object!',
['no_object'] = '~r~No object!',
},
['de'] = {
['menu_title'] = 'Map Builder',
['get_object_distance'] = 'Platzierte Objekte',
['controls'] = 'Bedienung',
['turn_right'] = ' ~s~um das Objekt ~b~nach rechts ~s~zu drehen',
['turn_left'] = ' ~s~um das Objekt ~b~nach links ~s~zu drehen',
['turn_fast'] = ' ~s~um das Objekt ~b~schneller ~s~zu drehen',
['turn_slow'] = ' ~s~um das Objekt ~b~langsamer ~s~zu drehen',
['move_forward'] = ' ~s~um das Objekt nach ~b~vorne ~s~zu ~b~bewegen.',
['move_backwards'] = ' ~s~um das Objekt nach ~b~hinten ~s~zu ~b~bewegen.',
['move_right'] = ' ~s~um das Objekt nach ~b~rechts ~s~zu ~b~bewegen.',
['move_left'] = ' ~s~um das Objekt nach ~b~links ~s~zu ~b~bewegen.',
['move_fast'] = ' ~s~um das Objekt ~b~schneller ~s~zu ~b~bewegen.',
['move_slow'] = ' ~s~um das Objekt ~b~langsamer ~s~zu ~b~bewegen.',
['move_lower'] = ' ~s~um das Objekt ~b~nach unten ~s~zu ~b~bewegen.',
['move_higher'] = ' ~s~um das Objekt ~b~nach oben ~s~zu ~b~bewegen.',
['back_to_menu'] = ' ~s~um zum ~b~Hauptmenu ~s~zurückzukehren.',
['only_for_admins'] = '~r~Nur Admins können beliebige Objekte verwenden!',
['spawn_object'] = 'Objekt spawnen',
['spawn_object_final'] = '~g~Objekt spawnen',
['spawn_object_final_desc'] = '~g~Das Objekt wird an deiner Position spawnen',
['move_object'] = 'Objekt bewegen',
['turn_object'] = 'Objekt drehen',
['delete_object'] = '~r~Objekt löschen',
['delete_object_desc'] = 'Lösche das Objekt',
['save_object'] = '~g~Objekt speichern',
['save_object_desc'] = 'Speichert das Objekt in der Datenbank',
['enter_objectname'] = 'Objekt:',
['enter_objectname_desc'] = 'Klicke, um eine Beschreibung hinzuzufügen',
['moveupdown_object'] = 'Höhe verändern',
['obj_tp'] = 'Teleport',
['obj_tp_desc'] = 'Teleportiere dich zu diesem Objekt',
['obj_hide'] = 'Ausblebende',
['obj_hide_desc'] = 'Blende das Objekt aus (Nur für dich unsichtbar)',
['obj_replace'] = 'Einblenden',
['obj_replace_desc'] = 'Blende das Objekt wieder ein',
['obj_already_exists'] = '~r~Das Objekt sollte noch sichtbar sein.',
['obj_permdelete_desc'] = 'Das Objekt wird permanent aus der Datenbank gelöscht!',
['obj_removed'] = '~g~Das Objekt wurde aus der Datenbank entfernt.',
['obj_savechanges'] = '~g~Änderungen speichern.',
['obj_savechanges_desc'] = 'Deine Änderungen werden gespeichert und für alle Spieler synchronisiert.',
['obj_saved'] = '~g~Deine Änderungen wurden gespeichert!',
['set_moveable'] = 'Objekt einfrieren?',
['set_moveable_desc'] = 'Soll das Objekt bewegt werden können?',
['moveable_state_changed'] = '~g~Freeze-Status geändert: ~w~',
['set_description'] = 'Kommentar',
['set_description_desc'] = 'Dadurch kann das Objekt leichter wiedergefunden werden.',
['recommend_objects'] = 'Verfügbare Objekte',
['recommend_objects_desc'] = 'Nützliche Objekte',
['select_object_desc'] = 'Objekt kaufen~b~',
['selectObject_help'] = 'Wähle ein anderen Objekt mit ~y~/selectObject [~g~OBJECT~y~]~s~ aus.',
['invalid_object'] = '~r~Unbekanntes Objekt!',
['not_enough_money'] = '~r~Du hast nicht genügend Geld!',
['no_object'] = '~r~Kein Objekt!',
['cant_save'] = '~r~Änderungen nicht gespeichert! Bitte starte das Spiel neu.',
},
['es'] = {
['menu_title'] = 'Constructor de Mapas',
['get_object_distance'] = 'Objetos colocados',
['controls'] = 'Controles',
['turn_right'] = ' ~s~para ~b~girar ~s~el objeto a la ~b~derecha',
['turn_left'] = ' ~s~para ~b~girar ~s~el objeto ~b~Izquierda',
['turn_fast'] = ' ~s~para ~b~girar ~s~el objeto ~b~rapido',
['turn_slow'] = ' ~s~para ~b~girar ~s~el objeto ~b~lento',
['move_forward'] = ' ~s~para ~b~mover ~s~el objeto ~b~hacia adelante',
['move_backwards'] = ' ~s~para ~b~mover ~s~el objeto ~b~hacia atrás',
['move_right'] = ' ~s~para ~b~mover ~s~el objeto ~b~lado derecho',
['move_left'] = ' ~s~para ~b~mover ~s~el objeto ~b~lado izquierdo',
['move_fast'] = ' ~s~para ~b~mover ~s~el objeto ~b~rapido',
['move_slow'] = ' ~s~para ~b~mover ~s~el objeto ~b~lento',
['move_higher'] = ' ~s~para ~b~mover ~s~el objeto ~b~arriba',
['move_lower'] = ' ~s~para ~b~mover ~s~el objeto ~b~hacia abajo',
['back_to_menu'] = ' ~s~para ~b~volver ~s~al menu principal',
['only_for_admins'] = '~r~¡Esta función solo puede ser utilizada por miembros del personal aministrativo!',
['spawn_object'] = 'Carear objeto',
['spawn_object_final'] = '~g~Crear Objeto',
['spawn_object_final_desc'] = '~g~El objeto se creará en su ubicación actual',
['move_object'] = 'Mover objeto',
['turn_object'] = 'Girar objeto',
['delete_object'] = '~r~Eliminar objeto',
['delete_object_desc'] = 'Eliminar objeto del mapa',
['save_object'] = '~g~Guardar objeto',
['save_object_desc'] = 'Guarde el objeto en su base de datos',
['enter_objectname'] = 'Objeto:',
['enter_objectname_desc'] = 'Haga clic para ingresar un nombre de objeto',
['moveupdown_object'] = 'Arriba y abajo',
['obj_tp'] = 'Teletransportarse',
['obj_tp_desc'] = 'Teletransportarse a este objeto',
['obj_hide'] = 'Ocultar',
['obj_hide_desc'] = 'Ocultar este objeto (solo para ti)',
['obj_replace'] = '(Re-)Spawn',
['obj_replace_desc'] = 'Genera este objeto de nuevo (Deshacer Ocultar)',
['obj_already_exists'] = '~r~El objeto sigue ahí. Escóndelo primero y luego podrás reaparecer.',
['obj_permdelete_desc'] = '¡El objeto se eliminará permanentemente de la base de datos!',
['obj_removed'] = '~g~El objeto fue eliminado de la base de datos.',
['obj_savechanges'] = '~g~Guardar cambios.',
['obj_savechanges_desc'] = 'Tus cambios se guardarán y se aplicarán a todos los jugadores.',
['obj_saved'] = '~g~¡Se guardaron sus cambios!',
['set_moveable'] = '¿Congelar objeto?',
['set_moveable_desc'] = '¿Debería ser posible empujar / mover este objeto?',
['moveable_state_changed'] = '~g~El estado de congelación cambió a ~w~',
['set_description'] = 'Descripción',
['set_description_desc'] = 'Facilita la búsqueda de su objeto en el menú.',
['recommend_objects'] = 'Objetos disponibles',
['recommend_objects_desc'] = 'Lista de objetos útiles',
['select_object_desc'] = 'Comprar objeto ~b~',
['selectObject_help'] = 'Ahora ingrese su objeto usando ~y~/selectObject [~g~OBJECT~y~]~s~.',
['invalid_object'] = '~r~¡Objeto inválido!',
['not_enough_money'] = '~r~¡No tienes suficiente dinero!',
['no_object'] = '~r~Sin objeto!',
['cant_save'] = '~r~¡El objeto no se guardó! Reinicia tu juego para editar este objeto.',
},
}
+16
View File
@@ -0,0 +1,16 @@
fx_version 'bodacious'
game 'gta5'
server_scripts {
'@mysql-async/lib/MySQL.lua',
'config.lua',
'server.lua',
}
client_scripts {
--"@NativeUILua_Reloaded/src/NativeUIReloaded.lua", -- disable this when you do not want to use NativeUIReloaded
'@NativeUI/NativeUI.lua', -- if you want to use NativeUI instead of NativeUI Reloaded -> Activate this!
'config.lua',
'client.lua',
}
+89
View File
@@ -0,0 +1,89 @@
RegisterServerEvent('mapbuilder:syncObject')
AddEventHandler('mapbuilder:syncObject', function(hash, loc, heading, freeze)
print('sync ' .. hash .. loc .. heading)
TriggerClientEvent('mapbuilder:spawnObject', -1, hash, loc, heading, freeze)
end)
RegisterServerEvent('mapbuilder:syncObjectRemove')
AddEventHandler('mapbuilder:syncObjectRemove', function(objectID, hash)
TriggerClientEvent('mapbuilder:deleteObject', -1, objectID, hash)
end)
RegisterServerEvent('mapbuilder:saveToDatabase')
AddEventHandler('mapbuilder:saveToDatabase', function(hash, loc, heading, freeze, comment)
local identifier = GetPlayerIdentifiers(source)[1]
MySQL.Async.execute(
'INSERT INTO mapbuilder (objectHash, locX, locY, locZ, heading, freeze, createdBy, comment) VALUES (@objectHash, @locX, @locY, @locZ, @heading, @freeze, @createdBy, @comment)', {
['@objectHash'] = hash,
['@locX'] = loc.x,
['@locY'] = loc.y,
['@locZ'] = loc.z,
['@heading'] = heading,
['@freeze'] = freeze,
['@createdBy'] = identifier,
['@comment'] = comment,
})
end)
RegisterServerEvent('mapbuilder:removeFromDatabase')
AddEventHandler('mapbuilder:removeFromDatabase', function(objectID, hash)
MySQL.Async.execute(
'DELETE FROM mapbuilder WHERE id = @id and objectHash = @objectHash', {
['@id'] = objectID,
['@objectHash'] = hash,
})
end)
RegisterServerEvent('mapbuilder:updateObject')
AddEventHandler('mapbuilder:updateObject', function(objectID, loc, heading, freeze)
MySQL.Async.execute(
'UPDATE mapbuilder SET locX = @locX, locY = @locY, locZ = @locZ, heading = @heading, freeze = @freeze WHERE id = @id', {
['@id'] = objectID,
['@locX'] = loc.x,
['@locY'] = loc.y,
['@locZ'] = loc.z,
['@heading'] = heading,
['@freeze'] = freeze,
})
TriggerClientEvent('mapbuilder:updateObject', -1, objectID, loc, heading, freeze)
end)
-- no callback to avoid using ESX
RegisterServerEvent('mapbuilder:getObjects')
AddEventHandler('mapbuilder:getObjects', function()
local _source = source
local steamID = GetPlayerIdentifiers(_source)[1]
MySQL.Async.fetchAll('SELECT * FROM mapbuilder', {},
function(result)
if #result > 0 then
TriggerClientEvent('mapbuilder:receiveObjects', _source, result)
end
end
)
local isWhitelisted = false
for k, v in pairs(Config.SteamWhitelist) do
if v == steamID then
isWhitelisted = true
break
end
end
local isAdmin = false
for k, v in pairs(Config.AdminWhitelist) do
if v == steamID then
isAdmin = true
break
end
end
TriggerClientEvent('mapbuilder:getPerm', _source, steamID, isWhitelisted, isAdmin)
end)