Forum Jump :

Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#1 Posted at 2015-08-30 14:53        
     
hey guys looking to make a script to place sand bag wall where the player is looking and give the object the same direction as the player in MP with Respawns but i also want it to check if the player has a toolkit in order to place it.

i know i will need a addAction to do this and to set a condition for respawn so the palyer gets the action again after death.

im thinking something like this would be a start but not sure how to set it up

mission int
player addMPEventHandler ["mpkilled", {Null = _this execVM "sandbag.sqf";}];

in player int
_SandBagAct = this addAction ["Build Sandbag wall", "sandbag.sqf"]

sandbag.sqf

if player has typeOf "toolkit" then{
_veh = createVehicle ["Land_BagFence_Long_F", position aimPos player, [], 0, "CAN_COLLIDE"];
_degrees = getDir player;
_veh = setDir player;
};

This post was edited by shadowmarine578 (2015-09-01 15:27, 779 days ago)


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#2 Posted at 2015-08-30 16:43        
     
init.sqf:
if (hasInterface) then {[] execVM "sandbag.sqf"};

sandbag.sqf:
removeSandbagAction = ["Remove Sandbag", {
    _unit = _this select 1;
    [_this select 0, _this select 2] remoteExec ["removeAction", 0, true];
    _anim = "AinvPknlMstpSnonWnonDnon_medic_1";
    _unit playMove _anim;
    waitUntil {animationState _unit == _anim || !alive _unit};
    waitUntil {animationState _unit != _anim || !alive _unit};
    if (!alive _unit) exitWith {};
    deleteVehicle (_this select 0);
}, [], 5, true, true, "", "'ToolKit' in items _this && (_target distance _this) < 3"];
putSandbagAction = ["Place Sandbag", {
    _unit = _this select 1;
    _anim = "AinvPknlMstpSnonWnonDnon_Putdown_AmovPknlMstpSnonWnonDnon";
    _unit playMove _anim;
    waitUntil {animationState _unit == _anim || !alive _unit};
    waitUntil {animationState _unit != _anim || !alive _unit};
    if (!alive _unit) exitWith {};
    _veh = createVehicle ["Land_BagFence_Long_F", _unit modelToWorld [0, 1.5, 0], [], 0, "CAN_COLLIDE"];
    _veh setDir (getDir _unit);
    [_veh, removeSandbagAction] remoteExec ["addAction", side _unit, true];
}, [], 4, true, true, "", "_this isEqualTo _target && 'ToolKit' in items _this"];
player addAction putSandbagAction;
player addEventHandler ["Respawn", {(_this select 0) addAction putSandbagAction}];

I've also had a idea where you whouldn't be able to remove sandbags if it was placed by another side, do you need that sort of thing?

EDIT (30/09/2015): Improved script. If the player dies during an animation the action is now canceled, also only players of the same team can remove sandbags.

This post was edited by 654wak654 (2016-04-02 04:09, 565 days ago)

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Advertisement


Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#3 Posted at 2015-08-30 18:07        
     
*THUMBS UP* *BRAVO* *DRINK* DUDE 654wak654 you sir are the man!!!!!!!!!!!!! most of my missions are coop but we do plan to go pvp later so so yea that would be a great idea!

1 question in the init.sqf the hasInterface var is that checking if the user is in game and alive?


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#4 Posted at 2015-08-30 19:22        
     
Glad you liked it, I'm pretty proud with this too.

hasInterface returns false on dedicated servers and headless clients, it's perfect for player-only scripts.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#5 Posted at 2015-08-30 19:58        
     
oh i just had a idea could we add a build time to it like a progress bar so we could add other objects like bunkers but that would take time to build up realistically. sand bags would take like 5 seconds and bunkers would take 30 to 60 seconds. kinda like the revive option in the vanilla Arma revive.


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#6 Posted at 2015-08-30 20:54        
     
I kinda don't see how a whole bunker whould appear, and sandbags are deploying quick enough so they don't need a progress bar. If you want more advanced stuff you could use [R3F] Logistics instead of us making a small less practical version of a logistics script.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#7 Posted at 2015-09-01 15:28        
     
is there a way to make this script jip capable? players who join after mission start cant use the action


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#8 Posted at 2015-09-01 15:54        
     
Which action? The addSandbagAction should be usable regardless. If not there is a whole unseen problem.

Putting this line instead of line #4 should fix the remove action for JIP though:
[_sb, (_this select 2)] remoteExec ["removeAction", 0, true];

This post was edited by 654wak654 (2015-09-22 15:45, 758 days ago)

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 3
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#9 Posted at 2016-02-25 23:14        
     
I have put this on my home server to test but it dosent work the player puts his hand out like he is putting something there but nothing appears. Is this easily fixed?


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#10 Posted at 2016-02-26 00:06        
     
How is your setup? Just tested it and it seems to work as usual.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 3
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#11 Posted at 2016-02-26 10:40        
     
# 654wak654 : How is your setup? Just tested it and it seems to work as usual.
In what way?
its a normal dedicated server running the wasteland missionthe only part of it that doesnt work is leaving the sandbag every other part of it works. i even tried changing the type of sandbag but no go


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#12 Posted at 2016-02-26 17:32        
     
I can't see any reason why it whould go all the way to the animation then just not create the sandbag. Maybe there is a security thing in the wasteland mission or your server, blocking some scripts from using the createVehicle command. Can't do anything on my part.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#13 Posted at 2016-02-26 19:09        
     
_unit? not defined if I'm right. replace all _unit by _caller

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#14 Posted at 2016-02-26 20:07        
     
# Pierre MGI : _unit? not defined if I'm right. replace all _unit by _caller

Had a broken version on here I guess. Fixed.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 3
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#15 Posted at 2016-02-27 09:52        
     
# Pierre MGI : _unit? not defined if I'm right. replace all _unit by _caller
Yip that did the trick thanks guys :)