New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maxed out skills resets while testing map #131
Comments
As far I know this only happens with Freeroam but I didn't test another gamemodes. Anyway, set race gamemode on map settings and then leave test mode, stats does not reset. Very weird, huh? |
Here's the line actually causing that issue: click me |
That doesn't look like the problem. Check out that defaultstats will give you the max ammount of biking ability, but when using the editor sh4z4n said that the maxed out skills resets, probably because defaultstats just stops. Even if it was reseting your stats at every freeroam start, you will have 999 biking skill anyway, and you should be able to make really high jumps with that. For your question, it seems that |
yeah, just noticed that, i guess i just miss-read the initial problem. gonna check again. |
Something weird is going on.. facts:
if defaultstats stops, then it will stop applying the defined stats when it's supposed to, but not set all stats to zero. This is what currently (per this bug) happens, and the reset stats apply to more than just bikes: everything, including that in map editor you'll be aiming down the sights like this: Theory 1: function isGamemode(resource)
if type(resource) ~= "userdata" then
return false
end
return (getResourceInfo(resource,"type") == "gamemode")
end
function isMap(resource)
if type(resource) ~= "userdata" then --!w
return false
end
return (getResourceInfo(resource,"type") == "map")
end I believe they are malfunctioning as "defaultstats" doesn't currently have any "type" defined in its meta.xml which means it shouldn't return true, but under the circumstances of this issue (when called by editor), return true which leads to the resource mistakenly stopping. The reason for this isn't immediately clear to me. But most of all, while I was reproducing i found that this is only the case when you do this:
in "Host game" mode (main menu), and the problem isn't there (stats won't be nulled) when you run MTA Server.exe and perform the same steps. The reason these utility functions or something else fails only with "Host game" is yet to be investigated The reason for stats being nulled (which like I said, normally doesn't happen when "defaultstats" stops).. my guess: Update 1: while writing this post, I suddenly stopped being able to reproduce the issue at all (even after restoring all resources to default).. both in "Host game" and MTA Server. So all of this can happen randomly.. what I noticed though, is that in my case it only happened when this: Not done debugging yet, but this all means the problem might be deeper (or perhaps in MTA) Update 2 (and Theory 2): the script that outputs above message: editor_main/server/freeroam.lua has been updated in b53f42b and with this update, my reproduction rate seems to be zero. The moment i reverted it to the old revision which had a serious syntax mistake in it:
.. i reproduced it a few times instantly. But then it started being random again, not always reproducing. So, i wonder if it's possible if this incorrect usage of getResourceFromName (missing parentheses) could result in undefined behavior due to scripting function implementation, of which the undefined behavior can result in a chance it will grab another resource, in this case stopping "defaultstats" and maybe even corrupting things like zero'ing what it set (the stats). This would mean people that haven't got the latest version of resources can run into this issue. |
I edited the above comment significantly, and i want to re-iterate that I am looking for the root cause this deep because of the following: Nowhere in the code of editor (or anywhere else) is there something that would cause all stats to be nulled (as if "defaultstats" never ran to set new values), stopping "defaultstats" normally doesn't null the stats (literally to 0 value, even worse than GTA defaults). This would only happen if "defaultstats" hasn't run at least once while the player was connected.. so yeah, something is funky, probably within MTA itself and not the resources. |
There are 2 issues I found in both
default mtaserver.conf and the importance of resource load orderWhen using a lot of resources that talk to eachother, I have found a lot of interesting things. Sometimes your function works, and sometimes it doesn't. the phrase have you tried turning it off and on again somehow does the trick.. but why? The answer: resource load order. in the default <resource src="admin" startup="1" protected="0" />
<resource src="defaultstats" startup="1" protected="0" />
<resource src="helpmanager" startup="1" protected="0" />
<resource src="joinquit" startup="1" protected="0" />
<resource src="mapcycler" startup="1" protected="0" />
<resource src="mapmanager" startup="1" protected="0" />
<resource src="parachute" startup="1" protected="0" />
<resource src="resourcebrowser" startup="1" protected="1" default="true" />
<resource src="resourcemanager" startup="1" protected="1" />
<resource src="scoreboard" startup="1" protected="0" />
<resource src="spawnmanager" startup="1" protected="0" />
<resource src="voice" startup="1" protected="0" />
<resource src="votemanager" startup="1" protected="0" />
<resource src="webadmin" startup="1" protected="0" />
<resource src="play" startup="1" protected="0" /> Neatly packed in alphabetical order, this list is But why?!Resource load order is important. Since some resources are depending on other resources. mapmanager_main.luacurrentGamemode = nil
currentGamemodeMap = nil
nextGamemode = nil
nextGamemodeMap = nil
setGameType(false)
setMapName("None")
addEvent("onGamemodeStart") --> now it is registered, any resources that has an eventHandler already defined before the resource started, they are nothing but sad empty stubs.
addEvent("onGamemodeStop")
addEvent("onGamemodeMapStart") --> This is the current event used
addEvent("onGamemodeMapStop") defaultstats.lualocal function applyStatsForEveryone()
local playersTable = getElementsByType("player")
for playerID = 1, #playersTable do
applyStatsForPlayer(playersTable[playerID])
end
end
addEventHandler("onResourceStart", resourceRoot, applyStatsForEveryone)
addEventHandler("onGamemodeStart", root, applyStatsForEveryone)
-- > adds event before mapmanager loads, throws an exception to root (we cannot see) Since the PR will follow soonI got the changes ready, just got to make a PR. I'll leave this here, and tell you where you should put the <resource src="admin" startup="1" protected="0" />
<!-- <resource src="defaultstats" startup="1" protected="0" /> --> <!-- default -->
<resource src="helpmanager" startup="1" protected="0" />
<resource src="joinquit" startup="1" protected="0" />
<resource src="mapcycler" startup="1" protected="0" /> <!-- mapmanager is included here -->
<resource src="defaultstats" startup="1" protected="0" /> <!-- where it should be (at least) -->
<resource src="mapmanager" startup="1" protected="0" /> <!-- where the events are added -->
<resource src="parachute" startup="1" protected="0" />
<resource src="resourcebrowser" startup="1" protected="1" default="true" />
<resource src="resourcemanager" startup="1" protected="1" />
<resource src="scoreboard" startup="1" protected="0" />
<resource src="spawnmanager" startup="1" protected="0" />
<resource src="voice" startup="1" protected="0" />
<resource src="votemanager" startup="1" protected="0" />
<resource src="webadmin" startup="1" protected="0" />
<resource src="play" startup="1" protected="0" /> |
Fixed via #471 |
Which resource(s) have this problem?
defaultstats
To Reproduce
Steps to reproduce the behaviour:
Now repeat the same steps of number 2.
Expected behaviour
Everytime Freeroam starts after press Full Test your maxed out skills resets because defaultstats automatically stop so you can't do bicycle high jump or shoot while walking, for example.
The text was updated successfully, but these errors were encountered: