Jump to content
Sign in to follow this  
PeeKay

Spawning objects ingame with subsequent names script

Recommended Posts

Hi guys,

I am trying to alter this script where I spawn objects while in-game.

consmkr.sqf:

// Construction Interface
// This script creates the objects.
// By: Oliver 15th MEU(SOC)

private ["_maker","_object","_padlistofobj"];

//_maker = _this select 0;

_object = lbCurSel 1500;

_padlistofobj =(count((getMarkerPos "coinpad") nearObjects 11));


If (_padlistofobj >= 53) exitWith {Hint "Please clear the Construction Pad before building more items!";};


switch (true) do {
case (_object == 0) : { 0 = "_FORTIFICATIONS_" createVehicle (getMarkerPos "coinpad");};
case (_object == 1) : { 0 = "Land_HBarrier_large" createVehicle (getMarkerPos "coinpad");};
   case (_object == 2) : { 0 = "Land_HBarrier5" createVehicle (getMarkerPos "coinpad");};
   case (_object == 3) : { 0 = "Land_HBarrier3" createVehicle (getMarkerPos "coinpad");};
   case (_object == 4) : { 0 = "Land_fort_bagfence_long" createVehicle (getMarkerPos "coinpad");};
   case (_object == 5) : { 0 = "Land_fort_bagfence_corner" createVehicle (getMarkerPos "coinpad");};
   case (_object == 6) : { 0 = "Land_fort_bagfence_round" createVehicle (getMarkerPos "coinpad");};
   case (_object == 7) : { 0 = "Land_BagFenceLong" createVehicle (getMarkerPos "coinpad");};
   case (_object == 8) : { 0 = "Land_BagFenceShort" createVehicle (getMarkerPos "coinpad");};

Since the objects aren't in the original mission.sqm I can't name them.

I am wondering how to alter this script so the object is spawned along with a subsequent name ie. Barrier1 then Barrier2 then Barrier 3.

I need to name them so the object will be saved in the my Persistent DB when I run the mission.

Thanks in advance!

-PeeKay

Share this post


Link to post
Share on other sites

This will set the in game name of the object _objectSpawned to whatever string value _objectName is.

{_objectSpawned setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_objectName];
processInitCommands;};

Instead of 0 = "Land..." you'd do _objectSpawned = "Land...." then you'd keep track of whatever value of _objectName should be and keep adding numbers to that. Unless your persistent script doesn't need actual names and can just save objects in which case changing your 0 = to something useful should work.

Share this post


Link to post
Share on other sites

Wow its been a while since I wrote that script. Pretty much what Kylania said, except I would advise against using setVehicleInit, it creates a lot of network traffic. It is used a lot in hacking and I would not be supprised if BI ends up crippeling it or taking it out completely.

But you really shouldn't need it, I cant think of a reason where you would need to set the objects names, you should just need a reference to the object. I would either add them to an array at creation and push that to the DB or dynamicly get a list of them right before you need to push the data to the DB. Similar to how I check if there are objects on the con pad.

http://browser.six-projects.net/cfg_vehicles/classlist?utf8=%E2%9C%93&version=58&commit=Change&options%5Bgroup_by%5D=vehicleclass&options%5Bsort_by%5D=name&options%5Bfaction%5D=&options%5Bvehicleclass%5D=Fortifications

[/color][color=#000000][font=Lucida Console]_list= [_xpos,_ypos] [/font][/color]nearObjects ["Fortifications",10000];[color=#3e3e3e]
[/color][color=#3E3E3E]

Also I would update the createVehicle to the new createVehicle Array syntax, it has much better performance.

http://community.bistudio.com/wiki/createVehicle_array

Share this post


Link to post
Share on other sites

Alright. Will do. Thanks alot guys! Thanks for the script Riouken!

Share this post


Link to post
Share on other sites

Sorry i don't understand either method above.

Im spawning a base using a script. I want to name some objects.

[

["Land_Pillow_EP1",[0,0,0],0,1,0,{}],

["Pile_of_wood",[-2.61914,0.323242,0],0,1,0,{}],

["Logic",[-3.75879,0.613281,0],0,1,0,{}],

["Land_CamoNetVar_NATO",[6.24072,25.6279,0],179.106,1,0,{}],

["Notice_board_EP1",[5.98389,26.1035,0],359.315,1,0,{}],

["Notice_board_EP1",[17.0752,25.9316,0],26.9831,1,0,{}],

["Land_CamoNetVar_NATO",[18.3872,25.623,0],179.106,1,0,{}],

["Land_transport_crates_EP1",[6.51172,30.5684,0],90,1,0,{}],

["ShootingRange_ACR",[10.6406,-29.9932,0],90,1,0,{}],

["Land_transport_crates_EP1",[10.5127,30.2764,0],90,1,0,{}],

["Land_Misc_deerstand",[-4.59033,-32.4277,0],1.60286,1,0,{}],

["ShootingRange_ACR",[14.4463,-30.0186,0],90,1,0,{}],

["Land_Fire_barrel_burning",[-4.65234,33.0137,0],90,1,0,{}],

["FootBridge_0_ACR",[33.5156,-1.17383,0],179.333,1,0,{}],

["FootBridge_0_ACR",[33.4717,3.31055,0],179.333,1,0,{}],

["Land_Campfire_burning",[-13.6475,30.9355,0],90,1,0,{}],

["Ural_CDF",[-19.6133,-27.584,-0.320099],0.464767,1,0.97,{}],

["FootBridge_0_ACR",[33.6597,-6.32422,0],179.333,1,0,{}],

["FootBridge_0_ACR",[33.4209,8.17871,0],179.333,1,0,{}],

["Land_transport_crates_EP1",[16.7241,30.3584,0],90,1,0,{}],

["ShootingRange_ACR",[18.4722,-29.9854,0],90,1,0,{}],

["FootBridge_0_ACR",[33.7036,-10.8086,0],179.333,1,0,{}],

["FootBridge_0_ACR",[33.377,12.6641,0],179.333,1,0,{}],

["ShootingRange_ACR",[22.5137,-29.9229,0],90,1,0,{}],

["FootBridge_0_ACR",[33.2329,17.8145,0],179.333,1,0,{}],

["Ural_CDF",[-25.9966,-27.584,-0.320099],0.464767,1,0.97,{}],

["CampEast_EP1",[-0.0898438,39.1748,0],89.4785,1,0,{}],

["ShootingRange_ACR",[26.292,-29.9922,0],90,1,0,{}],

["FootBridge_0_ACR",[33.189,22.2988,0],179.333,1,0,{}],

["Land_fort_rampart",[-0.0551758,-38.0967,0],0.240249,1,0,{}],

["CampEast_EP1",[-10.5308,39.4746,0],89.4785,1,0,{}],

["Land_Fire_barrel_burning",[-25.689,31.9063,0],90,1,0,{}],

["Land_fort_rampart",[7.96826,-38.1084,0],0.240249,1,0,{}],

["Land_fort_rampart",[-8.21484,-38.1289,0],0.240249,1,0,{}],

["Ural_CDF",[-32.2559,-27.3379,-0.320099],0.464767,1,0.97,{}],

["CampEast_EP1",[-33.436,26.3633,0],89.4785,1,0,{}],

["ShootingRange_ACR",[30.0977,-30.0176,0],90,1,0,{}],

["HeliH",[42.0967,7.38086,0],90.515,1,0,{}],

["HeliH",[41.9209,-11.0908,0],90.515,1,0,{}],

["Land_fort_rampart",[16.1084,-38.1016,0],0.240249,1,0,{}],

["Land_fort_rampart",[-16.2383,-38.1162,0],0.240249,1,0,{}],

["Land_Misc_deerstand",[-6.89795,44.0693,0],184.04,1,0,{}],

["ShootingRange_ACR",[34.1235,-29.9844,0],90,1,0,{}],

["CampEast_EP1",[-22.3008,39.6445,0],89.478,1,0,{}],

["Land_fort_rampart",[24.1328,-38.1162,0],0.240249,1,0,{}],

["Land_fort_rampart",[-24.3799,-38.1221,0],0.240249,1,0,{}],

["ShootingRange_ACR",[38.165,-29.9219,0],90,1,0,{}],

["HeliH",[42.0967,24.2715,0],90.515,1,0,{}],

["Land_fort_rampart",[-0.295898,48.6523,0],179.651,1,0,{}],

["FlagCarrierUSA_EP1",[-35.9917,35.9512,0],0,1,0,{}],

["Misc_Cargo1Bo_military",[-44.1206,-26.0107,0],162.913,1,0,{}],

["CampEast_EP1",[-43.7808,26.8564,0],89.4785,1,0,{}],

["Land_fort_rampart",[-8.45508,48.5381,0],179.651,1,0,{}],

["Land_fort_rampart",[7.72803,48.7227,0],179.651,1,0,{}],

];

_objs

So i want to name Notice_board_EP1 speaker1. How can i do this?

Thanks

Edited by BangaBob

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×