Search the Community
Showing results for tags 'codehelp'.
Found 1 result
-
This script is a bit of a doozie and I generally wanted it to be handled within all one SQF... Or at least thats what I thought I could do. But my issue is with every attempt at (albeit randomly) changing scopes/globals I always get 'error undefined variable in _' and to be quite I have no idea what I am doing outside of looking at several examples of several things, then attempting to combine them. So I have a scenario involving 4 groups, in a traitor-survival permadeath like scenario. Campers, killers, hunters, and guards. I wanted to an add action script on a Bell to ring that, in this order: Institutes a 30 second COOLDOWN for the addaction. Initiates a titleText BLACK FADED screen when activated, that pauses then shows text like "12 hours later" Hidden by that screen I wish to teleport players to certain markers And skips time 12 hours, more pause BLACK IN titleCut when then the teleportation has happened and they see a different time of day upon lifting Script/Addaction resets/loops Technicalities: Script must be repeatable for my purpose I want a UNIT VARIABLE NAME array, 1 for each pre mentioned group that is NOT SIDE dependent. All units are on Indfor. And a TELEPORTATION MARKER array, and code inserted to the teleportation bits so that once activated, for example, all campers will randomlytravel to one of the several CAMPER markers. This allows for rounds to not be the exact thing. CODE MUST NOT BE SIDE DEPENDENT. Ive clearly tried to make 3 arrays, one for each 'type', the reason why all units are Indfor is for smooth 'roleplay' purposes What Works: I believe the time passage works. The black screen fade in/out/text works. The teleportation does NOT WORK. I am screwing up with scopes/globals in accessing the array's Ive set up... Genuinely would like some help but have no idea how to proceed forward and I thank anyone in advance bellInteraction.sqf // Define the unit and marker arrays outside the function to avoid redefining them every time the script runs. campers = ["cpr1", "cpr2", "cpr3", "cpr4", "cpr5", "cpr6", "cpr7", "cpr8", "cpr9"]; campMarkers = ["campMarker1", "campMarker2", "campMarker3"]; scouts = ["sct1", "sct2", "sct3"]; scoutsMarkers = ["scoutMarker1", "scoutMarker2", "scoutMarker3"]; hunters = ["htr1", "htr2", "htr3"]; huntersMarkers = ["hunterMarker1", "hunterMarker2", "hunterMarker3"]; guards = ["grd1", "grd2", "grd3"]; guardsMarkers = ["guardMarker1", "guardMarker2", "guardMarker3"]; // Teleport function _teleportPlayers = { params ["_unitArray", "_markerArray"]; { private _unit = missionNamespace getVariable _x; if (!isNull _unit) then { private _randomMarker = selectRandom _markerArray; _unit setPos (getMarkerPos _randomMarker); }; } forEach _unitArray; }; // The main script that will be executed when the bell is rung _bellScript = { params ["_target", "_caller", "_id"]; // Check for cooldown if (!isNil {bellCooldown}) exitWith { _caller sideChat "The bell is on cooldown. Please wait."; }; // Set cooldown bellCooldown = true; _target removeAction _id; // Screen fade out to black titleText ["", "BLACK FADED", 1]; sleep 5; titleText ["<t color='#ffffff' size='5'>12 hours later...</t>", "BLACK FADED", -1, true, true]; sleep 2; // Skip 12 hours skipTime 12; // Teleport each group [campers, campMarkers] call _teleportPlayers; [scouts, scoutsMarkers] call _teleportPlayers; [hunters, huntersMarkers] call _teleportPlayers; [guards, guardsMarkers] call _teleportPlayers; // Screen fade in from black titleCut ["", "BLACK IN", 5]; // Reset cooldown after 10 minutes (600 seconds) sleep 600; bellCooldown = nil; // Re-add the action to the bell _target addAction ["Ring Bell", _bellScript]; }; // Execute the script with the provided parameters params ["_bell"]; _bell addAction ["Ring Bell", _bellScript]; The Bell Init Code: bell addAction ["Ring Bell", "mscripts\bellInteraction.sqf"];
- 1 reply
-
- 1
-
- scripthelp
- coding
- (and 9 more)