GithubHelp home page GithubHelp logo

fernando-a-rocha / mta-add-models Goto Github PK

View Code? Open in Web Editor NEW
50.0 5.0 16.0 6.2 MB

Library for Multi Theft Auto: San Andreas that lets you add new models to your server

License: GNU General Public License v3.0

Lua 100.00%
mta sa san andreas multiplayer objects peds skins add new

mta-add-models's Introduction

Banner

mta-add-models is an MTA resource (library) which makes use of the engineRequestModel features to add new peds (skins), vehicles and objects:

  • syncs all added models with all players
  • minimalistic, optimized and bug free

In simpler terms, with this resource you can make scripts/change your scripts to add new skin, vehicle and object IDs to your server! For example we can now add all SA-MP objects whilst keeping their intended IDs.

MTA forum thread: link

Support/Help

If you need help with anything related to this project, please read the corresponding section on the MTA forum thread linked above.

Visit the project's feedback page to check other people's opinions and share your own.

Getting Started

Prerequisites

  • Required minimum MTA Server & Client version 1.6.0-9.22204.0 (MTA 1.6) ⚠️
  • Get the installers from nightly.mtasa.com
  • Client should auto-update upon joining the server
  • Find out what the build numbers mean here: buildinfo.mtasa.com
  • If you don't have the right version these resources will not work correctly

Includes

newmodels: main library resource

  • (debugging) unittest_newmodels: a resource for testing the main scripts
  • (recommended) newmodels-engine: a resource that uses the main scripts (useful)
  • (optional) sampobj_reloaded: a resource that adds all SA-MP object models to your server
    • 👉 Download models.zip containing all dff/txd/col files required
  • (optional) vehicle_manager: a basic resource that adds some vehicle models to your server with custom properties
  • (optional) editor_custom: modified MTA:SA Map Editor resources to support using new model IDs

Install

  • Get the latest release: here
  • Download the source code Zip and extract it
  • Place the newmodels folder in your server's resources
  • Use command start newmodels in server console

Quick Testing

  • Place mod files newmodels/models (dff & txd (& col for objects))
  • List them in newmodels/meta.xml like the example
  • As of version 2.0, files have the download="false" attribute, causing newmodels to handle downloading them later only when needed
  • Define them in newmodels/mod_list.lua inside modList like the example
  • Use the commands to test, have fun!

Commands

Main testing commands in newmodels:

  • /listmods lists all defined mods
  • /allocatedids shows all allocated mod IDs in realtime
  • /selements lists all streamed in elements for debugging purposes
  • /myskin [ID] sets your skin to a default or new ID
  • /makeped [ID] creates a ped and sets its model to a default or new ID
  • /makeobject [ID] creates an object and sets its model to a default or new ID
  • /makevehicle [ID] creates a vehicle and sets its model to a default or new ID

How to Use

General Information/Guide: It should help you understand how the newmodels resource works and how to use it.

NandoCrypt

There is support for encrypted model files using the NandoCrypt resource.

This is useful for those who want to keep the models private & prevent people from stealing them.

Object Collisions

Object mods need a .col file to define its collisions. Ped and vehicles don't need any because the collisions are automatically generated by the game engine.

Use the KDFF tool to generate a .col file from a given .dff model (tutorial here).

Credits

The resources newmodels, vehicle_manager and sampobj_reloaded include mods from the following sources:

Related Projects

Final Note

Feel free to update the documentation in this repository and contribute to the code via pull requests.

Thank you for reading, have fun!

mta-add-models's People

Contributors

fernando-a-rocha avatar insigne avatar mimimiguel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mta-add-models's Issues

This resource is potentially insecure

Hey,
I recommend you to verify if elem data's such as vehicle handling etc. changes on the client and then kicking/flaging/banning player as it could be used from trainers to force unexpected behaviors.
U can do it using handle on event onElementDataChange and checking client parameter (so then its elem data changed on cside) along with key and indexing the table with protected serverside element datas such as handling.
My kindest regards,
Jakub

[Help] Implement new models in gridlist

Hi there! About a month ago I found this resource-library for adding models to new custom IDs. I'm not very good at coding in the MTA, my resources were a simple usage of engineReplaceModel, the CEF panels etc.
So, more to the point, after seeing this project, I decided to port some vehicles from my copy of San Andreas with objects on new IDs on local MTA server.
Added a few of them, works great, thanks for such a great resource! Can you please help me create a simple MTA guiGridlist for vehicle spawns with a custom ID? Just a piece of code with an example of how spawn "vehicle1" with not defualt ID by clicking on it in list, such as in the freeroam vehicle create menu. From this, I myself will figure out how to finish everything to an acceptable form for me.
Anyway, somewhere this week, when I have a free minute, I'll try it myself. Thanks in advance!

Problem with setElementModel

Everyone has a server written differently and this can help, for example, someone changes their clothes in the setElementModel store, so why should I add a removeElementData to take a custom skin

Some suggestions

  1. add a custom model cache based on usage frequency, API hinting (setCustomModelAlwaysLoaded) or database flag so that MTA does not have to perform the expensive disk loading of model data as frequently (improves FPS)

  2. add statistics API about the number of custom models loaded, their usage details (frequency, number of elements with the model, etc) and the general performance of the resource. You could even add a debug dashboard using some hidden key combination (very important to build user-trust into your resource workings)

  3. (DONE) add a way to register custom models from other storage resources. This way custom models could potentially be downloaded from the server on-demand by a second resource and - after finishing the download - be registered as custom model inside of your own resource. Could be really fun!

(( Edit: added number for each suggestion ))
(( Edit 2: marked suggestion 3 as done ))

Freeroam

o freeroam (painel f1) não ta dando spawn nos veiculos, como consigo fazer ele dar spawn?

How to add Weapons (method)

i wanted to know if it's possible to add weapons ? tried to add it as a object but it needs a collision file.

Element models not released by destroyElement (issue?)

If a streamed-in element is destroyed (for example using destroyElement) and it has a custom model association, then that custom model is not released. This is peculiar because your resource is releasing custom models on element-stream-out if these models are not used anymore. How about you try using the onClientElementDestroy event, too?

Bug: Vehicle upgrades are lost on model change

STEPS TO REPRODUCE:

  • Spawn any new car with this resource
  • Add upgrades to it (addVehicleUpgrade...)
  • Trigger a vehicle replacement, ex: reconnect, unload models, etc
  • Get closer back to the car
  • Upgrade is lost

Looking at the code, this seems to be similar to the issue with the handling, which you approached already. I can apply a similar fix to this if it's okey to you!

I will update this issue with any progress I make.

The trailer wheel won't engage!

The trailer wheel doesn't engage, the truck responsible for pulling the trailer can't engage anything if it's in the newmodels! Trailers can be on newmodels that work normally, but wheelies cannot!

can possible add cars in conce system?

I wanted to know if it is possible to add these vehicles in the concessionaire, because I want to add new vehicles, because vehicles 4 doors of my server are already finished, if you can take me this doubt I would thank you very much (:

Not checking the element-data key during onClientElementDataChange

At https://github.com/Fernando-A-Rocha/mta-add-models/blob/main/newmodels/client.lua#L137

addEventHandler( "onClientElementDataChange", root, 
function (theKey, oldValue, newValue)
	
	local et = getElementType(source)
	if isElementTypeSupported(et) and tonumber(newValue) then
		
		local id = tonumber(newValue)

		if isCustomModID(et, id) then

In a previous revision you were checking the theKey parameter for the correct one based on ped/player/object element type association but you are not doing that anymore. This results in triggering of the model adjustment logic for just about any element data of the supported elements that is a number.

Newmodel vehicle door & panel states are lost

Newmodel vehicles mainly lose the following states when the model is changed (happens intentionally clientside with setElementModel & also automatically with engineFreeModel):

  • door states
  • panel states

This is particularly bad because these are related to visual damage, so it's like they always get repaired.

One issue

Found issues in version 1.1.0

  • if there are two peds synced for the player and both have the same custom model assigned to them, then if one of them streams out your syncer attempts to release the custom model for both of the ped elements, especially the one already streamed in. While the documentation of engineFreeModel does not mention what happens in this case, I assume that the request fails. This scenario is a potential model ID leak (the client will run out of available real model IDs at some point). Even worse: the client could run out of RAM very quickly.

Moved suggestions to: #3

https://forum.mtasa.com/topic/133212-rel-add-new-models-library/#comment-1003406

possible to add vehicles to concessionaria?

I wanted to know if it is possible to add these vehicles in the concessionaire, because I want to add new vehicles, because vehicles 4 doors of my server are already finished, if you can take me this doubt I would thank you very much (:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.