Jump to content
daskunk

Vehicle Respawn Module

Recommended Posts

Gents, noob here but have an other question = how can I make a vehicle being a part of the ticket system ?? what I would like to do is when a vehicle is being destroyed a certain number of tickets will be deducted from the tickets - ideas please - thanks

 

Share this post


Link to post
Share on other sites

For the vehicle itself, it's simple, you have a "tickets" field in the module (or param in my script);

For punishing a player, you need to add a little code in the field of each vehicle you would like to protect with that:

 

this addMPEventHandler ["MPkilled", { [(_this select 2),-1,true] call BIS_fnc_respawnTickets}];

 

You can change the -1 value with the penalty you want.

  • Thanks 1

Share this post


Link to post
Share on other sites

@pierremgi - thanks yr info checking this after and let y know when succeeded :drinking2:

 

Edit: Just checked - Srry but I did forget to tell that I don't want to use vehicle respawn module :dozingoff: .... ideas ??

Share this post


Link to post
Share on other sites

This code works as soon as a vehicle as destroyed by a unit, independently of respawning or not. Killer is punished (for this vehicle). You can script some conditions.

You can also have a respawn vehicle system, apart, like this one. :whistle:

Share this post


Link to post
Share on other sites

@pierremgi - just tested again, min ago ...    WORKS !!!! - but would like to get a ticket deducted from the side the vehicle belongs, is that possible ?? - looking to yr script now - thanks

Share this post


Link to post
Share on other sites

Sure! do what you want. in the init field of some vehicle you like:

this addEventHandler ["killed",{
  params ["_killed","_killer","_instigator","_side"];
  if (count crew _killed >0) then {
    _side = [_killed,false] call bis_fnc_objectSide
  } else {
    _side = [_killed,true] call bis_fnc_objectSide
  };
  [_side,-1,false] call BIS_fnc_respawnTickets
}];

 

For example, if the vehicle (empty or not) is a WEST model, the WEST side will loose one point. But, If EAST unit(s) are inside a WEST made hunter (as crew), the point is subtracted to EAST.

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Fabulous!! , thanks again man - testing this p.m.

Share this post


Link to post
Share on other sites

@pierremgi  -  it works like a charm only have the following error, could you plz have a look, I have no clue - thanks

 

234M6oF.png

 

 

Edit: understand it's an ACE thing, afraid we have to wait  

 

 

JsPwc32.png

 

Share this post


Link to post
Share on other sites

@pierremgi - need a little help again from y if you dont mind. I want to punish a player/side with bleeding tickets when they kill a civilian. Been trying to do it myself but dnt succeed :dozingoff: - thanks

 

Share this post


Link to post
Share on other sites

civilian men? I can't test it but try:


 

this addEventHandler ["killed",{
   params ["_killed","_killer","_instigator","_side"];
   if (([_killed,true] call bis_fnc_objectSide == civilian or captive _killed) && !isnull _instigator) exitWith {
     [side _instigator,-1,false] call BIS_fnc_respawnTickets
   };
   if (count crew _killed >0) then {
     _side = [_killed,false] call bis_fnc_objectSide
   } else {
     _side = [_killed,true] call bis_fnc_objectSide
  };
  [_side,-1,false] call BIS_fnc_respawnTickets
}];

 

The problem is what you want to protect with that. I guess you can't copy/paste this code in all init fields of the units/vehicles.

So you can define an array of units. Never mind the method, just think about edited (3den) or spawned (in game). The second case needs a loop to refresh the array but, without treating the former units again and again.

 

First, the code is:

{ _x addEventHandler [.....]  } foreach AnArrayOfUnits; // can be [bob1,bob2,bob3] but also allUnits for example (men only), or vehicles (as written) or  allUnits + vehicles

 

Second, if you spawn some new units, you need to track the new units and "treat" them with EH. Two ways:

You treat them, immediatly once they spawn (I kept the case of an array here):

{ _x addEventHandler [....] } forEach arrayOfNewSpawnedUnits; // just after spawning code

 

or make a loop in init.sqf, waiting for some new arrival, considering general arrays like allUnits or vehicles:

[] spawn {

  while {true} do {

    { _x setVariable ["treated",true]; _x addEventHandler [....] } forEach AnArrayOfUnits select { !(_x getVariable ["treated",false]) };  // works fine with allUnits or vehicles

  }

};

 

 

.

 

Share this post


Link to post
Share on other sites

Thanks will test first thing in the mrng. I will use this in a TvT mission where towns are populated with civilians (AI). When a player/side kills a civi his side will be heavely punished with bleeding-out tickets. 

Share this post


Link to post
Share on other sites

@pierremgi - would like to have one more vafor from you; I need an invisable sector (have done this by a triggers) which works more or less like the vanilla sector control module. What I did is placing 2 triggers over each other and a marker somewhere on the map which changes colour when the trigger is activated by either side. I placed the fllw in the trigger/On Activation - "marker name" setMarkerColor "ColorRed"; hint "The platform is controlled by Opfor"; - and visa versa.

 

I would like to add tickets (repeatable) to the faction who has captured the trigger area - could you please help me out - thanks

Share this post


Link to post
Share on other sites

@Spoor We are a little bit far from the topic. If you need some more help with the respawn ticket, you should open another thread, useful for other readers. You problem is just question to select who triggered your trigger(s), so how do you wrote them. After that, your choice is simple.

Please open another thread, if you can't find some topic about about triggers.

Share this post


Link to post
Share on other sites

@pierremgi - srry for that. Im really a noob as regards to scripting etc but because of yr hint I fixed it :don13: - thanks

Share this post


Link to post
Share on other sites

Since everyone seems to have more idea than me, I have a question: what exactly do I have to write in the expression field in the respawn module menu, so that the vehicle respawns exactly as it was before (camouflage, components and most importantly the loadout of aircraft) ? There is only written that an array is passed with the new and the old vehicle. How exactly do I use this? Can someone please write the code for this here?

Share this post


Link to post
Share on other sites

Well it easy but first write how you get the vehicle at start as (camouflage, components and most importantly the loadout of aircraft)

Share this post


Link to post
Share on other sites
23 minutes ago, Lbbde said:

Since everyone seems to have more idea than me, I have a question: what exactly do I have to write in the expression field in the respawn module menu, so that the vehicle respawns exactly as it was before (camouflage, components and most importantly the loadout of aircraft) ? There is only written that an array is passed with the new and the old vehicle. How exactly do I use this? Can someone please write the code for this here?

I took time to write a script because the respawn module is limited.

Share this post


Link to post
Share on other sites
24 minutes ago, davidoss said:

Well it easy but first write how you get the vehicle at start as (camouflage, components and most importantly the loadout of aircraft)

The vehicles are placed in the editor and configured there via the corresponding functions (Edit appearance and pylons)

Share this post


Link to post
Share on other sites

editor vehicle init field:

 

if (isServer) then {
this setVariable [ "veh_customs", [
[this,typeOf this] call BIS_fnc_getVehicleCustomization,
[getWeaponCargo this,getMagazineCargo this,getItemCargo this,getBackpackCargo this],
getpos this,
direction this
],false];
};

 

editor vehicle respawn module expression field:

params [["_newVeh",objNull,[objNull]],["_oldVeh",objNull,[objNull]]];
private _paramcheck = (_oldVeh getVariable ["veh_customs",[]]) params [["_customs",[],[[]]],["_inventory",[],[[]]],["_position",[],[[]]],["_direction",0,[0]]];
if (!_paramcheck) exitWith {deleteVehicle _oldVeh};
_customs params [["_texture",[],[[]]],["_anime",[],[[]]]];
_inventory params [["_guns",[],[[]]],["_mags",[],[[]]],["_items",[],[[]]],["_backpack",[],[[]]]];
deleteVehicle _oldVeh;
[_newVeh, _texture, _anime, true] call BIS_fnc_initVehicle;
_newVeh setPos _position;
_newVeh setDir _direction;

clearWeaponCargoGlobal _newVeh;
clearMagazineCargoGlobal _newVeh;
clearItemCargoGlobal _newVeh;
clearBackpackCargoGlobal _newVeh;
for "_i" from 0 to ((count (_guns select 0)) -1) do {_newVeh addWeaponCargoGlobal [((_guns select 0) select _i),((_guns select 1) select _i)]};
for "_i" from 0 to ((count (_mags select 0)) -1) do {_newVeh addMagazineCargoGlobal [((_mags select 0) select _i),((_mags select 1) select _i)]};
for "_i" from 0 to ((count (_items select 0)) -1) do {_newVeh addItemCargoGlobal [((_items select 0) select _i),((_items select 1) select _i)]};		
for "_i" from 0 to ((count (_backpack select 0)) -1) do {_newVeh addBackpackCargoGlobal [((_backpack select 0) select _i),((_backpack select 1) select _i)]};	

editor vehicle respawn module parameter "wreck" set to "preserve".

Wreck will be deleted  by the code

  • Like 4

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

×