koragg Posted December 24, 2017 Share Posted December 24, 2017 (edited) I've seen it been done at one server but even though it's resoures are open-source I found it hard to make it work. Basically I'm looking for a way to see if the currently played map has a custom vehicle model into it. I need this check because I want to disable custom paintjobs/vehicle lights if the player's current vehicle is a modded one (with txd and dff files). Also if the map starts with the modded vehicle but then switches to a normal gtasa vehicle I need paintjobs/lights to work normally. So I'm looking for a way to keep checking if the vehicle is a modded one or not and I'll make it with a setTimer of 50ms. Hope you can help. Merry Christmas to everyone btw Edited December 24, 2017 by koragg Link to comment
Moderators IIYAMA Posted December 24, 2017 Moderators Share Posted December 24, 2017 How about starting with the map meta.xml itself? https://wiki.multitheftauto.com/wiki/Resource:Mapmanager onGamemodeMapStart function loadMap(startedMap) https://wiki.multitheftauto.com/wiki/GetResourceName https://wiki.multitheftauto.com/wiki/XmlLoadFile https://wiki.multitheftauto.com/wiki/XmlNodeGetChildren https://wiki.multitheftauto.com/wiki/XmlNodeGetName Node name: file Attribute: src And check for extensions. Link to comment
koragg Posted December 24, 2017 Author Share Posted December 24, 2017 (edited) 2 hours ago, IIYAMA said: How about starting with the map meta.xml itself? https://wiki.multitheftauto.com/wiki/Resource:Mapmanager onGamemodeMapStart function loadMap(startedMap) https://wiki.multitheftauto.com/wiki/GetResourceName https://wiki.multitheftauto.com/wiki/XmlLoadFile https://wiki.multitheftauto.com/wiki/XmlNodeGetChildren https://wiki.multitheftauto.com/wiki/XmlNodeGetName Node name: file Attribute: src And check for extensions. Not sure how to check for extentions but also what if the vehicle changes from a pickup or on checkpoint hit? Let's say map starts with a modded Sultan, then there is a pickup or checkpoint and it changes to a not modded Infernus, can I somehow know at any point during the race if the current vehicle is a mod or not? Edited December 24, 2017 by koragg Link to comment
Moderators IIYAMA Posted December 24, 2017 Moderators Share Posted December 24, 2017 Option 1. You will have to inject wrapper code in to the map. The meta can identify if it needs the injection yes and no. This could be applied directly after the gamemode has started and before the gamemode map has been loaded. (Option 2) Maybe it helps, maybe it doesn't. (not sure if there are changes in this, when different textures are applied. It might also only return the replacement names, not sure.) I have never used it before. https://wiki.multitheftauto.com/wiki/EngineGetModelTextureNames Link to comment
Slim Posted December 25, 2017 Share Posted December 25, 2017 (edited) If you used MGM, (custom downloader) You could detect this in the map loader with enough experience. Another method would be modding the original infernus.DFF and adding a tag component, for example: (IsModded) Use a script to retrieve all vehicle components, and if the component doesn't exist, it didn't load your tagged model. But depending on what you need this script to do, it would maybe require tagging all vehicle DFF, not only the infernus, which would be a rather large download. Quote onClientRender Clientside event This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them. You could use OnClientRender to constantly check.https://wiki.multitheftauto.com/wiki/SetVehicleComponentVisible Edited December 25, 2017 by Justin|X5| Link to comment
Slim Posted December 26, 2017 Share Posted December 26, 2017 (edited) Sorry for the double post it won't let me edit anymore. Another way you could pull this off would be to modify .DFF and .TXD for which ever cars you're allowing a custom paint job. (I'm assuming only the Infernus will have custom paintjobs because all other vehicles have bad UV mapping, and to fix the UV mapping for all vehicles would be a giant download) So long story short, what I'm saying is just change the texture name from vehiclegrunge256, to something like koragmap instead. So if ANY other vehicle is loaded instead of your custom paint job models, the texture name won't be the same, therefor it won't apply the paint job. I actually did this in my server earlier this year, even with the tail lights, I just forgot Another way get a true/false return, you could even use @IIYAMA's method, and if your custom koragmap texture doesn't exist, your tagged model isn't loaded. You need some experience in zModeler though to change the texture name from vehiclegrunge256 to koragmap, it's not hard, add me to Skype I'll do it for you. [email protected] Edited December 26, 2017 by Justin|X5| It auto corrected my naughty language xD Link to comment
koragg Posted December 26, 2017 Author Share Posted December 26, 2017 (edited) This became way too hard Well my paintjobs script works on all vehicles, literally all so editing the dff would be a huge download and i have no Idea how to do this since I've never used zModeler before. I guess I'll just detect if there are .txd and .dff files in the map's folder when a map starts (as @IIYAMA suggested). I can live with no paintjob on default cars if there is a modded one in the map. It's not like there are a lot of maps with custom vehicles which actually contain a switch to another non-modded one. Edit: line 435 here does that for another server but i still need to figure it out - https://github.com/JarnoVgr/Mr.Green-MTA-Resources/blob/master/resources/[gameplay]/gcshop/modshop/modshop_s.lua Edited December 26, 2017 by koragg Link to comment
koragg Posted December 26, 2017 Author Share Posted December 26, 2017 Fixed!! With below code: addEvent("onMapStarting", true) function onMapStarting() canUsePJsAndLights = true setElementData(resourceRoot, "canUsePJsAndLights", true) for k, s in pairs(getElementsByType("spawnpoint")) do if getElementData(s, "upgrades") or getElementData(s, "paintjob") then canUsePJsAndLights = false setElementData(resourceRoot, "canUsePJsAndLights", false) end end for k, s in pairs(getElementsByType("checkpoint")) do if getElementData(s, "upgrades") or getElementData(s, "paintjob") then canUsePJsAndLights = false setElementData(resourceRoot, "canUsePJsAndLights", false) end end for k, s in pairs(getElementsByType("pickup")) do if getElementData(s, "upgrades") or getElementData(s, "paintjob") then canUsePJsAndLights = false setElementData(resourceRoot, "canUsePJsAndLights", false) end end if canUsePJsAndLights == false then local customLightsRes = getResourceFromName("cr_vehiclelights") if customLightsRes then if getResourceState(customLightsRes) == "running" then return end end setTimer(outputChatBox, 1500, 1, "This map has it's own custom upgrades, paintjobs and vehicle lights are disabled!") end end addEventHandler("onMapStarting", root, onMapStarting) And whenever I don't want paintjobs (and vehicle lights) to load I just use if canUsePJsAndLights == false then return end And for client-side I use the resource's element data which I've set above^. The problem before was that I didn't know from where that "upgrades" and "paintjob" element data came for checkpoints, spawnpoints and pickups but now I found out that it's there by default in MTA. This made my work super easy Thanks for all the help guys. 2 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now