mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

setModelName/setVehicleName/getModelName

Open Allerek opened this issue 6 years ago • 17 comments

Hi, as you know current actually we are forced to use original models/vehicles names in GTA(we can do the table with ours but thats another thing)

I think it would be cool to add setVehicleName(int model, string name) returns true/false (to use with getVehicleNameFromModel/getVehicleName) setModelName(int model_id, string name) returns true/false getModelName(int model_id) returns string model name

I dont think anyone needs explanation how this should work, the functions names are pretty clear.

Allerek avatar Dec 04 '19 19:12 Allerek

Thanks for your proposal. Why do you think this is necessary / should be added?

Theoretically I guess it makes sense that it should be possible to change this metadata, but I'm worried that this would just be a feature that causes confusion.

qaisjp avatar Dec 04 '19 19:12 qaisjp

Thanks for your proposal. Why do you think this is necessary / should be added?

Theoretically I guess it makes sense that it should be possible to change this metadata, but I'm worried that this would just be a feature that causes confusion.

F.E. when you want to add car thats out of the GTA SA(i have Infernus from VC on my servers which is replaced for 'Saddle Shit' and named it 'Infernus SX') so it would be easier when you need to use getVehicleName[...]. 2.When you want to create some Map Editors by yourself without huuuge list of items/objects/vehicles etc.

Allerek avatar Dec 04 '19 19:12 Allerek

Map editor uses predefined model names that are listed in server\mods\deathmatch\resources[editor]\editor_gui\client\browser\objects.xml

But yeah, its not a totally bad idea to have custom vehicle names added - for most users this resource should be sufficient tho: https://community.mtasa.com/index.php?p=resources&s=details&id=12424

Einheit-101 avatar Dec 04 '19 22:12 Einheit-101

Map editor uses predefined model names that are listed in server\mods\deathmatch\resources[editor]\editor_gui\client\browser\objects.xml

But yeah, its not a totally bad idea to have custom vehicle names added - for most users this resource should be sufficient tho: https://community.mtasa.com/index.php?p=resources&s=details&id=12424

This one uses a table with names, i want to make it a hard-coded function

admin note: put an extra newline after the quote is done otherwise it will treat it as the same line

Allerek avatar Dec 05 '19 17:12 Allerek

Well, changing the model name may break scripts using getModelFromName(or whatever the name of the func. is), but i think we could do a set/getVehicleCustomName or something similar.

Pirulax avatar Dec 05 '19 22:12 Pirulax

in my opinion this would only be useful after adding the option of creating new vehicles. It's very easy to do this with the exported function and a table as you said before and as Pirulax said it could break some older coded scripts.

MrDadosz avatar Dec 06 '19 11:12 MrDadosz

If someone uses an old script then he should be able to fix issues coming with this function. Its better to identify vehicles by model id anyway.

Einheit-101 avatar Dec 06 '19 11:12 Einheit-101

https://github.com/multitheftauto/mtasa-blue/pull/1701

Allerek avatar Nov 10 '20 22:11 Allerek

Okay that makes sense

qaisjp avatar Nov 10 '20 22:11 qaisjp

over function like setModel/VehicleName, i'm suggesting to just add a .xml ( simillar to vehicle colors ) file where you can set custom name for custom models, objects, models, vehicles and peds so getVehicleNameFromModel() return custom name client and server side

CrosRoad95 avatar Nov 18 '20 18:11 CrosRoad95

over function like setModel/VehicleName, i'm suggesting to just add a .xml ( simillar to vehicle colors ) file where you can set custom name for custom models, objects, models, vehicles and peds so getVehicleNameFromModel() return custom name client and server side

I don't think this is possible or practical. Would it associate new ID -> name? The allocated ID is not guaranteed to be the same all the time as the wiki says:

There is no guarantee for the order of the numbers or that the same numbers will always correspond to the same element type. Any patterns are coincidental.

so I don't see how we would predefine names for custom vehicles. Plus, having it in an .xml file under server configuration seems like extra work.

I think we could have just the following:

  • engineSetModelName ( int modelID, string name )

To work with the existing functions:

  • engineGetModelNameFromID
  • engineGetModelIDFromName

I think it makes sense to have this new function on clientside considering that this PR recently made getElementModel on serverside fetch the element's parent model ID, so there is no issue on serverside.

^ Seems coherent, what do you guys think?

Fernando-A-Rocha avatar Oct 21 '21 16:10 Fernando-A-Rocha

I think it makes sense to have this new function on clientside considering that this PR recently made getElementModel on serverside fetch the element's parent model ID, so there is no issue on serverside.

No, the PR doesn't do that. All it does is make the client get max passenger count and vehicle type from the parent model. This only happens clientside, the server is not aware of any custom model (because custom models aren't implemented serverside yet). Hence calling getElementModel() serverside always fetches the parent model.

BCG2000 avatar Oct 21 '21 22:10 BCG2000

I think it makes sense to have this new function on clientside considering that this PR recently made getElementModel on serverside fetch the element's parent model ID, so there is no issue on serverside.

No, the PR doesn't do that. All it does is make the client get max passenger count and vehicle type from the parent model. This only happens clientside, the server is not aware of any custom model (because custom models aren't implemented serverside yet). Hence calling getElementModel() serverside always fetches the parent model.

Yep sorry that was a stupid misconception :D

I think that as a "temporary solution" (because #2251 plans on doing everything differently in the future) we can have engineSetModelName to define model name that can then be fetched with other functions, for now.

Fernando-A-Rocha avatar Oct 25 '21 18:10 Fernando-A-Rocha

so I don't see how we would predefine names for custom vehicles. Plus, having it in an .xml file under server configuration seems like extra work.

You can assign names in same time as you allocate the model.

Allerek avatar Nov 11 '21 20:11 Allerek

so I don't see how we would predefine names for custom vehicles. Plus, having it in an .xml file under server configuration seems like extra work.

You can assign names in same time as you allocate the model.

yup, that would be good! Like I said, engineSetModelName after model allocation, that could work. But I think now we're just going to focus on serverside model allocation as he current features ( 1.5.9-9.21026.0 ) allow u to use new model allocation without bugs.

Fernando-A-Rocha avatar Nov 12 '21 15:11 Fernando-A-Rocha

so I don't see how we would predefine names for custom vehicles. Plus, having it in an .xml file under server configuration seems like extra work.

You can assign names in same time as you allocate the model.

yup, that would be good! Like I said, engineSetModelName after model allocation, that could work. But I think now we're just going to focus on serverside model allocation as he current features ( 1.5.9-9.21026.0 ) allow u to use new model allocation without bugs.

The total to-do are bottom functions int engineRequestModel ( string elementType [, int parentID ], [ string name ] ) - to keep backwards compatibility + assign names in same time as you allocate the model. bool engineSetModelName ( int modelID, string name ) - new function which allows to set allocated model name + support with engineGetModelNameFromID, engineGetModelIDFromName, getVehicleName, getVehicleModelFromName and getVehicleNameFromModel.

I'll wait couple days for other proposals and start work on that

Inder00 avatar Jan 03 '22 21:01 Inder00

related to #3529

Proxy-99 avatar Jul 03 '24 15:07 Proxy-99