Vehicle Repawn Script

paddy1223

Member
I've been looking through the forums and unless im blind I havent found one yet. So looking for a hand here.

I've built a custom island on chernarus out of large peers, etc. Im going to run Sarge AI there aswell. But what im looking for is a script that'll let me

CreateVehicle - Say a URAL with Gear I've selected
And on every restart, Delete the Vehicle and Respawn it as above

The reason I need this is I've been buildng my own "Sector B" and want to give players something else todo on my server like fighting AI on an island to get gear.

My "Sector B" ie "Sector FNG"

 
Does that actually work though? I could test that but I didnt do it because adding vehicles that way makes them blowup / disappear in game. Something todo with not being properly adding in database?

Edit

I see nothing in my sqf or biedi file that relates to gear saving in the ural when i saved it. Only the coordinates.
 
Now that is nicely done. I have tried making an "island" similar to this, but making things out the water, just pulled out my remaining hair on my head.

By any chance you will share your beidi file?
Anyways, very nicely done.

Cheers, Kash
 
Im Bald too lol dont worry. I found that placing objects then editing the biedi file manually - save - load in editor was the only way todo such a big project neatly. Also on top of that testing everything i added in phases on my test server so they worked ok and fitted together XYZ wise.

I will probaly consider releasing this down the line if I get the Sarge ai and fresh repawning of fresh urals with gear to work. Then I'll probaly release the whole project. Im also still testing the map out at the moment too as its only on my test server atm.
 
Hehe :)
Yea, I have made a bridge to skallisty, and found a decent way..But still a lot of trouble.
Regarding your Ural, why don't you just use "carepackages", ammocrates and whatnot?
 
Damn that looks nice. I recall reading somewhere you can't spawn vehicles on an island like this because the vehicles are loaded first when the server restarts, then the buildings. So the vehicles get loaded and start falling into the ocean, then the base loads and the vehicles blow up. Same thing happens if a vehicle is left on top of a building in a city. Is that not the case?
 
if you take a look on the origins sql file you will see how its done...
they spawn in some regular vehicles... with a special id... so they can delete and respawn them on every script run...
 
I've added weaponcrates from the editor for now. But want something I can edit myself without generic gear they come with. Didnt think I could add carepackages so might have a look on here to see if theres a script on them
 
if you take a look on the origins sql file you will see how its done...
they spawn in some regular vehicles... with a special id... so they can delete and respawn them on every script run...

Where to look is my problem m8. That was my first thought. been looking through it last night and gave up lol
 
ok here is the part of the code you will need

Code:
    DELETE
            FROM `object_data`
            WHERE `ObjectUID` = '0000500000393';
    DELETE
            FROM `object_data`
            WHERE `ObjectUID` = '0000500000394';
    DELETE
            FROM `object_data`
            WHERE `ObjectUID` = '0000500000395';
 
    DELETE
            FROM `object_data`
            WHERE `ObjectUID` = '0000500001393';
    DELETE
            FROM `object_data`
            WHERE `ObjectUID` = '0000500001394';
    DELETE
            FROM `object_data`
            WHERE `ObjectUID` = '0000500001395';
    DELETE
            FROM `object_data`
            WHERE `ObjectUID` = '0000500001396';
    DELETE
            FROM `object_data`
            WHERE `ObjectUID` = '0000500001397';
 
    INSERT INTO `object_data`
            VALUES (NULL, '0000500001393', '1', 'UralCivil2', '0.05000', '0', '[180,[22462.2,19495.5,0]]', '[[[],[]],[["ItemAntibiotic","ItemBandage","ItemBloodbag","ItemEpinephrine","ItemMorphine","ItemPainkiller","FoodCanBakedBeans","FoodCanFrankBeans","FoodCanPasta","FoodCanSardines","ItemSodaCoke","ItemSodaPepsi","ItemHeatPack"],[15,15,15,15,15,15,15,15,15,15,15,15,15]],[["O_TravelerPack_1","O_MegaPack_1"],[1,1]]]', '[["motor",0.8],["karoserie",1],["palivo",0.8],["wheel_1_1_steering",1],["wheel_2_1_steering",1],["wheel_1_2_steering",1],["wheel_2_2_steering",1]]', '0.01000', NOW());
    INSERT INTO `object_data`
            VALUES (NULL, '0000500001394', '1', 'UralCivil2', '0.05000', '0', '[269,[22180.7,19833.1,0]]', '[[["ItemPickaxe"],[2]],[["ItemBpt_b1","ItemBpt_b2","ItemBpt_h1","ItemBpt_h2","ItemBpt_g_s","ItemBpt_g_b","ItemBattery","ItemPin","ItemRocks","ItemCementBag","PartScrap","PartWoodPile","ItemCeMix"],[3,3,3,3,3,1,7,7,15,5,10,15,3]],[["O_TravelerPack_1","O_MegaPack_1"],[1,1]]]', '[["motor",0.8],["karoserie",1],["palivo",0.8],["wheel_1_1_steering",1],["wheel_2_1_steering",1],["wheel_1_2_steering",1],["wheel_2_2_steering",1]]', '0.01000', NOW());
    INSERT INTO `object_data`
            VALUES (NULL, '0000500001395', '1', 'UralCivil2', '0.05000', '0', '[90,[22452.8,20074.8,0]]', '[[["AKS_74_kobra","M16A2GL","AKS_74_U","FN_FAL","M9SD","PK_DZ","Pecheneg_DZ","bizon_silenced","M4A3_RCO_GL_EP1","NVGoggles","ItemGPS","G36K"],[3,3,3,3,3,3,3,3,3,2,2,1]],[["ItemBloodbag","100Rnd_762x54_PK","30Rnd_556x45_Stanag","100Rnd_762x51_M240","30Rnd_556x45_G36SD","10Rnd_9x39_SP5_VSS","ItemAntibiotic","30Rnd_545x39_AK","20Rnd_762x51_FNFAL","15Rnd_9x19_M9SD","64Rnd_9x19_SD_Bizon","1Rnd_HE_GP25","PartGeneric","PartEngine","PartGlass","PartVRotor","ItemJerrycan","ItemTent"],[10,10,10,10,10,10,10,10,10,10,10,10,4,2,6,2,10,2]],[["O_TravelerPack_1","O_MegaPack_1"],[1,1]]]', '[["motor",0.8],["karoserie",1],["palivo",0.8],["wheel_1_1_steering",1],["wheel_2_1_steering",1],["wheel_1_2_steering",1],["wheel_2_2_steering",1]]', '0.01000', NOW());
    INSERT INTO `object_data`
            VALUES (NULL, '0000500001396', '1', 'UralCivil2', '0.05000', '0', '[178,[22533,20073,0]]', '[[["AKS_74_kobra","M16A2GL","AKS_74_U","FN_FAL","M9SD","PK_DZ","Pecheneg_DZ","bizon_silenced","M4A3_RCO_GL_EP1","NVGoggles","ItemGPS","G36K"],[3,3,3,3,3,3,3,3,3,2,2,1]],[["ItemBloodbag","100Rnd_762x54_PK","30Rnd_556x45_Stanag","100Rnd_762x51_M240","30Rnd_556x45_G36SD","10Rnd_9x39_SP5_VSS","ItemAntibiotic","30Rnd_545x39_AK","20Rnd_762x51_FNFAL","15Rnd_9x19_M9SD","64Rnd_9x19_SD_Bizon","1Rnd_HE_GP25","PartGeneric","PartEngine","PartGlass","PartVRotor","ItemJerrycan","ItemTent"],[10,10,10,10,10,10,10,10,10,10,10,10,4,2,6,2,10,2]],[["O_TravelerPack_1","O_MegaPack_1"],[1,1]]]', '[["motor",0.8],["karoserie",1],["palivo",0.8],["wheel_1_1_steering",1],["wheel_2_1_steering",1],["wheel_1_2_steering",1],["wheel_2_2_steering",1]]', '0.01000', NOW());
    INSERT INTO `object_data`
            VALUES (NULL, '0000500001397', '1', 'UralCivil2', '0.05000', '0', '[178,[22549.2,20071.9,0]]', '[[["AKS_74_kobra","M16A2GL","AKS_74_U","FN_FAL","M9SD","PK_DZ","Pecheneg_DZ","bizon_silenced","M4A3_RCO_GL_EP1","NVGoggles","ItemGPS","G36K"],[3,3,3,3,3,3,3,3,3,2,2,1]],[["ItemBloodbag","100Rnd_762x54_PK","30Rnd_556x45_Stanag","100Rnd_762x51_M240","30Rnd_556x45_G36SD","10Rnd_9x39_SP5_VSS","ItemAntibiotic","30Rnd_545x39_AK","20Rnd_762x51_FNFAL","15Rnd_9x19_M9SD","64Rnd_9x19_SD_Bizon","1Rnd_HE_GP25","PartGeneric","PartEngine","PartGlass","PartVRotor","ItemJerrycan","ItemTent"],[10,10,10,10,10,10,10,10,10,10,10,10,4,2,6,2,10,2]],[["O_TravelerPack_1","O_MegaPack_1"],[1,1]]]', '[["motor",0.8],["karoserie",1],["palivo",0.8],["wheel_1_1_steering",1],["wheel_2_1_steering",1],["wheel_1_2_steering",1],["wheel_2_2_steering",1]]', '0.01000', NOW());
as you can see they are deleting the vehicles with the specific ids and insert them with the same ids back into the table...
in the insert code you can set your location the vehicle health and the gear...
i would say you run this script before every restart and you are good to go... (of course you modify it to your needs before ^^)

cya
 
Yea I found the full sql code. Now to learn how to automatic exec it at restarts :)

Would it be as simple as putting a

[] ExecVM "respawnvehicles.sql";

in my init.sqf file?
 
no sorry... it wont work this way...
would be to easy ^^

you can put this whole code into a batchfile and execute it (will need a bit more code though)
or you can also make an event direct in your database... executed on a daily schedule for example...
or you can put this whole code into a mysql function or procedure in your database and execute this one
 
no sorry... it wont work this way...
would be to easy ^^

you can put this whole code into a batchfile and execute it (will need a bit more code though)
or you can also make an event direct in your database... executed on a daily schedule for example...
or you can put this whole code into a mysql function or procedure in your database and execute this one

Thank you

I've been looking through my database and found a few procedures being used for basebuilding, login, logout etc. All beginning with "Begin" "End" with Data Queries in the middle. I'm guessing I make a new one with Begin - My Database table Stuff - End and then somewhere I call on this function / procedure to run on restarts. Or will the routine run automatically at restarts?

Thx for your help, im getting there :p
 
Could you use any of these to prevent helicopters blowing up on a server restart if left on the aircraft carrier? Or any ideas how to stop this happening.
 
Spawned in vehicles through mission will work ok if there at the bottem of your sqf file. I placed my urals at the bottom of my sectorfng.sqf and they spawn ok. My problem is that if someone lands a helicopter there from the database. Sometimes it will spawn in before my sqf. So Im wondering if I can move my exec sectorfng up my init.sqf so it execs faster.

After hours of learning how to code how I want I use the following code for my urals. After changing the Server_updateObject and Server_Cleanup.fsm as above.

At the bottem of my custombase.sqf file I have.

Code:
//URAL Spawns
//URAL Weapons
_vehicle_103769 = objNull;
if (true) then
{
  _this = createVehicle ["Ural_TK_CIV_EP1", [14236, 494.5, 6.05], [], 0, "CAN_COLLIDE"];
  _vehicle_103769 = _this;
    //Damage Vehicle So cant Drive
  _this setHit ["wheel_1_1_steering", 1];
  _this setHit ["wheel_1_2_steering", 1];
  _this setHit ["wheel_1_3_steering", 0.5];
  _this setHit ["wheel_2_1_steering", 1];
  _this setHit ["wheel_2_2_steering", 1];
  _this setHit ["wheel_2_3_steering", 0.5];
  _this setHit ["motor", 0.70];
  _this setHit ["karoserie", 0.70];
  _this setHit ["palivo", 0.70];
  _this setFuel 0;
  //Clear Cargo
  clearweaponcargoGlobal _this;
  clearmagazinecargoGlobal _this;
  //Add Cargo
  _this addWeaponCargoGlobal ["M9SD",2];
  _this addWeaponCargoGlobal ["DMR_DZ",2];
  _this addWeaponCargoGlobal ["M4A1_AIM_SD_camo",2];
  _this addWeaponCargoGlobal ["FN_FAL",2];
  _this addWeaponCargoGlobal ["M249_DZ",2];
  _this addWeaponCargoGlobal ["M14_EP1",2];
  _this addWeaponCargoGlobal ["Mk_48_DZ",2];
  _this addWeaponCargoGlobal ["BAF_L85A2_RIS_SUSAT",2];
  _this addWeaponCargoGlobal ["BAF_L85A2_RIS_Holo",2];
  _this addWeaponCargoGlobal ["G36K_camo",2];
  _this addWeaponCargoGlobal ["NVGoggles",1];
  _this addWeaponCargoGlobal ["Binocular_Vector",1];
  _this addWeaponCargoGlobal ["ItemGPS",1];
 
  _this addmagazineCargoGlobal ["20Rnd_762x51_DMR",20];
  _this addmagazineCargoGlobal ["30Rnd_556x45_StanagSD",20];
  _this addmagazineCargoGlobal ["20Rnd_762x51_FNFAL",10];
  _this addmagazineCargoGlobal ["100Rnd_762x51_M240",10];
  _this addmagazineCargoGlobal ["200Rnd_556x45_M249",10];
  _this addmagazineCargoGlobal ["30Rnd_556x45_G36",10];
  _this addmagazineCargoGlobal ["30Rnd_556x45_Stanag",30];
  _this addmagazineCargoGlobal ["15Rnd_9x19_M9SD",10];
  _this addmagazineCargoGlobal ["ItemHeatPack",15];
  _this addmagazineCargoGlobal ["ItemPainkiller",5];
  _this addmagazineCargoGlobal ["ItemMorphine",5];
  _this addmagazineCargoGlobal ["ItemBloodBag",5];
  _this addmagazineCargoGlobal ["ItemAntibiotic",5];
 
  _this addbackpackCargoGlobal ["DZ_Backpack_EP1",2];
  _this setPos [14236, 494.5, 6.05];
};

I have similar code to spawn, food, vehicle parts, medical and base building urals at my sector FNG and all works fine. Hope this helps others. Basically if you spawn urals in with the 3d mission editor you can goto the mission.sqf file you converted for your server and add parts of the code above todo what you want to them.

My next mission is to install sarge 1.5 and persistance spawn soldiers on sectorFNG :p Fingers crossed :p
 
I would love to know how you got that island together so nicely! Maybe a few pointers? Everytime I have 2 or more platforms, terraces, whatever, that touch, once in game they disappear or change elevation. Not asking for the work youve done above, just maybe a simple tut on how to prevent my issue. Thanks and nice work!
 
I would love to know how you got that island together so nicely! Maybe a few pointers? Everytime I have 2 or more platforms, terraces, whatever, that touch, once in game they disappear or change elevation. Not asking for the work youve done above, just maybe a simple tut on how to prevent my issue. Thanks and nice work!

Best way I done it was to put a few objects down and save mission. Open the mission.biedi file and look at the XYZ coordinates of the objects you put down. Edit them so all the X coordinates lineup, etc as an example. Example code of my piers.

Code:
class _vehicle_00
{
    objectType="vehicle";
    class Arguments
    {
        POSITION="[14000, 400.6]";
        TYPE="land_nav_pier_c_big";
        AZIMUT="-90";
        PARENT="";
    };
};
class _vehicle_01
{
    objectType="vehicle";
    class Arguments
    {
        POSITION="[14000, 440.6, 0]";
        TYPE="land_nav_pier_c_big";
        AZIMUT="-90";
        PARENT="";
    };
};
class _vehicle_02
{
    objectType="vehicle";
    class Arguments
    {
        POSITION="[14000, 480.6, 0]";
        TYPE="land_nav_pier_c_big";
        AZIMUT="-90";
        PARENT="";
    };
};
class _vehicle_03
{
    objectType="vehicle";
    class Arguments
    {
        POSITION="[14000, 520.6, 0]";
        TYPE="land_nav_pier_c_big";
        AZIMUT="-90";
        PARENT="";
    };
};
class _vehicle_04
{
    objectType="vehicle";
    class Arguments
    {
        POSITION="[14000, 560.6, 0]";
        TYPE="land_nav_pier_c_big";
        AZIMUT="-90";
        PARENT="";
    };
};


Save Biedi file and load reload in editor. They might show a fraction out of place in editor, but Ignore that. Aslong as its right in the biedi file. Save again if it looks ok so it saves the new coordinates in the mission.sqf. Alot of trail and error as you try and work out the dimensions of the object. Took me a full week to build that island and long hours lol. But if you want things to be straight! Do it manually in the biedi file!
 
Back
Top