Cockheaven 21 Posted June 7, 2019 Hi guys, I have sort of a mishmash of code here I'm trying to work my way through. I'm sure there are some better ways to do the things I'm trying to do like using foreach as well as passing parameters to other scripts but unfortunately, I'm not quite grasping both of those concepts. What I need to do is either by addiction or at the start of the game choose a random player create a task for all players that show approximately that chosen player's position to kill said player uppon killing said player choose a new player, actually, choose the player that killed the target player and continue looping until everyone is fed up with the game mode I've had a few iterations of my code and here's where I am at right now if (isNil "_killer") then // Nobody got got? { if (isServer) then { _units = []; { if (isPlayer _x) then { _units pushBack _x; } } foreach playableUnits; _Rabbit = _units call BIS_fnc_selectRandom; // initial target choice }; } else { _Rabbit = _killer // since killer exists make killer the target }; _Rabbit addMPEventHandler ["MPkilled", { params ["_unit", "_killer", "_instigator", "_useEffects"]; }]; // record who does what to Rabbit while {alive _Rabbit} do { sleep 15; // loop interval hint format ["Kill %1",_Rabbit]; if ( "t1" call BIS_fnc_taskExists ) then { "t1" call BIS_fnc_deleteTask }; // delete any existing t1 if ( "t2" call BIS_fnc_taskExists ) then { "t2" call BIS_fnc_deleteTask }; // delete any existing t2 if ( "t3" call BIS_fnc_taskExists ) then { "t3" call BIS_fnc_deleteTask }; // delete any existing t3 if ( "t4" call BIS_fnc_taskExists ) then { "t4" call BIS_fnc_deleteTask }; // delete any existing t4 _Rabbitmarker = createmarker ["Rabbitloc", position _Rabbit]; [west,["t1"],["Kill the Rabbit","Kill the Rabbit","Rabbitloc"],getmarkerpos "Rabbitloc",1,3,true] call BIS_fnc_taskCreate; // create task for blue [east,["t2"],["Kill the Rabbit","Kill the Rabbit","Rabbitloc"],getmarkerpos "Rabbitloc",1,3,true] call BIS_fnc_taskCreate; // create task for red [independent,["t3"],["Kill the Rabbit","Kill the Rabbit","Rabbitloc"],getmarkerpos "Rabbitloc",1,3,true] call BIS_fnc_taskCreate; // create task for green [civilian,["t4"],["Kill the Rabbit","Kill the Rabbit","Rabbitloc"],getmarkerpos "Rabbitloc",1,3,true] call BIS_fnc_taskCreate; // create task for purple }; // while rabbit is alive tell people to kill them and mark their position if !(alive _Rabbit) then { _Rabbit = _killer; execVM "Rabbit.sqf"; } else { }; // If rabbit is killed make their killer the new rabbit and rerun the script Thanks for all the help, I'm slowly becoming more capable of making my own crappy scripts. 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 7, 2019 6 hours ago, Cockheaven said: I have sort of a mishmash of code here I'm trying to work my way through. Hello there Cockheaven ! Below i will add a quick approach of what you might want to succeed if i understand correctly : in the init : []execvm "script.sqf"; "script.sqf" waituntil{time>2}; systemchat "start"; // _allPlayers = allUnits select {!isPlayer _x && alive _x && _x iskindof "man" && !(_x isKindOf "HeadlessClient_F")}; // to test with ai _allPlayers = allUnits select {isPlayer _x && {alive _x} && {!(_x isKindOf "HeadlessClient_F")}}; if(count _allPlayers isEqualTo 1)exitwith{ systemchat "end"; call BIS_fnc_endMissionServer; }; _Player = selectrandom _allPlayers; systemchat format ["%1",_Player]; diag_log format ["%1",_Player]; _Players = allUnits select {isPlayer _x && {alive _x} && {!(_x isKindOf "HeadlessClient_F")}}; [_Players,["task_1","Mission_1"],["Description : ...","Find and Kill",""], getpos _Player,true,1,true,"kill",true] call BIS_fnc_taskCreate; ["task_1","ASSIGNED",true] spawn BIS_fnc_taskSetState; GF_Player = _Player; [] spawn { GF_marker = format["GF_marker_%1",GF_Player]; createMarker [GF_marker, getPos vehicle GF_Player]; GF_marker setMarkerShape "ICON"; _side = side group GF_Player; _sideColor = [_side, true] call BIS_fnc_sideColor; while {alive GF_Player}do{ GF_marker setMarkerColor _sideColor; GF_marker setMarkerType "loc_ViewTower"; GF_marker setMarkerSize [2,2]; GF_marker setMarkerPos getpos GF_Player; GF_marker setMarkerDir getDir GF_Player; uisleep 0.1; }; }; waitUntil {uisleep 1;!alive _Player}; systemchat "end"; ["task_1", "SUCCEEDED",true] spawn BIS_fnc_taskSetState; deleteMarker GF_marker; Uisleep 3; ["task_1"] call BIS_fnc_deleteTask; []execvm "script.sqf"; 3 1 Share this post Link to post Share on other sites
ZaellixA 383 Posted June 7, 2019 Well, I believe George gave you a great head start. Just want to make a couple of comments on though. 1) Most probably you would like to exclude the "rabbit" from the players that get the "Kill" task. So instead of 7 minutes ago, GEORGE FLOROS GR said: [_allPlayers,["task_1","Mission_1"],["Description : ...","Find and Kill",""], getpos _Player,true,1,true,"kill",true] call BIS_fnc_taskCreate; you could do something like _hunters = allUnits select {isPlayer _x && {alive _x} && {!(_x isKindOf "HeadlessClient_F")}}; // Changed the _allPlayers to _hunters. _rabbit = _selectRandom _hunters; // Find a random rabbit -> Changed _Player to _rabbit _hunters deleteAt[findIf[_x isEqualTo _rabbit]]; // Remove the rabbit from the hunters array [_hunters,["task_1","Mission_1"],["Description : ...","Find and Kill",""], getpos _rabbit,true,1,true,"kill",true] call BIS_fnc_taskCreate; // Just changed _allPlayers to _hunters and _Player to _rabbit 2) Most probably the killed players will respawn, so the 24 minutes ago, GEORGE FLOROS GR said: if(count _allPlayers isEqualTo 1) exitwith { systemchat "end"; call BIS_fnc_endMissionServer; }; part is not needed. Unless you want to check if you are the only one playing (it is a quite valid check if you ask me). 3) Additionally, I believe you want the killer to become the rabbit after the "execution". In my opinion the best way to achieve that is by using an eventHandler. This would require you to change your script and the way you use it, so that you will run the script once at the beginning (very similar to the version George sent you) and then handle the rest through an eventHandler which you will "pass" from the killed rabbit to its killer (the new rabbit). I am not able to provide an example at the moment (apologies for that), but I will do so as soon as possible. Of course this is not the only way to achieve the desired result. 2 1 Share this post Link to post Share on other sites
Cockheaven 21 Posted June 8, 2019 What George gave me works and is plug and play, however, the task needs to update the target players position continuously, I'd like it to have a delay around 20 seconds. the task doesn't seem to update the player's position continuously although I'm assuming the following code is supposed to perform that function while {alive GF_Player}do{ GF_marker setMarkerColor _sideColor; GF_marker setMarkerType "loc_ViewTower"; GF_marker setMarkerSize [2,2]; GF_marker setMarkerPos getpos GF_Player; GF_marker setMarkerDir getDir GF_Player; uisleep 0.1; }; @ZaellixA Yes I want the killer of the target player to become the next target 1 Share this post Link to post Share on other sites
ZaellixA 383 Posted June 8, 2019 Hhhmmm..., yes this was supposed to work (referring to the above code snippet). Unfortunately I won't be able to perform any check for the next 10 days (only Mac available 'till then), so I cannot help with this test. Now, regarding the example I told you about. Here you are :) // showRabbit.sqf script _newRabbit = _this select 0; // You will pass the newRabbit to the script as an argument // Delete the previously created Rabbit marker _marker = allMapMakrers findIf { _x isEqualTo "Rabbit"; // Instead of "Rabbit" use the name of the marker you want }; if(!(_marker isEqualTo -1)) { deleteMarker (allMapMarkers select _marker); // Delete the marker }; // Create and maintain the new rabbit marker // This part is copy-pasted from George Floros' code snippet with some minor changes _marker = "Rabbit"; // Set the name of the marker -> IMPORTANT: This must match the name that you search for inside the findIf above createMarker [_marker, getPos vehicle _newRabbit]; // Create the marker _marker setMarkerShape "ICON"; // Set the shape of the marker _side = side group _newRabbit; // Get the side of the new rabbit _sideColor = [_side, true] call BIS_fnc_sideColor; // Get the color of the side -> This and the above statements are optional in case you want to have the marker's color match the players side color // Maintain and update the marker while {alive _newRabbit} do { _marker setMarkerColor _sideColor; // Set the color of the marker -> As mentioned above this is optional _marker setMarkerType "loc_ViewTower"; // Set the marker type _marker setMarkerSize [2,2]; // Set size of the marker _marker setMarkerPos getpos _newRabbit; // Set the position of the marker to match the position of the rabbit // Optional alternative: Use random to randomize the location emulating a possible GPS error // _markerPosition = getPos _newRabbit; // Get the position of the rabbit // _markerPosition set[0, (_markerPos select 0) + random 5]; // Add a random constant to the x-coordinate of the marker // _markerPosition set[1, (_markerPos select 1) + random 5]; // Add a random constant to the y-coordinate of the marker // _marker setMarkerPos _markerPosition _marker setMarkerDir getDir _newRabbit; // The same kind of randomization as above can be done for the direction uisleep 5; // Sleep for 5 seconds between "iterations" }; Now, you have to add an eventHandler to the rabbit. This should look like // addTheRabbitHandler.sqf script _rabbit = _this select 0; // You will pass the rabbit to the script // Add the eventHandler to the rabbit _rabbit addEventHandler["Killed", { _theRabbit = _this select 0; // The rabbit that died _killer = _this select 1; // The person who killed the rabbit _theRabbit removeEventHandler _thisEventHandler; // Remove the current eventHandler from the rabbit [_killer] spawn "addTheRabbitHandler.sqf"; // Run this script to add a similar eventHandler to the killer who in turn will be the new rabbit }]; [_killer] spawn "showRabbit.sqf"; // Run the script to show and maintain the marker for the killer (who is now the new rabbit) Finally, you will somehow need to initiate the whole process. You will have to somehow, somewhere execute the addTheRabbitHandler.sqf. You could do that in the init.sqf like // init.sqf waitUntil{time > 10}; // Wait a bit to make sure everything is running // Find all alive players _allPlayers = allUnits select {isPlayer _x && {alive _x} && {!(_x isKindOf "HeadlessClient_F")}}; // Taken from George Floros' code _firstRabbit = selectRandom _allPlayers; // Randomly select a rabbit // Execute the script to initiate the whole process [_firstRabbit] spawn "addTheRabbitHandler.sqf"; // Run the script to add the handler and start the whole thing Phew..., well it seems it is a bit more complicated than what I initially had in my mind. If you find this too complicated to follow feel free to skip it entirely. Even if you do not feel like testing it, it could be beneficial (to all of us) to go through it and see if you have any questions about it, or if you can find any errors (there most probably exist at least one 😆). Whatever the case, please keep in mind that this is UNTESTED, so if you intend to even go through it, please test it simultaneously to make sure everything works as intended. This of course is most unlikely since the first time the bugs and errors are more than the correct commands in my code snippets 🤣 . 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 8, 2019 16 hours ago, Cockheaven said: What George gave me works and is plug and play, however, the task needs to update the target players position continuously, I'd like it to have a delay around 20 seconds. the task doesn't seem to update the player's position continuously although I'm assuming the following code is supposed to perform that function If i remember there is a way for the sign ( marker) of the mission to follow the target , but i couldn't find how yesterday , so if anyone already knows , it would be very good to share the information. This is why i added the extra marker in the code. You can also use this and just add the 20 sec wait (in uisleep). There is always space for improvement , so it's good to experiment and add your final code , when it's done ! and by the way ZaellixA gave very good pointers ! 2 Share this post Link to post Share on other sites
Cockheaven 21 Posted June 8, 2019 @GEORGE FLOROS GR here's what I changed regarding task tracking. while {alive GF_player} do { sleep 20; [] spawn { GF_marker = format["GF_marker_%1",GF_player]; createMarker [GF_marker, getPos vehicle GF_player]; GF_marker setMarkerShape "ICON"; _side = side group GF_player; _sideColor = [_side, true] call BIS_fnc_sideColor; ["t1", getMarkerPos "GF_marker"] call BIS_fnc_taskSetDestination; }; }; not kicking any errors uploading into dedicated now for testing. thinking I've got some unnecessary stuff in there can deal with later. 2 Share this post Link to post Share on other sites
ZaellixA 383 Posted June 8, 2019 Well, I haven't used BIS_fnc_taskSetDestination before but in its BIKI says that you could instead of what you have, do ["t1", [GF_Player, true]] call BIS_fnc_taskSetDestination This will put the marker on top of the "GF_Player". You could also omit "true" but this may not show the marker to players that do not know about GF_Player's whereabouts. EDIT: Also, I am not sure what the difference is between BIS_fnc_taskSetDestination and setMarkerPosition. 1 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 8, 2019 You need "spawn" before "while" as the code above in order to run any code after the loop ( while ) , otherwise it will continue the loop and any code below , will not continue , until the loop will stop. also you have the create marker in the loop , so it will continue creating markers. This is why i have used a global variable "GF_player" instead of a local ( "_player") , because of the spawn. so probably you need only this to loop : call BIS_fnc_taskSetDestination; 2 Share this post Link to post Share on other sites
Cockheaven 21 Posted June 8, 2019 (edited) 21 minutes ago, ZaellixA said: Well, I haven't used BIS_fnc_taskSetDestination before but in its BIKI says that you could instead of what you have, do ["t1", [GF_Player, true]] call BIS_fnc_taskSetDestination This will put the marker on top of the "GF_Player". You could also omit "true" but this may not show the marker to players that do not know about GF_Player's whereabouts. EDIT: Also, I am not sure what the difference is between BIS_fnc_taskSetDestination and setMarkerPosition. Using that works, but there isn't a delay, I would like a small delay in between tracking updates. Current code GF_player = _Player; [] spawn { GF_marker = format["GF_marker_%1",GF_player]; createMarker [GF_marker, getPos vehicle GF_player]; GF_marker setMarkerShape "ICON"; _side = side group GF_player; _sideColor = [_side, true] call BIS_fnc_sideColor; while {alive GF_player}do{ sleep 20; GF_marker setMarkerColor _sideColor; GF_marker setMarkerType "loc_ViewTower"; GF_marker setMarkerSize [2,2]; GF_marker setMarkerPos getpos GF_player; GF_marker setMarkerDir getDir GF_player; ["t1", [GF_Player, true]] call BIS_fnc_taskSetDestination; }; }; Edited June 8, 2019 by Cockheaven added current code 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 8, 2019 16 minutes ago, Cockheaven said: Using that works, but there isn't a delay, I would like a small delay in between tracking updates. as i just test this it's working as you want this way : (based on the script above "task_1") [] spawn { while {alive GF_Player}do{ ["task_1",getpos GF_Player] call BIS_fnc_taskSetDestination; uisleep 20; }; }; also working like : ["task_1",GF_Player] call BIS_fnc_taskSetDestination; 1 Share this post Link to post Share on other sites
Cockheaven 21 Posted June 8, 2019 29 minutes ago, GEORGE FLOROS GR said: as i just test this it's working as you want this way : (based on the script above "task_1") [] spawn { while {alive GF_Player}do{ ["task_1",getpos GF_Player] call BIS_fnc_taskSetDestination; uisleep 20; }; }; also working like : ["task_1",GF_Player] call BIS_fnc_taskSetDestination; Okay @GEORGE FLOROS GR , it wasn't working when I hosted locally in MP. If it works on the dedicated great, if not I'm pretty darn happy with the state of the mission. Thank you and @ZaellixA for your help! 2 Share this post Link to post Share on other sites
ZaellixA 383 Posted June 8, 2019 Hhhhmmm, not sure why... Please correct me if I am wrong but markers should work for all players (global effect) 🌐. As I said, unfortunately I cannot help with testing. I will ask a friend to test for me if he can. This will happen tomorrow though (it's quite late now here). I'll come back to you if I have any news... 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 8, 2019 23 minutes ago, Cockheaven said: it wasn't working when I hosted locally in MP. Share also below all your code and how you execute this. 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 9, 2019 - because i just checked this in my code and it's working as intended ( also in MP ). Share this post Link to post Share on other sites
Cockheaven 21 Posted June 9, 2019 Hi guys I'm going to post for you what I have thus far and the results of the playtest last night. I have a mission that contains empty markers (marker_#) on the map aswell as respawn_side markers for all 4 sides, 4 players per side total of 16 players. That is the extent of the Eden assets below in spoilers is the code being executed. init.sqf Spoiler []execvm "Rabbit.sqf"; enableSaving [ false, false ]; if (isServer) then { _clearBodies = [] spawn { while {true} do { { deleteVehicle _x; sleep 0.01; } forEach allDeadMen; sleep 10; }; }; onPlayerkilled.sqf Spoiler vehicle player setdamage [1,false]; //BLOW YOUR SHIT UP IF ITS NOT ALREADY {deleteVehicle _x} forEach crew (vehicle player);// + [vehicle player]; DELETE YOUR CREW (COMMENTED OUT VEHICLE ITSELF) onPlayerRespawn.sqf Spoiler if (hasInterface) then { //DONT EXECUTE ON !HUMANS // _markers = allMapMarkers select {toUpper _x find "marker" >= 0}; _spawn_pos = ["marker_0","marker_1","marker_2","marker_3","marker_4","marker_5","marker_6","marker_7","marker_8","marker_9","marker_10","marker_11","marker_12","marker_13","marker_14","marker_15","marker_16","marker_17","marker_18","marker_19","marker_20","marker_21","marker_22","marker_23","marker_24","marker_25","marker_26","marker_27","marker_28","marker_29","marker_30","marker_31","marker_32","marker_33","marker_34","marker_35",'marker_36',"marker_37","marker_38","marker_39","marker_40","marker_41","marker_42","marker_43","marker_44","marker_45","marker_46","marker_47","marker_48","marker_49","marker_50","marker_51","marker_52","marker_53","marker_54","marker_55","marker_56","marker_57","marker_58","marker_59","marker_60"] call BIS_fnc_selectRandom; //SELECT A RANDOM MARKER waitUntil {!isnull player}; //WAIT UNTIL YOUR DEAD LOL player setPos (getMarkerPos _spawn_pos); //TELEPORT !DEAD YOU TO A WHOLE NEW WORLD }; _helmet = selectrandom ["CFP_SOARCREW_BLUE","CFP_SOARCREW_STACHE","CFP_SOARCREW_RED","CFP_SOARCREW_SKULL"]; //SELECT A RANDOM COOL DUDE HELMET player addHeadgear _helmet; //PUT ON YOUR COOL DUDE HELMET player addbackpack "B_Kitbag_cbr"; player addItemToBackpack "Toolkit"; player addItem "ACE_EarPlugs"; //PUT ON YOUR EARPLUGS player allowDamage false; //GIVE YOU GODMODE _veh = createVehicle ["CFP_B_UGARMY_T90_01", [getPosATL player select 0, getPosATL player select 1, (getPosATL player select 2) + 9], [], 0, "NONE"]; //SPAWN YOUR CHARIOT _veh setVariable ["ACE_isRepairVehicle", true]; _chute0 = "B_parachute_02_F" createVehicle [0,0,0]; _chute0 attachTo [_veh, [0, 0, 0]]; _veh allowDamage false; //GIVE YOUR CHARIOT GOD MODE _veh setDir 160; //WHO CARES createVehicleCrew _veh; //GIVE YOU A CREW _veh disableTIEquipment true; //NO THERMALS FOR YOU!!! _veh deleteVehicleCrew gunner _veh; //DELETE YOUR GUNNER _vehcrew = crew _veh; //GET YOUR CREW _vehcrew join (group player); //YOUR CREW JOINS YOU { _x disableAI "AUTOTARGET"; //AI DONT SHOOT MANS } foreach units group player; player moveInGunner _veh; //YOU GET INTO GUNNER SEAT _veh removeMagazinesTurret ["CUP_5Rnd_AT11_M",[0]]; //REMOVE THE OPTION TO USE THIS MAGAZINE _veh setAmmo ["CUP_5Rnd_AT11_M", 0]; //REMOVE THE ACTUAL AMMO FROM THE VEHICLE sleep 10; //WAIT 10 SECONDS? _veh allowDamage true; //REMOVE GODMODE FROM YOUR CHARIOT player allowDamage true; //REMOVE GODMODE FROM YOU deleteVehicle _chute0; Rabbit.sqf Spoiler waituntil{time>30}; systemchat "start"; // _allPlayers = allUnits select {!isPlayer _x && alive _x && _x iskindof "man" && !(_x isKindOf "HeadlessClient_F")}; // to test with ai _allPlayers = allUnits select {isPlayer _x && {alive _x} && {!(_x isKindOf "HeadlessClient_F")}}; /*if(count _allPlayers isEqualTo 1)exitwith{ systemchat "end"; call BIS_fnc_endMissionServer; };*/ _Player = selectrandom _allPlayers; systemchat format ["%1",_Player]; diag_log format ["%1",_Player]; vehicle _Player disableTIEquipment false; //THERMALS FOR RABBIT! _Players = allUnits select {isPlayer _x && {alive _x} && {!(_x isKindOf "HeadlessClient_F")}}; [_Players,["t1","Mission_1"],["Kill the Rabbit","Kill the Rabbit",""], getpos _Player,true,1,true,"kill",true] call BIS_fnc_taskCreate; ["t1","ASSIGNED",true] spawn BIS_fnc_taskSetState; GF_player = _Player; [] spawn { GF_marker = format["GF_marker_%1",GF_player]; createMarker [GF_marker, getPos vehicle GF_player]; GF_marker setMarkerShape "ICON"; _side = side group GF_player; _sideColor = [_side, true] call BIS_fnc_sideColor; while {alive GF_player}do{ GF_marker setMarkerColor _sideColor; GF_marker setMarkerType "loc_ViewTower"; GF_marker setMarkerSize [2,2]; GF_marker setMarkerPos getpos GF_player; GF_marker setMarkerDir getDir GF_player; ["t1", [GF_Player, true]] call BIS_fnc_taskSetDestination; Uisleep 20; }; }; waitUntil {sleep 1;!alive _Player}; systemchat "end"; ["t1", "SUCCEEDED",true] spawn BIS_fnc_taskSetState; deleteMarker GF_marker; Uisleep 15; ["t1"] call BIS_fnc_deleteTask; []execvm "Rabbit.sqf"; Although it was kind of broken, players had fun. Problems with the code include 1. Multiple "rabbits" being chosen continuously (without killing a rabbit two or more players could be the rabbit). 2. Task marker jumping between players, marking players whether or not they are the "rabbit". Again Thanks a lot for your guy's help, stupid projects like this are really helping me understand more complex aspects of mission making. 3 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 9, 2019 2 hours ago, Cockheaven said: Again Thanks a lot for your guy's help, Ok so first , it would be good to check this : https://community.bistudio.com/wiki/Initialization_Order Then , You can create an initPlayerlocal.sqf and add this code inside , or else in your onPlayerRespawn.sqf and get rid of the loop: Spoiler while {true} do { { deleteVehicle _x; sleep 0.01; } forEach allDeadMen; sleep 10; }; player addEventHandler ["Respawn",{ params ["_unit", "_corpse"]; _pos = getPosASL _corpse; _nearestObjects = nearestObjects [_pos,["WeaponHolder","groundWeaponHolder","WeaponHolderSimulated"],2]; { deleteVehicle _x; }forEach _nearestObjects; deleteVehicle _corpse; }]; You are using hasInterface in onPlayerRespawn.sqf that it's not needed. 2 hours ago, Cockheaven said: waituntil{time>30}; the use of the waituntil in my given code was just to pop up the notification for the objective ( just to know ) i'm going to check the Rabbit.sqf and tell you but i noticed you didn't add ZaellixA's additions ?! 2 Share this post Link to post Share on other sites
Cockheaven 21 Posted June 9, 2019 (edited) I forgot about 41 minutes ago, GEORGE FLOROS GR said: initPlayerlocal.sqf Thanks 41 minutes ago, GEORGE FLOROS GR said: ZaellixA's additions ?! I plan on implementing them once the base code is working. @ZaellixAis 100% correct on what I am looking for. Edited June 9, 2019 by Cockheaven Stupid phone 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 9, 2019 31 minutes ago, Cockheaven said: Thanks This is a little bit more clear , try this in the initserver.sqf : waituntil{time>2}; _allPlayers = allUnits select {isPlayer _x && {alive _x} && {!(_x isKindOf "HeadlessClient_F")}}; _target = selectRandom _allPlayers; _allPlayers = _allPlayers - [_target]; systemchat format ["%1",_target]; diag_log format ["%1",_target]; [_allPlayers,["task_1","Mission_1"],["Description : ...","Find and Kill",""], getpos _target,true,1,true,"kill",true] call BIS_fnc_taskCreate; ["task_1","ASSIGNED",true] spawn BIS_fnc_taskSetState; [_target] spawn{ _unit = _this select 0; while {alive _unit}do{ ["task_1",_unit] call BIS_fnc_taskSetDestination; uisleep 20; }; }; waitUntil {uisleep 1;!alive _target}; systemchat "end"; diag_log "end"; ["task_1", "SUCCEEDED",true] spawn BIS_fnc_taskSetState; Uisleep 3; ["task_1"] call BIS_fnc_deleteTask; Uisleep 2; []execvm "script.sqf"; 1 Share this post Link to post Share on other sites
ZaellixA 383 Posted June 9, 2019 Yep, I believe GEORGE FLOROS has some points in his code (above) that I would recommend too. One small example is that you "calculate" allPlayers twice, one as _allPlayers and one as _Players (while George gets it only once). Also, as I "showcased" (I am not suggesting that this is THE BEST way) with my example I believe the best way to go is with eventHandlers. Although this may be just a personal preference (but possibly an overhead reduction too) so you should first of all go for a way that you feel more comfortable with. Nevertheless using the onPlayerRespawn and onPlayerKilled scripts is equally nice, plus you get all your code kinda concentrated on one (or two) place(s) instead of having code related to an object or process spread out in different scripts. One last suggestion. Try to write small chunks of code, test them to make sure they work as intended and then either combine them or extend them to reach your final "destination" in smaller steps. It will make the whole process a lot easier. For example, make a small chunk of code to add make someone the rabbit and make sure it works. When this is done you can take for granted that you will always have a rabbit in the way you want. Then you can go on, add a marker on the rabbit and refresh it every once in a while. This way you will take small SECURED steps and you will reach your destination SAFELY. It may take a little bit longer but you when you arrive you will be sure that it works (and then you start fixing bugs 🤣). Unfortunately I will be on the road for the next two days so I won't be able to help with tests. If by the time I reach home you still encounter issues I will do my best to support. Keep up the good work 🙂. 2 Share this post Link to post Share on other sites