Announcement

Collapse
No announcement yet.

Eventhandler confusion

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Eventhandler confusion

    Well, I've been trying to make a civilian kill penalization script for a TvT I've been working on the past couple days and here is what I've come up with so far...

    I don't know what to put in the ??? part however as select 1 won't work by itself or under single quotations (returns as a string). Also, it appears that it may be impossible to return a faction off of this eventhandler?

    Code:
    if (!isServer) exitWith {};
    
    private ["_kFaction", "_cKil"];
    
    _this addEventHandler ["killed", "hint format['Killed by %1',_this select 1]"];
    _this addEventHandler ["killed", "_kFaction = (faction ???)"];
    
    cKil = True;
    
    while {_cKil} do
    {
    	if (!alive _this) then
    	{
    		sleep 1;
    		hint format["Faction: %1", _kFaction];
    		if (_kFaction == "ACE_BLUFOR_USMC_DESERT") then
    			{
    				TicketsWest = TicketsWest - 10;
    				sleep 0.1;
    				publicVariable "TicketsWest";
    			};
    		_cKil = False;
    	};
    	sleep 10;
    };

    Damnit Blizzard, fix ZvT already >.<
    In Soviet Russian, Arma admins are nice to you!

  • #2
    Re: Eventhandler confusion

    Try:

    Code:
    if (!isServer) exitWith {};
    
    private ["_kFaction", "_cKil"];
    
    _this addEventHandler ["killed", "hint format['Killed by %1',_this select 1]; (_this select 0) setVariable ['myFaction', format['%1', faction (_this select 0)], false];"];
    
    _cKil = true;
    
    while {_cKil} do
    {
    	if (!alive _this) then
    	{
    		sleep 1;
                   _kFaction = _this getVariable "myFaction";
    		hint format["Faction: %1", _kFaction];
    		if (_kFaction == "ACE_BLUFOR_USMC_DESERT") then
    			{
    				TicketsWest = TicketsWest - 10;
    				sleep 0.1;
    				publicVariable "TicketsWest";
    			};
    		_cKil = False;
    	};
    	sleep 10;
    };

    I take it this script is called from the init line of some civilians? Something like:

    Code:
    nul = [this] execVM "thisScript.sqf";
    ?


    EDIT: New stuff.

    Comment


    • #3
      Re: Eventhandler confusion

      Yeah this is called from the civilians init line through execVM.

      Just tested out your script and it is halfway to where I want it to be. I want it to run a check on the killer and not the civilian as to what faction they are on though. This will be used in a TvT so I don't want the insurgents forcing negative tickets onto the usmc by them killing civilians.

      Just for clarification: the check shows the faction of the person killed, not the killer with your version.

      I tried swapping out _this select 0 for _this select 1 and also just select 1 but it didn't return anything other than a <null>.

      Damnit Blizzard, fix ZvT already >.<
      In Soviet Russian, Arma admins are nice to you!

      Comment


      • #4
        Re: Eventhandler confusion

        Ah, change:

        Code:
        _this addEventHandler ["killed", "hint format['Killed by %1',_this select 1]; (_this select 0) setVariable ['myFaction', format['%1', faction (_this select 0)], false];"];
        to

        Code:
        _this addEventHandler ["killed", "hint format['Killed by %1',_this select 1]; (_this select 0) setVariable ['myFaction', format['%1', faction (_this select 1)], false];"];

        Should work then. Testing is always nice though.

        Comment


        • #5
          Re: Eventhandler confusion

          It works, thanks a bunch beta :)

          Damnit Blizzard, fix ZvT already >.<
          In Soviet Russian, Arma admins are nice to you!

          Comment

          Connect

          Collapse

          TeamSpeak 3 Server

          Collapse

          Advertisement

          Collapse

          Twitter Feed

          Collapse

          Working...
          X