Jump to content

Adesso

Member
  • Content Count

    2
  • Joined

  • Last visited

  • Medals

Community Reputation

10 Good

About Adesso

  • Rank
    Newbie

core_pfieldgroups_3

  • Occupation
    IT Manager
  1. Thanks for the heads-up on the bug, but I think I am getting somewhere. I have now tried naming the guards... g1 g2 g3.. on my Task init script I then assign the EventHandlers via the name and changed my script to this _obj = _this select 0; _obj removeEventHandler ["killed", 0]; sleep 10; ?!(alive g1) : hint 'Guards 1 Killed '; ?!(alive g2) : hint 'Guards 2 Killed '; ?!(alive g3) : hint 'Guards 3 Killed '; ?(!(alive g1)&&!(alive g2)&&!(alive g3)) : hint 'ALL Guards Killed'; It seems it's counting right now... but I am so confused as to what the right syntax should be.. :confused: I'll post more results as I make progress... ---------- Post added at 04:15 PM ---------- Previous post was at 04:01 PM ---------- Finally I got it to work _obj = _this select 0; _obj removeEventHandler ["killed", 0]; sleep 10; ?!(alive g1) : hint 'Guards 1 Killed '; ?!(alive g2) : hint 'Guards 2 Killed '; ?!(alive g3) : hint 'Guards 3 Killed '; ?(!(alive g1)&&!(alive g2)&&!(alive g3)) : hint 'ALL Guards Killed'; task2 setTaskState "SUCCEEDED"; [task2] call mk_fTaskHint; What is REALLY puzzeling me is that I have to use this if syntax ?():; and not the if() then{}else{}; So far learning this scripting language has got to be THE MOST confusing experience in my coding life... It took me 6 hours to solve this simple problem.... phew
  2. Greetings. I am breaking my head here, and have tried a million variations, but can't seem to get simple variable addition and testing to work. Can someone help me please. The Idea. A soldier is unarmed, and gets a task to move to a location. Working 100% A Trigger on the way assigns a gun to the soldier and new task. Working 100% The new task is to kill 3 people. Not working Now I have tried so many flavours I am almost crying. The 3 people he has to kill is not in a group, nor are they the only 3 people in a area. So what I have done is to add on there init box this addEventHandler ["killed", {_this exec "kill_task2.sqf"}]; in my kill_task2.sqf file I have _this removeAllEventHandlers "killed"; _bodies = player getVariable "num_task2"; if ( _bodies > 2) then { hint format['Guards Killed %1',_bodies]; task2 setTaskState "SUCCEEDED"; [task2] call mk_fTaskHint; } else { _bodies = _bodies + 1; player setVariable ["num_task2", _bodies]; hint format['Guards Killed %1',_bodies]; }; The idea is to simply call the script on the kill, incrament the kill count, and when all 3 guards are dead, finish the task... Right now The scripts is called twice for every kill, resulting in double numbers on the hint, and both the if and else is executing??? What am I doing wrong here... ---------- Post added at 03:35 PM ---------- Previous post was at 02:00 PM ---------- So I have simpliefied the script even more... _obj = _this select 0; _obj removeEventHandler ["killed", 0]; num_task2 = num_task2 + 1; hint format['Guards Killed %1',num_task2]; but still get 2 Guards killed if I kill only 1 another version _obj = _this select 0; _obj removeEventHandler ["killed", 0]; sleep 10; num_task2 = num_task2+1; hint format['Guards Killed %1',num_task2]; sleep 10; if (num_task2==3) then { task2 setTaskState "SUCCEEDED"; [task2] call mk_fTaskHint; } This one starts to count better, but sometime I get a 2 count and sometime a 1 ???
×