daskunk 1 Posted September 6, 2013 Could someone please tell me what i have done wrong here. It was working fine using this code for blufor and opfor if (!isDedicated) then { //false shows the score of both sides //true only the score of the players side is shown hintTicketSide = false; //A client side function to hint ticket scores fnc_HintTickets = { _HStringEast = format ["East = %1",_this select 0]; _HStringWest = format ["West = %1",_this select 1]; if (hintTicketSide) then { if (side player == west) then { hintSilent _HStringWest; }else{ hintSilent _HStringEast; }; }else{ hintSilent format["%1\n%2",_HStringWest,_HStringEast] }; }; }; if (isServer) then { //Start a thread to monitor the sector _handle = [] spawn { //Setup default variables //east = 0, west = 1 _Tickets = [20, 20]; _captureTime = 120; _Sector = Capture; _AreaLost = false; _GameOver = false; while {(!(_GameOver))} do { //WaitUntil someone actually owns the sector waitUntil { _Sector getVariable "owner" != sideUnknown}; _SectorOwner = _Sector getVariable "owner"; //Start timer _captureEnd = time + _captureTime; _AreaLost = false; while {time < _captureEnd} do { sleep 0.5; if ((_Sector getVariable "owner") != _SectorOwner) exitWith {_AreaLost = true}; }; if (!(_AreaLost) ) then { //Decrease opposing tickets _SectorOwner = _SectorOwner call BIS_fnc_sideID; _opposingTeam = ((_SectorOwner * -1) + 1); //0 = 1 , 1 = 0 _Tickets set [_opposingTeam , (_Tickets select _opposingTeam) - 1]; //If opposingTeam have run out of tickets if ((_Tickets select _opposingTeam) == 0) then { //Debrief WON [["end1", true, 2],"BIS_fnc_endMission",(_SectorOwner call BIS_fnc_sideType),false] call BIS_fnc_MP; //Debrief LOST [["end2", false, 2],"BIS_fnc_endMission",(_opposingTeam call BIS_fnc_sideType),false] call BIS_fnc_MP; _GameOver = true; }; //Send a hint to all clients showing tickets [_Tickets,"fnc_HintTickets",true,false] call BIS_fnc_MP; }; }; }; }; But after trying to add in the Guerrila also it now gives errors and wont work. waitUntil { _Sector getVariable "owner" != sideUnkno> Error position: <_Sector getVariable "owner" != sideUnkno> Error Undefined variable in expression: _sector File C:\Users\Gary\Documents\Arma 3 - Other Profiles\-1PARA-DaSkunk\mpmissions\AfterTheRainV01.Altis\init.sqf, line 60 Error in expression <hile {(!(_GameOver))} do { if (!isDedicated) then { //false shows the score of both sides //true only the score of the players side is shown hintTicketSide = false; //A client side function to hint ticket scores fnc_HintTickets = { _HStringEast = format ["East = %1",_this select 0]; _HStringWest = format ["West = %1",_this select 1]; _HStringWest = format ["Guerrila = %1",_this select 2]; if (hintTicketSide) then { if (side player == west) then { hintSilent _HStringWest; }else{ hintSilent _HStringEast; }else{ hintSilent _HStringGuerrila; }; }else{ hintSilent format["%1\n%2",_HStringWest,_HStringEast,_HStringGuerrila] }; }; }; if (isServer) then { //Start a thread to monitor the sector _handle = [] spawn { //Setup default variables //east = 0, west = 1 _Tickets = [20, 20]; _captureTime = 120; _Sector = Capture; _AreaLost = false; _GameOver = false; while {(!(_GameOver))} do { //WaitUntil someone actually owns the sector waitUntil { _Sector getVariable "owner" != sideUnknown}; _SectorOwner = _Sector getVariable "owner"; //Start timer _captureEnd = time + _captureTime; _AreaLost = false; while {time < _captureEnd} do { sleep 0.5; if ((_Sector getVariable "owner") != _SectorOwner) exitWith {_AreaLost = true}; }; if (!(_AreaLost) ) then { //Decrease opposing tickets _SectorOwner = _SectorOwner call BIS_fnc_sideID; _opposingTeam = ((_SectorOwner * -1) + 1); //0 = 1 , 1 = 0 _Tickets set [_opposingTeam , (_Tickets select _opposingTeam) - 1]; //If opposingTeam have run out of tickets if ((_Tickets select _opposingTeam) == 0) then { //Debrief WON [["end1", true, 2],"BIS_fnc_endMission",(_SectorOwner call BIS_fnc_sideType),false] call BIS_fnc_MP; //Debrief LOST [["end2", false, 2],"BIS_fnc_endMission",(_opposingTeam call BIS_fnc_sideType),false] call BIS_fnc_MP; _GameOver = true; }; //Send a hint to all clients showing tickets [_Tickets,"fnc_HintTickets",true,false] call BIS_fnc_MP; }; }; }; }; Share this post Link to post Share on other sites
Zenophon 110 Posted September 6, 2013 In the second script, you declare '_HStringWest' twice and never declare '_HStringGuerrila'. That seems unrelated though. The error you are getting means exactly what it says. You declare '_sector = capture;', so 'capture' could be undefined. So what is 'capture'? How is it declared? Do any other functions use it? How many threads of this function are running? You could also try adding a private statement at the beginning of the spawned code block: private ["_Tickets", "_captureTime", "_Sector", etc ...]; You could also simply use 'capture' instead of '_sector' and see if the error reports that 'capture' is undefined. If capture is defined, then the private statement could help. Share this post Link to post Share on other sites
Larrow 2753 Posted September 6, 2013 (edited) The original script i wrote for you was for east vs west, just adding to the hints is not going to help you as all the code below needs to be changed to take into account all three factions east, west and independant. You cant do if else else , it is just bad syntax. if (side player == west) then { hintSilent _HStringWest; }else{ hintSilent _HStringEast; }else{ hintSilent _HStringGuerrila; }; if (!isDedicated) then { //false shows the score of both sides //true only the score of the players side is shown hintTicketSide = false; //A client side function to hint ticket scores fnc_HintTickets = { _HStringEast = format ["East = %1",_this select 0]; _HStringWest = format ["West = %1",_this select 1]; [color="#FF0000"]_HStringInd = format ["Independent = %1",_this select 1];[/color] if (hintTicketSide) then { [color="#FF0000"]switch (side player) do { case west : { hintSilent _HStringWest; }; case east : { hintSilent _HStringEast; }; case independent : { hintSilent _HStringInd; }; };[/color] }else{ hintSilent format["%1\n%2[color="#FF0000"]\n%3[/color]",_HStringWest,_HStringEast,[color="#FF0000"]_HStringInd[/color]] }; }; }; if (isServer) then { //Start a thread to monitor the sector _handle = [] spawn { //Setup default variables //east = 0, west = 1, independant = 2 _Tickets = [20, 20, [color="#FF0000"]20[/color]]; _captureTime = 120; _Sector = Capture; //name of sector module in editor _AreaLost = false; _GameOver = false; while {(!(_GameOver))} do { //WaitUntil someone actually owns the sector waitUntil { _Sector getVariable "owner" != sideUnknown}; _SectorOwner = _Sector getVariable "owner"; //Start timer _captureEnd = time + _captureTime; _AreaLost = false; while {time < _captureEnd} do { sleep 0.5; if ((_Sector getVariable "owner") != _SectorOwner) exitWith {_AreaLost = true}; }; if (!(_AreaLost) ) then { //Decrease opposing tickets [color="#FF0000"]_sides = [0,1,2]; _opposingTeams = _sides - [_SectorOwner call BIS_fnc_sideID]; { _Tickets set [ _x, (_Tickets select _x) - 1]; }forEach _opposingTeams; { //If one of the Teams has run out of tickets if ((_Tickets select _x) == 0) exitWith { { //Check to make sure two teams didnt reach 0 tickets at the same time if(_x == 0) then { //Debrief LOST [["end3", false, 2],"BIS_fnc_endMission",(_forEachIndex call BIS_fnc_sideType),false] call BIS_fnc_MP; _sides = _sides - [_forEachIndex]; }; }forEach _Tickets; //if only one team LOST if((count _sides) > 1) then { //Debrief WON _won = (_Tickets select (_sides select 0)) max (_Tickets select (_sides select 1)); [["end1", true, 2],"BIS_fnc_endMission",((_Tickets find _won) call BIS_fnc_sideType),false] call BIS_fnc_MP; _sides = _sides - [(_Tickets find _won)]; //Debrief FAILED [["end2", false, 2],"BIS_fnc_endMission",((_sides select 0) call BIS_fnc_sideType),false] call BIS_fnc_MP; }else{ //No FAILED as two teams reached 0 tickets at the same time //Debrief WON [["end1", true, 2],"BIS_fnc_endMission",((_sides select 0) call BIS_fnc_sideType),false] call BIS_fnc_MP; }; _GameOver = true; }; }forEach _sides;[/color] //Send a hint to all clients showing tickets [_Tickets,"fnc_HintTickets",true,false] call BIS_fnc_MP; }; }; }; }; All the code highlighted in red are the changes i have done to the original code. fnc_HintTickets now correctly receives 3 scores from the code and assigns them each to their own respective sides hint string, it then uses a switch statement dependant on player side of which hint to show. _Tickets has had an extra index added to store the score for Independants. The whole section of code to decrease tickets and check who won has changed quite a bit. There is now an end1, end2 and end3. WON (side with most tickets when a side reaches 0 tickets), end1 LOST (teams that reached 0 tickets), end3 FAILED (side that neither won or lost), end2 I HAVE NOT TESTED THESE CHANGES!!! but looks ok, famous last words Edited September 6, 2013 by Larrow fixed missing bracket in code Share this post Link to post Share on other sites
daskunk 1 Posted September 6, 2013 Larrow again ty vm for taking the time to help me. I am getting this error now :) Error in expression <,(_sides select 0) call BIS_fnc_sideType),false] call BIS_fnc_MP; }else{ [["en> Error position: <),false] call BIS_fnc_MP; }else{ [["en> Error Missing ] File C:\Users\Gary\Documents\Arma 3 - Other Profiles\-1PARA-DaSkunk\mpmissions\AfterTheRainV01.Altis\init.sqf, line 113 Error in expression <,(_sides select 0) call BIS_fnc_sideType),false] call BIS_fnc_MP; }else{ [["en> Error position: <),false] call BIS_fnc_MP; }else{ [["en> Error Missing ] File C:\Users\Gary\Documents\Arma 3 - Other Profiles\-1PARA-DaSkunk\mpmissions\AfterTheRainV01.Altis\init.sqf, line 113 Share this post Link to post Share on other sites
Larrow 2753 Posted September 6, 2013 //Debrief FAILED [["end2", false, 2],"BIS_fnc_endMission",[color="#FF0000"]([/color](_sides select 0) call BIS_fnc_sideType),false] call BIS_fnc_MP; Sorry i missed a bracket there. Try that, still not near a PC with ARMA atm to test. Share this post Link to post Share on other sites
daskunk 1 Posted September 7, 2013 Now getting this error bud... from rpt waitUntil { _Sector getVariable "owner" != sideUnkno> Error position: <_Sector getVariable "owner" != sideUnkno> Error Undefined variable in expression: _sector File C:\Users\Gary\Documents\Arma 3 - Other Profiles\-1PARA-DaSkunk\mpmissions\AfterTheRainV01.Altis\init.sqf, line 65 Error in expression <ile {(!(_GameOver))} do { Share this post Link to post Share on other sites
Larrow 2753 Posted September 7, 2013 (edited) Ok ive had time to test this today, other than an error in one of the hint lines that was messing up the hints the code is working perfectly fine for me. When i originally wrote this code for you, you wanted it hard coded for a sector called capture, as Zenophon pointed out the undefined error you are getting is related to this, did you check out his advice?? This is the line that specifies the sector name, as per the name box in the module. _Sector = Capture; //name of sector module in editor Below is the latest code with the hints fixed. (the two changes are in red) if (!isDedicated) then { //false shows the score of both sides //true only the score of the players side is shown hintTicketSide = false; //A client side function to hint ticket scores fnc_HintTickets = { _HStringEast = format ["East = %1",_this select 0]; _HStringWest = format ["West = %1",_this select 1]; _HStringInd = format ["Independent = %1",_this select [color="#FF0000"]2[/color]]; if (hintTicketSide) then { switch (side player) do { case west : { hintSilent _HStringWest; }; case east : { hintSilent _HStringEast; }; case independent : { hintSilent _HStringInd; }; }; }else{ hintSilent format["%1\n%2\n%3",_HStringWest,_HStringEast,_HStringInd][color="#FF0000"];[/color] }; }; }; if (isServer) then { //Start a thread to monitor the sector _handle = [] spawn { //Setup default variables //east = 0, west = 1, independant = 2 _Tickets = [20, 20, 20]; _captureTime = 120; _Sector = Capture; //name of sector module in editor _AreaLost = false; _GameOver = false; while {(!(_GameOver))} do { //WaitUntil someone actually owns the sector waitUntil { _Sector getVariable "owner" != sideUnknown}; _SectorOwner = _Sector getVariable "owner"; //Start timer _captureEnd = time + _captureTime; _AreaLost = false; while {time < _captureEnd} do { sleep 0.5; if ((_Sector getVariable "owner") != _SectorOwner) exitWith {_AreaLost = true}; }; if (!(_AreaLost) ) then { //Decrease opposing tickets _sides = [0,1,2]; _opposingTeams = _sides - [_SectorOwner call BIS_fnc_sideID]; { _Tickets set [ _x, (_Tickets select _x) - 1]; }forEach _opposingTeams; { //If one of the Teams has run out of tickets if ((_Tickets select _x) == 0) exitWith { { //Check to make sure two teams didnt reach 0 tickets at the same time if(_x == 0) then { //Debrief LOST [["end3", false, 2],"BIS_fnc_endMission",(_forEachIndex call BIS_fnc_sideType),false] call BIS_fnc_MP; _sides = _sides - [_forEachIndex]; }; }forEach _Tickets; [color="#00C000"]//if only one team LOST, find who failed if((count _sides) > 1) then { _failed = (_Tickets select (_sides select 0)) min (_Tickets select (_sides select 1)); //Debrief FAILED [["end2", false, 2],"BIS_fnc_endMission",((_Tickets find _failed) call BIS_fnc_sideType),false] call BIS_fnc_MP; _sides = _sides - [(_Tickets find _failed)]; }; //Debrief WON [["end1", true, 2],"BIS_fnc_endMission",((_sides select 0) call BIS_fnc_sideType),false] call BIS_fnc_MP;[/color] _GameOver = true; }; }forEach _sides; //Send a hint to all clients showing tickets [_Tickets,"fnc_HintTickets",true,false] call BIS_fnc_MP; }; }; }; }; EDIT: Cleaned up endMission conditions, (repeated code and readability) highlighted in green. Makes no difference to script operation. Edited September 7, 2013 by Larrow cleaned up endMission conditions Share this post Link to post Share on other sites
daskunk 1 Posted September 7, 2013 Larrow your a star m8 thanks very much. And yes i forgot to name it Capture lol, thanx for your help to Zen much appreciated. I thought i may be able to understand how it works but its a tougher task atm for me i think i am trying to run before i can walk. Once again thanks for the great support and help chaps o7 Skunk Share this post Link to post Share on other sites
Larrow 2753 Posted September 7, 2013 I thought i may be able to understand how it works but its a tougher task atm for me i think i am trying to run before i can walk.Yer thats not going be the easiest script to learn from i have used a few bis functions that compare sides to a number and then used this number as indexs to take care of tickets for each side.Glad you got it working though Share this post Link to post Share on other sites