Forum Jump :

Author Message


Posts: 33
Rank:


Level: Member

Country: us
Location: FL , US
Occupation:
Age:
In-game name: R.Danh or darkstaride

 
#1 Posted at 2016-02-25 01:12        
     
Hello, Armaholic community.
Can someone help me how to make this?
Currently, I'm trying to make a PVP thing but when you get shot you get teleported instead of dying.

Heres what I got so far.

First you use a flag to teleport to an area

_tele = _this select 0;		//location
_unit = _this select 1;		//caller

_unit setPos (getPos (red_team));
hint "Red Team";

//Put unit to godmode
_unit allowdamage false;

//Add Eventhandler
_unit addMPEventHandler ["MPHit", {_this setPos (getPos (out_team));}];
I have a gamelogic called out_team and when I use an Ai to shoot at me, it doesn't work. I tired using a player also.

Update - Maybe this will work?

_tele = _this select 0;		//location
_unit = _this select 1;		//caller

_unit setPos (getPos (red_team));
hint "Red Team";

//Put unit to godmode
_unit allowdamage false;

hint "working";
//Add Eventhandler
_unit addMPEventHandler ["MPHit", {
	if (damage _unit > 0.8) then
	{
	_unit setdamage 0;
	hint "PRE-TELE";
	_unit setPos (getPos (out_team));
	hint "TELE";
	_unit setdamage 0;
	;}];

This post was edited by darkstaride (2016-02-25 01:25, ago)


Author Message


Posts: 1526
Rank:


Level: Member

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

 
#2 Posted at 2016-02-25 02:10        
     
can't say for sure but one thing is that _unit won't work in the evh you need to find the object by selecting the parameter

example
_unit addMPEventHandler ["MPHit", {
	if (damage (_this select 0) > 0.8) then
	{
	(_this select 0) setdamage 0;
	hint "PRE-TELE";
	(_this select 0) setPos (getPos (out_team));
	hint "TELE";
	(_this select 0) setdamage 0;
	;}];


Advertisement


Author Message


Posts: 33
Rank:


Level: Member

Country: us
Location: FL , US
Occupation:
Age:
In-game name: R.Danh or darkstaride

 
#3 Posted at 2016-02-25 03:05        
     
# F2kSel : can't say for sure but one thing is that _unit won't work in the evh you need to find the object by selecting the parameter

example
_unit addMPEventHandler ["MPHit", {
	if (damage (_this select 0) > 0.8) then
	{
	(_this select 0) setdamage 0;
	hint "PRE-TELE";
	(_this select 0) setPos (getPos (out_team));
	hint "TELE";
	(_this select 0) setdamage 0;
	;}];

It doesn't work either..


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#4 Posted at 2016-02-25 03:46        
     
Yes,
player addMPEventHandler ["MPHit", {
  if (damage (_this select 0) > 0.8) then {
    (_this select 0) setdamage 0;
    (_this select 0) setPos (getPos (out_team));
    hint "TELE";
  };
}];

You don't need to repeat the setdamage (teleportation is safe). 2 hints without delay are useless, the second one crushes the first one.
But, overall, it will be hard to catch a damage > 0.8 without being killed!
Overall damage is a weird, non-correlated thing with hitpoints damages.
To test your EH, I first threw 2 grenades not too far. Bleeding and unable to run, overall damage was 0.09!!
If you test with player setdamage 0.8 + , keep on mind you need also to be hit by a projectile. The command setdamage doesn't trigger the EH.

If you're motivated, here is a better way to handle damage!

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: 23
In-game name: Wak

 
#5 Posted at 2016-02-25 05:18        
     
Both the Hit and MPHit hit event handlers literally have this in the wiki:
Does not fire when a unit is set to allowDamage false.


So like Pierre mentioned, you're better off using HandleDamage:
_unit = _this select 1; //caller
_unit setPos (getPos red_team);
hint "Red Team";

//Put unit to godmode
_unit allowDamage false;

//Add Eventhandler
if (isNil "handlerAdded") then {
	_unit addEventHandler ["HandleDamage", {_this setPos (getPos out_team)}];
	handlerAdded = true; //Make sure it's only addded once
};

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

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 36
In-game name: Tajin

 
#6 Posted at 2016-02-25 10:35        
     
You're probably better off to assign that eventhandler to all players from the start and then only work with object variables to tell it what to do.

Like this:
// init.sqf
if (!isDedicated) then {
    player setVariable["team","none",true];
    player addEventHandler
    [
        "HandleDamage",
        {
            _unit = _this select 0;
            if ((_this select 1) == "") then {
                switch (_unit getVariable "team") do {
                    case "none": { 
                        hint "no team yet";
                    };
                    case "out_team": { 
                        hint "already out";
                    };
                    case "red_team": { 
                        _unit setVariable["team","out_team",true];
                        _unit setPos (getPos out_team);
                    };
                    case "blue_team": { 
                        _unit setVariable["team","out_team",true];
                        _unit setPos (getPos out_team);
                    };

                };
            };
            0; // this negates all damage
        }
    ];
};

Your flag would do this:
_tele = _this select 0;     //location
_unit = _this select 1;     //caller

_unit setVariable["team","red_team",true];
_unit setPos (getPos (red_team));
hint "Red Team";

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.

Author Message


Posts: 33
Rank:


Level: Member

Country: us
Location: FL , US
Occupation:
Age:
In-game name: R.Danh or darkstaride

 
#7 Posted at 2016-02-27 05:23        
     
Thank you all guys for your responses!