Jump to content

soldierXXXX

Member
  • Content Count

    101
  • Joined

  • Last visited

  • Medals

Community Reputation

108 Excellent

1 Follower

About soldierXXXX

  • Rank
    Sergeant

Profile Information

  • Gender
    Male
  • Location
    Czech Republic

Recent Profile Visitors

1114 profile views
  1. Hi, if I understand correctly, you only need to check when all artillery units ceased to fire, right ?. You can do it by checking unitReady. Obviously, this should be put after artillery started firing. _artilleries = [arty1,arty2,arty3]; { _x doArtilleryFire [[3000, 120, 1000], "8Rnd_82mm_Mo_shells", 3]; } forEach _artilleries; waitUntil {sleep 3;(_artilleries findIf {!unitReady _x}) == -1}; hint "artilleries ceased to fire"; With eventhandlers...that's not how they work. They cannot be used as replacement for conditionals. Events are fired when specific engine coded script is done. It happens in the background even without you knowing it. Event is called when unit changes animation (animDone), gets hurt (HandleDamage, Hit, Hitpart), reloads weapon (Reloaded) and so on . So to have something practical to explain on, when unit dies, it calls killed event. Then the game checks if any code is added to unit via addEventhandler with "Killed" type and runs all assigned codes. If you add eventhandler it stores the code in some query, or array and when event happens, game runs every code stored in that query. Code is running in unscheduled environment (cannot be paused with sleep/waitUntil). More importantly it's completely new scope, the code is separated and cannot see code above or bellow. Code you wrote will always return false, because it's in the scope that is not direct parent of eventhander scope that means _isShooting in function is not the same variable as _isShooting in event code even when they have the same name. Take a look at this. If you need deeper understanding of that, you can experiment and simulate similar behavior in some of your own function with BIS_fnc_callScriptedEventHandler which will behave like engine scripted code and somewhere else BIS_fnc_addScriptedEventHandler which then simulates addEventHandler behavior. So my quick fun to make idea is try make door opening script and add functionality to be able to call external code with scripted event whenever doors open/closes. I'll understand if it's too complicated. It takes time to fully get what eventhandlers do. Also I made function that checks if some bullet is still flying. Returns TRUE if any bullet is still in air, FALSE if no bullet is flying. Might be useful for someone.
  2. Oh, right. MapAnimAdd only works during mission, my bad ๐Ÿ˜„. Here is fixed code. player createDiaryRecord ["Diary", ["The Hub"," For the duration of your stay you will based here at <execute expression='player selectDiarySubject ""Map"";if ((findDisplay 37) isNotEqualTo displayNull) then { private _ctrlMap = ((findDisplay 37) displayCtrl 51); _ctrlMap ctrlMapAnimAdd [1, 0.1, getMarkerPos ""theHub""];ctrlMapAnimCommit _ctrlMap;} else {mapAnimAdd [1, 0.1, markerPos ""theHub""];mapAnimCommit;}'>The Hub</execute>,a Joint Operations Centre (JOC) in Mexico.<br/>"+ "<img image='images\theHubsml.jpg' width='329' height='185' title='The Hub' /><br/>"+ "<br/> The..."]];
  3. Hi, it's doable, if you don't mind loosing the blue lines pointing to the marker. You just have to script map animation youself. For that you should use execute tag, which is part of the diary system. player createDiaryRecord ["Diary", ["The Hub"," For the duration of your stay you will based here at <execute expression='player selectDiarySubject ""Map"";mapAnimAdd [1, 0.1, markerPos ""theHub""];mapAnimCommit;'>The Hub</execute>,a Joint Operations Centre (JOC) in Mexico.<br/>"+ "<img image='images\theHubsml.jpg' width='329' height='185' title='The Hub' /><br/>"+ "<br/> The..."]];
  4. soldierXXXX

    What am i doing wrong?

    Hi, and welcome to the forum. So there is a lot of things wrong with this code. Let's get through the code. 1)you're passing only _searchlightman variable to new scope (when you use spawn it creates new scope and all variables needs to be passed or redeclared) 2)_searchlights therefore aren't defined 3)while {alive _searchlightman && alive _searchlights} you're passing whole array of lights there, that should be only one object 4)If you'll use && code will never be run, because while condition exits when condition returns false, you need to change that for || 5)if (!alive _searchlightman || !alive _searchlights) again you're passing whole array of lights there 6)There is no good reason to check the code if searchlight is dead, so you can simplify it to only check searchlight status in a while loop and searchlightman status in if condition 7)_forEachIndex is not defined here, it only exists in forEach loop 8)there is no sleep at the end of the loop which can cause whole game to freeze. While loop is iterated multiple times per frame if there is no sleep inside. Here is good explanation. If I'd followed same logic you wrote it, fixed code should look like this. However I don't really recomment this. If you'll create too many searchlightman units, you might see it on game performance because scheduler will be cluttered with these codes. I suggest to use killed eventhandler for this. It's much easier to use for this situation and also code is called only when searchlightman dies. That means you can have as many units as you want and scheduler is not cluttered. This code should be run only on the server in case it's for multiplayer mission. Either put the code below in initServer.sqf or add condition if(isServer) then {//paste the code here};
  5. soldierXXXX

    points for healing in MP

    For peace of mind, I want to share the code I put together for anyone that might come across this thread in the future. This is actually my first time messing with eventhandlers in the multiplayer script, so I spend about three days observing, adjusting and learning how events behave in multiplayer environment. I really wanted to make the event work since it was the original idea of this thread, and I believe, I managed to make it functional. This event is a bit complicated as it has to run on each client and be updated after unit respawns. Learned quite a lot I have to say as previously I only read about multiplayer scripting in theory. Still it's not my cup of tea, so if someone experienced points out something I forgot about, I'll gladly hear it. Otherwise I consider this thread resolved ๐Ÿ™‚. I tested it with instant respawn, so I hope it works on other types as well. I had one client as player hosted server and other as joined client. Tried both clients in lobby ready to play as well as JIP, and it worked in my tests. Code with debug and description: Cleaner code no debug, no description:
  6. soldierXXXX

    points for healing in MP

    Glad to hear that you got your system working ๐Ÿ™‚
  7. soldierXXXX

    points for healing in MP

    Well, since remoteExec has JIP parameter filled, when player disconnects, his unit is destroyed and becomes objNull unit dies, but JIP command persists and when new player connects he receives basically objNull deadUnit addEventhandler... not sure if that would trow error or not doesn't trow error, but it's not needed anymore, so I think it will be better to remove that request when player disconnects. That would also need some array of JIP IDs managed by the server. I believe, it's connected to the unit, so when unit dies, eventhandler is bound to that dead unit. After testing respawning seems to work even with respawned unit. So it seems to be persistent...huh...so, if I get it right,if addEventHandler is called with object player, eventhandlers are transfered to player every time from dead unit to new unit when he respawns ? I would need someone to explain it to me how it actually works. Hmmm, strange. I would need more informations. When it didn't work, did the first hint show up, how did you healed other player, was the unit same as you connected or new unit (respawned) and so on. Video might help. tested with respawn instant, so it might also work differently with other respawn types. update2: After further testing, it seems that events added on client PC is persistent only for him after respawning (that's why code above still triggers on self heal but nothing else), and for the other clients it's tied to previous unit as events cease to work on new unit. That might be fixed by removing previous event and reexecuting it when new unit spawns. That's why I don't do multiplayer scripting ๐Ÿ˜„.
  8. soldierXXXX

    points for healing in MP

    Right, so I tried the code with local hosted MP from Eden, I've put your code into initPlayerLocal.sqf and had two playable characters, one medic (client 1) and other normal soldier (client 2). I noticed that it indeed didn't show the hints, except when injured player healed himself. That is because how the event is designed. It only triggers on PC where healer is local. But in that case initPlayerLocal only added event on connected PC, that caused only self heal to be registered because addEventHandler has local effect-no other client knows that you should be registered for healing. So when I remoteExecuted addEventHandlers with JIP parameter as TRUE, It started to trigger when I used healing on the second client. That is, because client 1 at the moment client 2 connected received information to register HandleHeal event on client 2 selected character (unit), and client 2 also received information to register client1 unit event. That meant both PC had now registered HandleHeal to each other and might start to run the code properly. Eh...I'm not good at explaining this ๐Ÿ˜„ Here is the code I tried: //initPlayerLocal.sqf [player,["HandleHeal", { _this spawn { params ["_injured", "_healer", "_isMedic", "_atVehicle", "_action"]; [str _this] remoteExec ["hint"]; private _damage = damage _injured; if (_injured isNotEqualTo _healer) then { waitUntil { (damage _injured isEqualTo 0) or (damage _injured isEqualTo 1) }; if (damage _injured isEqualTo 0) then {// give healer points [_healer,1] remoteExec ["addScore",2]; [("giving points to: " + str _healer)] remoteExec ["hint"]; }; }; }; }]] remoteExec ["addEventHandler",0,TRUE]; Also this behaviour might be related to this specific event handler that needs to be registered on all clients (and possibly all the other units if player should get points for healing AIs) that should be able to heal each other. Probably because the local healer condition. Most important information is that healer runs the code on his PC and needs to know the object that he is healing has HandleHeal event registered otherwise script won't trigger. Also, this code has potential to get stucked in program flow on the healer's PC in case that he is not a medic and won't heal injured unit fully. It will wait in scheduler before some other medic heals the injured unit fully or unit dies and only after that it releases. Possibly revarding both healers (intended ?). Problem might be if client heals many units just partially, that will create many waiting scripts on that client PC that might potentially decrease performance of the mission for him. Might be better to have it handled by server as separate function. I also believe that you have to re-register the same event every time a player dies. Transfering the event to new unit. Possibly also remove event from previous unit. Removing should also be done if player disconnects and AI switches in the role. Those are some things to be considered. I'm definitely not sure how your mission is set up, so I just tried what I thought would be best. There are certainly people more experienced with multiplayer scripting than I am ๐Ÿ˜„. Still, I'm gonna hope that I helped you at least a little bit ๐Ÿ™‚. And sorry if this explanation is a bit messy ๐Ÿ˜„.
  9. soldierXXXX

    points for healing in MP

    Hi, just a quick notice, you're using [] spawn {}, but that doesn't have any params itself. Try use _this spawn {} instead. That should pass event parameters and code should run. If not, there might be locality problem. Depends how you execute the script.
  10. Hi, welcome to the forum. When you create object with createVehicle, you can see that it returns object. That means we can save the returned value into variable and we will have reference to that object. For this example I'm gonna use global variable and will refer to it as "wall". when you want to set direction to object, you can use setDir command. so full script then looks like this wall = "Land_W_sharpRock_wallH" createVehicle getMarkerPos "marker0"; wall setDir 45; Assigning variables are basic thing to do in every scripting language. You will use it a lot. You can read this article to better understand how scripting works in general.
  11. soldierXXXX

    help re nearestObjects

    Yep, probably would be better to put it between round brackets I tested it with this, {[_x, 2500] spawn {params ["_unit","_number"];systemChat str ("Unit:" + str _unit + " Number: " + str _number)}} forEach (player nearEntities [["O_Soldier_base_F"],51]); So your code should look like this {[_x, 2500] execVM "fn_taskRush.sqf"} forEach (cap0_1 nearEntities [["O_Soldier_base_F"],51]); Also I noticed that you had there empty characters, which also causing errors. If you're satisfied with @JCataclisma's code (which works), there's no actual need to change that. We're talking about milliseconds here, so regular users won't notice the difference anyway ๐Ÿ™‚.
  12. soldierXXXX

    help re nearestObjects

    Yep, you got this wrong. You can't combine nearestObjects with nearEntities. It's either one or the other. So like this: {[_x, 2500] execVM "fn_taskRush.sqf"} forEach cap0_1 nearEntities [["O_Soldier_base_F"],51]; You can of course change O_Soldier_base_F for SoldierEB,SoldierWB or SoldierGB. O_Soldier_base_F is child of SoldierEB.
  13. soldierXXXX

    help re nearestObjects

    Hi, if you need to return opfor units + opfor vehicles you can filter them with select command nearestObjects [cap0_1,["O_Soldier_base_F","LandVehicle"],51] select {side _x == EAST}; But if you need only on foot units it might be better use nearEntities which is much faster cap0_1 nearEntities [["O_Soldier_base_F"],51];
  14. Hi, as far as I know this change shouldn't affect any script in particular. While scripters use random x with combination floor, round or ceil then the number always returns integer value. In case the script uses pure random, then the autor probably didn't really needed that specific x value to be included. So that means, if you're using ceil for instance with number 5, it might generate any number between 0 and <5 so like 4.73 can be generated and ceil automatically makes it 5. If you seriously need that value to be included you can probably use linearConversion command with clip value true. something like _wantedNum = 5; _randomIncluded = linearConversion [-0.01,_wantedNum,(random (_wantedNum + 1))-0.01,0,_wantedNum,TRUE]; //should theoretically return numbers between 0 and 5 not tested IMO this change might actually help, because when I used for loop with combination of array select _i in older scripts, I always had to account for that particular case that it didn't choose that last number where no value was defined so I had to do like for "_i" from 0 to (floor (random (count _array -0.1))) do {...(Today I'm usually using forEach loop instead) And since 2.18 it could be same thing without -0.1. It's not really good example to show it on but now it will work like in other programming languages. I think that's why they changed it.
  15. Hi, Bendy, handling such system through UIEH would be really hard. Fortunately we have also user eventhandlers that can do all sorts of things. I prepared a quick example code that should be able to do what you need. But multiplayer scripting is not my cup of tea if you understand. Maybe you would also need to add functionality that would handle respawning, adding units to your group and so on. I hope that this code could help you at least a little bit. ๐Ÿ™‚
ร—