Search the Community
Showing results for tags 'overload'.
Found 1 result
-
[Code Snippet] create method library - CreateVehicle, DeleteVehicle (Arma 3 similar)
sarogahtyp posted a topic in Arma Reforger - Configs & Scripting
What I began on my current AR project is to create a tool class with methods that make me some things easier. In this case I show how to create an easy to use CreateVehicle and a DeleteVehicle method with overloaded argument lists. Which just means that you can have different parameter syntaxes as known from various Arma 3 commands. I created a new script file in the newly created folder MyProject/scripts/GameCode/Tools according to the AR directory structure as I understand it^^. I named the file SaRo_Tools.c - this file will contain the class with my tools methods. What do I have to do when spawning a vehicle without that tools class? Something like this: Now instead of doing this we create our tools class which does most of this automatically: Now you have 2 easy methods to spawn a vehicle: IEntity vehicle1, vehicle2; //1st method using resource name and spawn position vehicle1 = SaRo_Tools.CreateVehicle("{DD774A8FD0989A78}Prefabs/Vehicles/Wheeled/M998/M1025_armed_M2HB_MERDC.et", Vector(1288.93, 0, 766.7)); //2nd method using resource name, an existing entity and a position vector relative to that entity vehicle2 = SaRo_Tools.CreateVehicle("{DD774A8FD0989A78}Prefabs/Vehicles/Wheeled/M998/M1025_armed_M2HB_MERDC.et", someEntity, Vector (0, 0, -15)); //spawns 15m behind someEntity Maybe I did some mistakes in this post because I did write it out of my mind partially. But I ll validate, expand and edit it if Im at home... Deletion methods will be done then as well EDIT: to get this done, I also added 2 entity deletion methods to the tools class. I just post those 2 methods and not the CreateVehicle methods from above again although they are in that class: Now you have 2 easy methods to delete an entity: //1st method delete using the entity ID SaRo_Tools.DeleteVehicle ( SaRo_BMHQ01MenuBaseClass.camoNetID ); //2nd method delete using the entity itself SaRo_Tools.DeleteVehicle ( someEntity ); Now YOU know how to build an own tools library class and you also know how to overload class methods. Its your turn to create more methods that way to get things a bit easier for you...