Lvrent Posted December 18, 2020 Share Posted December 18, 2020 (edited) I don't know if there is already a topic opened on this subject (as I searched and found nothing). Sorry if I missed out, you can redirect me to a similar topic and close this one. So, I want to add custom vehicles to my server, but without replacing the current ones. Tested engineRequestModel("vehicle") and it works very well for my needs, but it's clientside only. That being said, I can't sync the vehicles between the players or control them (with commands for example) serverside. Is there an alternative to sync and control addons vehicles? More precisely, to create them serverside? I think a function for this will be very welcomed for most scripters, if it doesn't already exists and I'm missing out. It will also be useful to use a similar function (or the same function but with different parameters) to request serverside ID's not only for vehicles, but also for peds and objects (as engineRequestModel supports this) and then create them with the specific functions (createVehicle, createObject etc.). MTA:SA version at this topic's open: 1.5.8 build 20760 Thanks in advance. Edited December 18, 2020 by Saint Laurent 1 Link to comment
FernandoMTA Posted December 19, 2020 Share Posted December 19, 2020 8 hours ago, Saint Laurent said: I want to add custom vehicles to my server, but without replacing the current ones. Tested engineRequestModel("vehicle") and it works very well for my needs, but it's clientside only. That being said, I can't sync the vehicles between the players or control them (with commands for example) serverside. Is there an alternative to sync and control addons vehicles? More precisely, to create them serverside? I think a function for this will be very welcomed for most scripters, if it doesn't already exists and I'm missing out. It will also be useful to use a similar function (or the same function but with different parameters) to request serverside ID's not only for vehicles, but also for peds and objects (as engineRequestModel supports this) and then create them with the specific functions (createVehicle, createObject etc.). I believe that what you are suggesting is still not yet a feature. You should read more about this on MTA's GitHub, for example by searching here: Issues · multitheftauto/mtasa-blue (github.com) This here is very interesting in particular: Add efficient modding interface for new model ID's · Issue #1792 · multitheftauto/mtasa-blue (github.com) 1 Link to comment
xPipeZ Posted December 27, 2022 Share Posted December 27, 2022 Hello, I'm answering this post because I asked myself the same question and I would like to know if so far someone else has achieved what is explained here. I was experimenting with some things and in a certain way I achieved something with a little code, but nevertheless I don't know if what I am doing can affect the performance of a server (for example with +100 players online). In the same way, this approach has a small error and that is that when a user enters the server and vehicles have already been created with this method, the custom skins will not be seen, otherwise it works well (I tried it on a local server with a friend). I would like to know the opinion of someone else. I'm not too expert in Lua so I apologize if I'm doing something wrong haha. Here's my code: -- server.lua resourceRoot = getResourceRootElement(getThisResource()) function createBike(playerSource, commandName, model) if model == 'dt-175' or model == 'dr-650' then local x, y, z = getElementPosition(playerSource) local vehicle = createVehicle(468, x + 0.5, y, z + 0.5) triggerClientEvent('setBikeModel', resourceRoot, vehicle, model) else outputChatBox('You should specify a valid model. (\'dt-175\' or \'dr-650\')', playerSoruce) end end addCommandHandler('createBike', createBike, false, false) -- client.lua resourceRoot = getResourceRootElement(getThisResource()) function setBikeModel(vehicle, model) local txd = engineLoadTXD('models/' .. model .. '.txd') local dff = engineLoadDFF('models/' .. model .. '.dff') local bike = engineRequestModel('vehicle', 468) engineImportTXD(txd, bike) engineReplaceModel(dff, bike) setElementModel(vehicle, bike) end addEvent('setBikeModel', true) addEventHandler('setBikeModel', resourceRoot, setBikeModel) 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