Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions [gameplay]/hedit/meta.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<meta>
<info type="script" name="Ingame Handling Editor" author="Remi-X" version="2.1.5" description="The first ingame handling editor for MTA!" />
<info type="script" name="Ingame Handling Editor" author="Remi-X, MTA contributors (github.com/multitheftauto/mtasa-resources)" version="2.1.6" description="The first ingame handling editor for MTA!" />
<oop>true</oop>
<min_mta_version server="1.4.0" client="1.4.0" />
<min_mta_version server="1.6.0-9.22815" client="1.6.0-9.22815" />

<!-- SHARED -->
<script src="shared/variables/general.lua" type="shared" />
Expand Down
24 changes: 12 additions & 12 deletions [gameplay]/hedit/server/cfgloader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function loadCFGIntoMemory ( cfgstr )
waitForLine = false

if addingEntry then
print ( "[HEDIT] Error while adding line #"..tostring(#lines)..", invalid character found: "..token )
outputDebugString ( "[HEDIT] Error while adding line #"..tostring(#lines)..", invalid character found: "..token, 1)
table.remove ( lines, #lines )
addingEntry = false
end
Expand Down Expand Up @@ -63,18 +63,18 @@ function loadCFGIntoMemory ( cfgstr )


if #lines > 0 then
print ( "[HEDIT] Loaded "..tostring(#lines).." handling entries from "..tostring(string.len(cfgstr)).." bytes into the memory." )
print ( "[HEDIT] Type 'exportcfg' to import the handling entries into defaults.xml." )
print ( "[HEDIT] This may take some time." )
outputDebugString ( "[HEDIT] Loaded "..tostring(#lines).." handling entries from "..tostring(string.len(cfgstr)).." bytes into the memory." )
outputDebugString ( "[HEDIT] Type 'exportcfg' to import the handling entries into defaults.xml." )
outputDebugString ( "[HEDIT] This may take some time." )

addCommandHandler ( "exportcfg", function ( player )

if getElementType ( player ) ~= "console" then
return false
end

print ( "[HEDIT] Importing "..line.." handling entries into defaults.xml." )
print ( "[HEDIT] This may take a while. Please wait." )
outputDebugString ( "[HEDIT] Importing "..line.." handling entries into defaults.xml." )
outputDebugString ( "[HEDIT] This may take a while. Please wait." )

setTimer ( function ( )
exportToDefaults ( lines )
Expand All @@ -85,8 +85,8 @@ function loadCFGIntoMemory ( cfgstr )
return true
end

print ( "[HEDIT] No handling entries found in "..tostring(string.len(cfgstr)).." bytes!")
print ( "[HEDIT] Make sure handling.cfg is correct and try again." )
outputDebugString ( "[HEDIT] No handling entries found in "..tostring(string.len(cfgstr)).." bytes!", 2)
outputDebugString ( "[HEDIT] Make sure handling.cfg is correct and try again.", 2 )

return true
end
Expand All @@ -113,7 +113,7 @@ function exportToDefaults ( linetabs )

if id == 1 then
if not tonumber ( value ) then
print ( "[HEDIT] Handling line #"..tostring(num).." is invalid, can't import!" )
outputDebugString ( "[HEDIT] Handling line #"..tostring(num).." is invalid, can't import!", 1 )
break
end

Expand Down Expand Up @@ -156,8 +156,8 @@ addCommandHandler ( "loadcfg", function ( player )

fileClose ( cfgFile )

print ( "[HEDIT] handling.cfg has been read." )
print ( "[HEDIT] Please wait while loading the lines into the memory." )
outputDebugString ( "[HEDIT] handling.cfg has been read." )
outputDebugString ( "[HEDIT] Please wait while loading the lines into the memory." )

setTimer ( function ( )
loadCFGIntoMemory ( str )
Expand All @@ -166,6 +166,6 @@ addCommandHandler ( "loadcfg", function ( player )
return true
end

print ( "[HEDIT] No handling.cfg found. Make sure it's in the root of this resource." )
outputDebugString ( "[HEDIT] No handling.cfg found. Make sure it's in the root of this resource.", 2 )
return false
end )
19 changes: 3 additions & 16 deletions [gameplay]/hedit/server/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,21 @@ addEventHandler ( "onResourceStart", resourceRoot, function ( )

local resName = getResourceName ( resource )

setElementData(resourceRoot, "resourceVersion", getResourceInfo(resource, "version"))

if resName ~= "hedit" and not DEBUGMODE then
outputChatBox ( "Handling Editor failed to start, see the logs for more information." )
print ( "===============================================================================" )
print ( "[HEDIT] Please rename resource '"..resName.."' to 'hedit' to use the handling editor." )
print ( "[HEDIT] The handling editor will not work unless you rename the resource to 'hedit'." )
print ( "===============================================================================" )
outputDebugString ( "[HEDIT] Please rename resource '"..resName.."' to 'hedit' to use the handling editor.", 1)
return cancelEvent ( true, "Rename the handling editor resource to 'hedit' in order to use the resource." )
end


print ( "===============================================================================" )
print ( " MTA:SA HANDLING EDITOR [hedit.github.io]" )
print ( "===============================================================================" )
if fileExists ( "handling.cfg" ) then
print ( " Handling.cfg found." )
print ( " Type 'loadcfg' to load handling.cfg into the memory." )
print ( " After this, you can import the handling into defaults.xml." )
print ( "===============================================================================" )
outputDebugString ( "[HEDIT] Handling.cfg found; type 'loadcfg' to load handling.cfg into the memory.")
end

--Parse meta settings
parseMetaSettings()
addEventHandler("onSettingChange", root, parseMetaSettings)

for model=400,611 do
setElementData ( root, "originalHandling."..tostring ( model ), getOriginalHandling ( model, true ) )
setElementData ( resourceRoot, "hedit:originalHandling."..tostring ( model ), getOriginalHandling ( model, true ), true, "deny" )
end

--initiateCFGLoader ( )
Expand Down
6 changes: 3 additions & 3 deletions [gameplay]/hedit/server/logmanager.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local vehicleLogs = {}

function loadHandlingLog ( )
local data = getElementData ( root, "hedit:vehicleLogs" )
local data = getElementData ( root, "hedit:vehicleLogs" ) -- retrieve stashed vehicleLogs from root element data (if it exists)

if data then
vehicleLogs = data
Expand All @@ -12,7 +12,7 @@ end


function unloadHandlingLog ( )
setElementData ( root, "hedit:vehicleLogs", vehicleLogs, false )
setElementData ( root, "hedit:vehicleLogs", vehicleLogs, false, "deny") -- stash vehicleLogs as root element data so it can be recovered on next start

return true
end
Expand Down Expand Up @@ -109,7 +109,7 @@ function uploadFullLog ( vehicle )
return false
end

triggerClientEvent ( client, "receiveFullLog", client, getElementData(root,"hedit:vehicleLogs")[vehicle] )
triggerClientEvent ( client, "receiveFullLog", client, vehicleLogs[vehicle] )
return true
end
addEvent ( "requestFullLog", true )
Expand Down
3 changes: 1 addition & 2 deletions [gameplay]/hedit/server/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ function parseMetaSettings()
propertySettings[handlingProperty] = tobool(settingExists)
else
propertySettings[handlingProperty] = false
print("Missing setting for "..handlingProperty..", defaulting to false.")
outputDebugString("Missing setting for "..handlingProperty..", defaulting to false.", 2)
end
end
setElementData(resourceRoot, "propertySettings", propertySettings)
setElementData(resourceRoot, "hedit:propertySettings", propertySettings, true, "deny")
end
3 changes: 1 addition & 2 deletions [gameplay]/hedit/shared/settings.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
DEBUGMODE = false

MTAVER = 1.6
HVER = "2.1.5"
HVER = "2.1.6"
10 changes: 5 additions & 5 deletions [gameplay]/hedit/shared/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ end
--This function returns true if a setting is enabled in the meta, false otherwise.
function isHandlingPropertyEnabled(property)
if getLocalPlayer then
return (getElementData(resourceRoot, "propertySettings", false)[property]) or true
return (getElementData(resourceRoot, "hedit:propertySettings", false)[property]) or true
else
return tobool(get("*enable_"..property))
end
Expand Down Expand Up @@ -330,7 +330,7 @@ function getHandlingPreviousValue ( vehicle, property )
return false
end

return getElementData ( vehicle, "hedit:vehiclepreviousvalue."..property )
return getElementData ( vehicle, "hedit:vehiclepreviousvalue."..property, false )
end


Expand All @@ -344,7 +344,7 @@ function setVehicleSaved ( vehicle, saved )
return true
end

setElementData ( vehicle, "hedit:saved", tostring ( saved ) )
setElementData ( vehicle, "hedit:saved", tostring ( saved ), true, "deny" )

local occupants = getVehicleOccupants ( vehicle )
local seats = getVehicleMaxPassengers ( vehicle )
Expand All @@ -370,8 +370,8 @@ function isVehicleSaved ( vehicle )
return false
end

if not getElementData ( vehicle, "hedit:saved" ) then
setElementData ( vehicle, "hedit:saved", "true" )
if not getElementData ( vehicle, "hedit:saved", false ) then
setElementData ( vehicle, "hedit:saved", "true", true, "deny" )
end

return tobool ( getElementData ( vehicle, "hedit:saved" ) )
Expand Down
8 changes: 4 additions & 4 deletions [gameplay]/hedit/shared/wrappers/general.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ end


_outputDebugString = outputDebugString
function outputDebugString(...)
if DEBUGMODE then
return _outputDebugString(...)
end
function outputDebugString(string, level, r, g, b)
if not level then level = 3 end
if (not DEBUGMODE) and level >= 3 then return end
return _outputDebugString(string, level, r, g, b)
end


Expand Down
4 changes: 2 additions & 2 deletions [gameplay]/hedit/shared/wrappers/handling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function setVehicleHandling ( vehicle, property, value, withLog )
end


setElementData ( vehicle, "hedit:vehiclepreviousvalue."..property, oldValue )
setElementData ( vehicle, "hedit:vehiclepreviousvalue."..property, oldValue, true, "deny" )

triggerEvent ( "onVehicleHandlingChange", client, vehicle, property, oldValue, value )

Expand All @@ -197,7 +197,7 @@ function getOriginalHandling ( model, force )
return nil
end

local data = getElementData ( root, "originalHandling."..tostring(model) )
local data = getElementData ( resourceRoot, "hedit:originalHandling."..tostring(model), false )
if not data or force then
data = conformHandlingTable ( _getOriginalHandling ( model ), model )
end
Expand Down
Loading