Jump to content
Sign in to follow this  
1para{god-father}

addEventHandler to create Marker and name

Recommended Posts

Need some more help please !

I am adding this to the ALICE module to try and capture who killed the civilian. and then in the script create a marker with the Player name how can I get the Players name i.e "MyGameNameisblar blar" not the units name i.e "s1" , and then how do i pass the possition to teh script.

Never used EH before so very lost , hope some of the below is correct !?


_ALICE setVariable ["ALICE_civilianinit",[{
	_this addEventHandler ["Killed",{
		if(side (_this select 1) == West || isNull (_this select 1)) then{
			[_this select 1]execVM "civilians\civdeath.sqf";
		};
	}];
}]];

civilians\civdeath.sqf

//// how do I get the position of the Killed  Civilian and the players Name////


///// players name////
_pid =_this select 1;
_t = format["Civillian Killed by %1",_pid];

////ID
_cid = floor(random 10000);
_id = format["Civillian %1",_cid];


[_id, ??location??, "Icon", [1,1], "TEXT:", _t, "TYPE:", "Dot", "COLOR:", "ColorRed", "GLOBAL", "PERSIST"] call CBA_fnc_createMarker;

Share this post


Link to post
Share on other sites

_ALICE setVariable [ "ALICE_civilianinit", [{_this addEventHandler ["Killed", {[this]execVM "civilians\civdeath.sqf";} ]; }] ];

//civdeath.sqf
_civ = _this select 0;
_killer = _this select 1;

if (isPlayer _killer) then {
 mnum = mnum + 1;
 _mname = format["killmarker%1",mnum];
 _marker = createMarkerLocal [_mname, getPos _civ];
 _mname setMarkerTypeLocal "Warning";
 _mname setMarkerTextLocal format ["Civilian killed by %1", name _killer];
};

Something like this.

Share this post


Link to post
Share on other sites

I am having an issue with this i get a message as follows:-

<createMarkerLocal [_marker, getPos _civ];>
 Error 0 elements provided, 3 expected

so i am presuming it is not passing anything to this script ?

Share this post


Link to post
Share on other sites

can't remember immediately, but isn't createmarkerlocal require a [x,y] position rather than the [x,y,z] that getpos returns. if so maybe try screenToWorld that can convert 3d to 2d.

Share this post


Link to post
Share on other sites

screenToWorld has a different use.

Here..

//civdeath.sqf
_civ = _this select 0;
_killer = _this select 1;

if (isPlayer _killer) then {
 mnum = mnum + 1;
 _mname = format["killmarker%1",mnum];
 _marker = createMarkerLocal [_mname, [(getPos _civ) select 0, (getPos _civ) select 1]];
 _mname setMarkerTypeLocal "Warning";
 _mname setMarkerTextLocal format ["Civilian killed by %1", name _killer];
};

Share this post


Link to post
Share on other sites

Still the same, I think it is not passing anything as when I just place a simple marker down using players position I get the Killers name is <Null>

So for some reason it is not passing anything to the kill script from the EH ?

Share this post


Link to post
Share on other sites

My bad.

The error was here:

_ALICE setVariable [ "ALICE_civilianinit", [{_this addEventHandler ["Killed", {[[b]_[/b]this]execVM "civilians\civdeath.sqf";} ]; }] ];

Forgot the "_" in front of "this". *facepalm*

Share this post


Link to post
Share on other sites

Cool thanks got it working well chuffed !

My next question is , is there any way I can get the players real name and not the name I gave to the Unit i.e "s1" I wouls like there gamers name? is that possible ?

I know i can use the below to get theer name but not sure how i tie that into who killed the civi ?

name player;

Edited by psvialli

Share this post


Link to post
Share on other sites

_mname setMarkerTextLocal format ["Civilian killed by %1", [size=4]name _killer[/size]];

Doesnt that already display the right name ?

Share this post


Link to post
Share on other sites

:j: errr yes it does i missed the "name" bit out ooppps

All 100% working Many Many thanks for your time !!!!!!

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
Sign in to follow this  

×