OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: MadMartigaN on 25 Mar 2009, 13:20:19

Title: Medkit script problem
Post by: MadMartigaN on 25 Mar 2009, 13:20:19
Hi all script gurus! :)
I'm really new to scripting so please bear with me. (I'm in the process of learning scripting)

It's not for ArmA but VBS2, but its no difference.

What i want with the script is that you can use the medkit on you or a friend/friends if you have a medkit.
It works on you but not on friend/friends and the vbs2_medkit_use* doesn't seems to work?

*Name on the medkit in VBS2 (I think?!) Maybe you know a way to get the correct name on the medkit if it's wrong.

File: init.sqf
Code: [Select]
// Heal
{_x addaction ["Heal", "scripts\heal.sqf"]} foreach
[
s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21
];

// MedKit
{_x addMagazine "vbs2_medkit_use"} foreach
[
s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21
];


File: heal.sqf
Code: [Select]
disableUserInput true;
player playMove "AinvPknlMstpSlayWrflDnon_medic";
player removeMagazine "vbs2_medkit_use";
player setdammage 0;

sleep 8;
disableUserInput false;
if (true) exitWith {};


I've tried this but it's not working at all: (Not my work)
Code: [Select]
// Heal other
{_x addAction ["Heal Target", "scripts\heal.sqf", (nearestObjects [player, "Man", 5] select 0)]} forEach
[
     s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21
];

Code: [Select]
_target = _this select 3;

disableUserInput true;
player playMove "AinvPknlMstpSlayWrflDnon_medic";
player removeMagazine "vbs2_medkit_use";

if(isNull _target)then
{
     player setDammage 0;
}
else
{
     _target setDammage 0;
};

sleep 8;
disableUserInput false;

if(true)then
{
     exitWith {};
};

Appreciate all the help a can get.
Thanks,

Rikard
Title: Re: Medkit script problem
Post by: LCD on 26 Mar 2009, 13:34:06
im a "little bit" rusty but wud say that in the 1st script the problem with the healing of others is that in the heal.sqf file u have only to heal the play (look at it... it says player setdamage 0)

as for the other... it seems very unstable to me... that would fail in lotsa cases...

also i dont have any idea about the VBS2 thing (infelizmente ive got ArmA)...

but i wud have changed the healing action to b added to the target... seems better to me... i havnt scripted in a year and a bit (hence... rusty) but it shudnt b 2 hard...

LCD OUT

p.s

WELCOME 2 OFPEC M8  :D
Title: Re: Medkit script problem
Post by: h- on 26 Mar 2009, 20:33:19
Welcome to OFPEC :welcome:

Code: [Select]
It's not for ArmA but VBS2, but its no difference.Well, this really isn't true in all cases because VBS2 has a lot that is not implemented in ArmA :P

And, we don't really allow VBS editing stuff here (since we're about the BIS game side only) so I'm hoping this doesn't become a growing trend since there is the VBS forum for the users of that software..  :whistle:  :shhh:


Anyhoo, try this:
Code: (addAction ["Heal Target","healfella.sqf") [Select]
private ["_user","_target"];

_user = _this select 0;
if ("vbs2_medkit_use" in (magazines _user)) exitWith {hint "No Medikit in inventory"};


disableUserInput true;
_user removeMagazine "vbs2_medkit_use";
_target = ((_user nearObjects ["Man",3])-[_user]) select 0;
if (format ["%1",_target] == "<null>") exitWith {hint "No one to heal here.."; disableUserInput false};
_user playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 8;
if (alive _target)
 then {_target setDamage 0};
 
disableUserInput false;
Should work, no idea how it does in MP though..
Title: Re: Medkit script problem
Post by: MadMartigaN on 27 Mar 2009, 08:12:05
Really appreciate all the help! Sorry for posting VBS2 script problem here.


Thanks, the Arma community is the best!

(If someone is interested in help me with some scripting, contakt me) :whistle:
Title: Re: Medkit script problem
Post by: h- on 27 Mar 2009, 15:19:46
Quote
Sorry for posting VBS2 script problem here.
Not a biggy.. :)
Besides, if you disguise it to be for ArmA no-one knows  :D  :D


So I take it that the script worked?
Title: Re: Medkit script problem
Post by: MadMartigaN on 30 Mar 2009, 10:19:58
I play OFP/ArmA on my spare time. :D

The script has it's problems.
My avatar he is standing still and the the other one doing the "AinvPknlMstpSlayWrflDnon_medic" with no effect.

Medkits name: vbs2_mag_medkit

 :dunno: ???

Appreciates your help!
Thanks,

Rikard
Title: Re: Medkit script problem
Post by: h- on 30 Mar 2009, 11:40:00
Try changing "vbs2_medkit_use" in the script to "vbs2_mag_medkit"
Title: Re: Medkit script problem
Post by: Rommel92 on 31 Mar 2009, 00:28:54
Code: [Select]
private ["_user","_target"];

_user = _this select 0;
if ("vbs2_mag_medkit" in (magazines _user)) exitWith {hint "No Medikit in inventory"};


disableUserInput true;
_target = ((_user nearObjects ["Man",3])-[_user]) select 0;
if (format ["%1",_target] == "<null>") exitWith {hint "No one to heal here.."; disableUserInput false};
_user removeMagazine "vbs2_mag_medkit";
_user playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 8;
if (alive _target)
 then {_target setDamage 0};
 
disableUserInput false;

I moved around your removeMagazine, it seemed strange if "No one to heal here.." but you threw away your medkit anyway...
Title: Re: Medkit script problem
Post by: h- on 31 Mar 2009, 09:52:33
 :-[

Well, I don't claim sucking at scripting for nothing..  ::)
Title: Re: Medkit script problem
Post by: MadMartigaN on 08 Apr 2009, 08:23:44
Code: [Select]
private ["_user","_target"];

_user = _this select 0;
if ("vbs2_mag_medkit" in (magazines _user)) exitWith {hint "No Medikit in inventory"};


disableUserInput true;
_target = ((_user nearObjects ["Man",3])-[_user]) select 0;
if (format ["%1",_target] == "<null>") exitWith {hint "No one to heal here.."; disableUserInput false};
_user removeMagazine "vbs2_mag_medkit";
_user playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 8;
if (alive _target)
 then {_target setDamage 0};
 
disableUserInput false;

I moved around your removeMagazine, it seemed strange if "No one to heal here.." but you threw away your medkit anyway...
The target is not getting heald?

Thanks,

Rikard
Title: Re: Medkit script problem
Post by: Luke on 19 Apr 2009, 00:06:03
Instead of:
Code: [Select]
if (alive _target)
 then {_target setDamage 0};
try;
Code: [Select]
if ((getdammage _target)<1)
 then {_target setDammage 0};
Title: Re: Medkit script problem
Post by: MadMartigaN on 20 Apr 2009, 10:06:43
The avatar that is hurt he does the "AinvPknlMstpSlayWrflDnon_medic", but he is still hurt. ???