cougarxr7 1 Posted July 16, 2010 (edited) Hello, In my mission I have the killcam. However to get it to work I have to use 2 triggers per player. 30 players = 60 triggers, but I have never had 30 players in the server before. I have had 25 and never seemed to have a problem. For some reason I got to thinking that many triggers can't be good. Not sure, but it seems like a lot just to have the killcam to work and I think I read somewhere too many triggers can cause mission problems. Anyway I got to thinking there must be a way that 2 created triggers can do all this work. So I scripted a 2 trigger sqf file, called killcam.sqf I used different ways to execVM this file. I used a trigger, in the init.sqf, in the spawn.sqf, and the players init. It did not seem to make a difference how the file was execVM. killcam.sqf _units = ["p1","p2","p3","p4","p5","p6","p7","p8","p9","p10","p11","p12","p13","p14","p15","p16","p17","p18","p19","p20","p21","p22","p23","p24","p25","p26","eng1","eng2","eng3","eng4"]; _pos = position player; _i = 0; player setpos [_pos select 0,_pos select 1,0]; /* while {_i < (count _units)} do { _trgobj2 = createTrigger ["EmptyDetector",_pos]; _trgobj2 triggerAttachVehicle [player]; _trgobj2 setTriggerActivation ["Vehicle", "PRESENT", true]; _trgobj2 setTriggerArea [30, 30, 0, true]; _trgobj2 setTriggerStatements ["this", "evh_1 = [player execVM 'scripts\killed.sqf'",""]; sleep 0.5; _trgobj3 = createTrigger ["EmptyDetector",_pos]; _trgobj3 setTriggerActivation ["NONE", "PRESENT", true]; _trgobj3 setTriggerArea [30, 30, 0, true]; _trgobj3 setTriggerStatements ["(!alive player)", "player removealleventhandlers 'killed'",""]; _i = _i +1;//<added, pointed out by seba1976 }; */ while {_i < (count _units)} do { _trgobj2 = createTrigger ["EmptyDetector",_pos]; _trgobj2 triggerAttachVehicle [player]; _trgobj2 setTriggerActivation ["Vehicle", "PRESENT", true]; hint format ["VEHICLE= %1",player]; sleep 5; _trgobj2 setTriggerArea [30, 30, 0, true]; _trgobj2 setTriggerStatements ["this", "evh_1 = [player] execVM 'scripts\killed.sqf'",""]; hint format ["THIS= %1",this]; sleep 5; _trgobj3 = createTrigger ["EmptyDetector",_pos]; hint format ["PLAYER= %1",player]; sleep 5; _trgobj3 setTriggerActivation ["NONE", "PRESENT", true]; _trgobj3 setTriggerArea [10, 10, 0, true]; _trgobj3 setTriggerStatements ["(!alive player)", "player removealleventhandlers 'killed'",""]; _i = _i +1;//<added, pointed out by seba1976 }; There are 4 triggers in this file, they are the same, except the bottom 2 have hints in them for troubleshooting/debugging. File killcam.sqf was execVM from the init.sqf. The hint "VEHICLE" in _trgobj2 and the hint "PLAYER" of _trgobj3 would always be "p7" which that was the correct player slot I was in. This is where the fun began! The hint "THIS" was "false", then it was "true", then it was "Light4_1", then it was "Cobra1", then it was "p7" at random times, during testing! Strange behavior. If anyone can explain that please do! I hosted with my 1st. comp. and joined as a client with my 2nd comp. My results were this. Both players got the correct hints concerning player slots/name. Cougar was "p7", 1st comp/host, Cougarxr7 was "p8", 2nd comp/client. The hint "THIS" was false, then true, then false, false, then true, ect...ect... When Cougar "p7" shot Cougarxr7 "p8". nothing, Cougarxr7 would time out and respawn, everytime. But when Cougarxr7 shot Cougar, bam , the killcam script fired and Cougar would get the killcam everytime! So I fired up the mission on my dedicated server, both comps joined as clients and both comps never did get the killcam! Triggers did not fire or work on the dedicated server. Does anyone have any idea how the correct this?? What am I missing here? Here are the triggers hard coded from the sqm. class Item84 { position[]={9785.691406,139.994995,10067.715820}; a=30.000000; b=30.000000; activationBy="VEHICLE"; repeating=1; interruptable=1; age="UNKNOWN"; idVehicle=242; expActiv="evh_1= [p7] execvm ""scripts\killed.sqf"";"; class Effects { }; }; class Item85 { position[]={9785.878906,139.994995,10066.689453}; a=10.000000; b=10.000000; repeating=1; interruptable=1; age="UNKNOWN"; expCond="(!alive p7)"; expActiv="p7 removeAllEventHandlers ""killed"";"; class Effects { }; }; Thanks for the help! Edited July 16, 2010 by Cougarxr7 Share this post Link to post Share on other sites
seba1976 98 Posted July 16, 2010 _i should be incremented somewhere inside the while loop. Either you missed that or I fail to see where it's being done. I'm unsure if your general idea is right though, but let's start with the basics. Share this post Link to post Share on other sites
cougarxr7 1 Posted July 16, 2010 (edited) Totally missed that! I don't know why I thought it was.:j: Of course very easy, quick fix! Now that _i is being incremented. Any ideas about the other issues?? Thanks! Edited July 16, 2010 by Cougarxr7 Share this post Link to post Share on other sites
seba1976 98 Posted July 16, 2010 OK. Without an end for the loop, the result was caos :D, so you should repeat the test with that correction in place. But while you're at it, check the scope of the script, if it has to run only server side, or clientside, or both. As it is now, it's not taking that into account, and so the results will vary whether you have a dedicated server + clients, or a client/host + clients scenario. Also be sure that whatever method you use to run the script, the 'player' entity already exists (if you want to refer to it). If, for example, you execVM something through the init line of the player unit, and in the script try to reference to that player unit, it will not work for pure clients, because the player entity there is created after the briefing screen, while the execVM runs at the briefing screen. It's trial and error most of the time, but it's usually feasible. Check the documentation for the locality of things. Share this post Link to post Share on other sites
cougarxr7 1 Posted July 17, 2010 (edited) Ok, total rework on this script. After looking more closely. It dawned on me that it look as if I was having every player create 30 triggers with the, i = 0; while {_i < (count _units)} do trigger code; i = i +1; So I reworked it and got it to work this way. Placed in player init, variable name p7. evh_1 = [p7] execVM "killcam.sqf"; Placed in player init, variable name p8. evh_1 = [p8] execVM "killcam.sqf"; _pos = position player; player = _this select 0; switch (player) do { case p7://player variable name p7 { _trgobj2 = createTrigger ["EmptyDetector",_pos]; _trgobj2 triggerAttachVehicle [player]; _trgobj2 setTriggerActivation ["Vehicle", "PRESENT", true]; _trgobj2 setTriggerArea [30, 30, 0, true]; _trgobj2 setTriggerStatements ["this", "evh_1 = [p7] execVM 'scripts\killed.sqf'",""]; sleep 0.5; _trgobj3 = createTrigger ["EmptyDetector",_pos]; _trgobj3 setTriggerActivation ["NONE", "PRESENT", true]; _trgobj3 setTriggerArea [30, 30, 0, true]; _trgobj3 setTriggerStatements ["(!alive p7)", "p7 removealleventhandlers 'killed'",""]; }; case p8://player variable name p8 { _trgobj2 = createTrigger ["EmptyDetector",_pos]; _trgobj2 triggerAttachVehicle [player]; _trgobj2 setTriggerActivation ["Vehicle", "PRESENT", true]; _trgobj2 setTriggerArea [30, 30, 0, true]; _trgobj2 setTriggerStatements ["this", "evh_1 = [p8] execVM 'scripts\killed.sqf'",""]; sleep 0.5; _trgobj3 = createTrigger ["EmptyDetector",_pos]; _trgobj3 setTriggerActivation ["NONE", "PRESENT", true]; _trgobj3 setTriggerArea [30, 30, 0, true]; _trgobj3 setTriggerStatements ["(!alive p8)", "p8 removealleventhandlers 'killed'",""]; }; }; This worked on the dedicated server. However this way means scripting 2 triggers per player to get it to work for clients. that was not what I was trying for.:( I was hoping to get 2 triggers to do all this. I still believe that it can be done, I'm just not that sharp when it comes to scripting. In my previous post, the hints would return with the correct player variable name, p7 or p8. I tried some testing to see if I the game was seeing them like this. if ((player name) in _units) then hint "we got a player!"; I never got that hint except when I reverse the command with "not", then I got the hint. It's wierd how the "vehicle","player" hints would show the correct player variable name but, it didn't/couldn't find it in _units. I'd really like to figure that out. Edited July 17, 2010 by Cougarxr7 Share this post Link to post Share on other sites
seba1976 98 Posted July 17, 2010 In my previous post, the hints would return with the correct player variable name, p7 or p8. I tried some testing to see if I the game was seeing them like this. if ((player name) in _units) then hint "we got a player!"; I never got that hint except when I reverse the command with "not", then I got the hint. It's wierd how the "vehicle","player" hints would show the correct player variable name but, it didn't/couldn't find it in _units. I'd really like to figure that out. The function 'name' does not returns the name of the unit given in the editor, it rather returns: "The name given to a unit using the setIdentity instruction or selected randomly by the game engine if setIdentity has not been used on the unit. Check here for details. At the end of the page you'll see a comment by Kronzky about how to get the name you want, but it's unclear to me how to extrapolate that to make it work inside a script. ---------- Post added at 08:13 PM ---------- Previous post was at 08:00 PM ---------- _pos = position player; player = _this select 0; switch (player) do { case p7://player variable name p7 { _trgobj2 = createTrigger ["EmptyDetector",_pos]; _trgobj2 triggerAttachVehicle [player]; _trgobj2 setTriggerActivation ["Vehicle", "PRESENT", true]; _trgobj2 setTriggerArea [30, 30, 0, true]; _trgobj2 setTriggerStatements ["this", "evh_1 = [p7] execVM 'scripts\killed.sqf'",""]; sleep 0.5; _trgobj3 = createTrigger ["EmptyDetector",_pos]; _trgobj3 setTriggerActivation ["NONE", "PRESENT", true]; _trgobj3 setTriggerArea [30, 30, 0, true]; _trgobj3 setTriggerStatements ["(!alive p7)", "p7 removealleventhandlers 'killed'",""]; }; case p8://player variable name p8 { _trgobj2 = createTrigger ["EmptyDetector",_pos]; _trgobj2 triggerAttachVehicle [player]; _trgobj2 setTriggerActivation ["Vehicle", "PRESENT", true]; _trgobj2 setTriggerArea [30, 30, 0, true]; _trgobj2 setTriggerStatements ["this", "evh_1 = [p8] execVM 'scripts\killed.sqf'",""]; sleep 0.5; _trgobj3 = createTrigger ["EmptyDetector",_pos]; _trgobj3 setTriggerActivation ["NONE", "PRESENT", true]; _trgobj3 setTriggerArea [30, 30, 0, true]; _trgobj3 setTriggerStatements ["(!alive p8)", "p8 removealleventhandlers 'killed'",""]; }; }; This worked on the dedicated server. However this way means scripting 2 triggers per player to get it to work for clients. that was not what I was trying for.:( I was hoping to get 2 triggers to do all this. I'm not sure you haven't succeeded already :rolleyes:. As far as I can see, that code will run on the client only ('cos player is local to every client) and since createTrigger local effect, you'll end up with only 2 triggers from the clients point of view, i.e. every client machine will see only 2 triggers. In that case it will be no load for the server. I don't think it can get better than that. Share this post Link to post Share on other sites