Jump to content
Sign in to follow this  
twiggy158

Need Help Getting this Script to Work

Recommended Posts

Basically what I want this script to do is check and see how many players are in the server, as well as on each side. It then needs to monitor the score to see if the opposing teams score reaches or passes the player amount on that team (Such as OPFOR having two people, and BLUFOR's score is 2, it will set #West section of the script to true). When it becomes true, the "round" will end and kill the winning players so they re-spawn. It doesn't seem to be happening though. It will correctly give me the amount of players on the server as well as per team, but when the score reaches the amount of players on the opposing team, nothing happens. This is my first time really attempting to script so I realize this may not be the most effective way of achieving this, but any advice would be great. I can't seem to find a decent way to debug this even with using the UODebugger. Thanks in advance!

I also realize that there may be some redundant variables in there, but i was my first time using them so I wanted to make sure I knew how to get them to work.

// Declare Variables
private ["_playerList", "_playerCount", "_westPlayers", "_eastPlayers", "_scoreWest", "_scoreEast"];
_playerList = playableUnits;
_playerCount = count _playerList;
_westPlayers = west countSide _playerList;
_eastPlayers = east countSide _playerList;
_scoreWest = scoreSide west;
_scoreEast = scoreSide east;

// Display total amount of players in game. As well as on each side.
if (_playerCount > 0) then {
gamelogic1 globalChat format["%1 player(s) in this match", _playerCount];
sleep 1;
gamelogic1 globalChat format["%1 player(s) are BLUFOR", _westPlayers];
sleep 1;
gamelogic1 globalChat format["%1 player(s) are OPFOR", _eastPlayers];
};

// Check if West score is higher than East Players. If not, check if East score is higher than West Players
#West
if (_scoreWest >= _eastPlayers) then {
gamelogic1 globalChat "BLUFOR wins the round!";
sleep 5;
gamelogic1 globalChat "Respawning players...";
sleep 3;
{if (side _x == west) then {_x setDamage 1};} foreach allunits;
_scoreWest = 0;
westFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
eastFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
} else {
	if (_scoreEast >= _westPlayers) then {
		gamelogic1 globalChat "OPFOR wins the round!";
		sleep 5;
		gamelogic1 globalChat "Respawning players...";
		sleep 3;
		{if (side _x == east) then {_x setDamage 1};} foreach allunits;
		_scoreEast = 0;
		westFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
		eastFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
		} else {
			goto "West";
			};
};

TL;DR: Something is wrong with the section under #West. Can't figure out what though.

Edited by TwiGGy158

Share this post


Link to post
Share on other sites

#west and goto are sqs while the rest looks sqf

I'm not on my scripting pc at the moment but you might be trying to make a loop ...like this....(just check the curly brakets)

// Check if West score is higher than East Players. If not, check if East score is higher than West Players
while{true}do
{
if (_scoreWest >= _eastPlayers) then {
gamelogic1 globalChat "BLUFOR wins the round!";
sleep 5;
gamelogic1 globalChat "Respawning players...";
sleep 3;
{if (side _x == west) then {_x setDamage 1};} foreach allunits;
_scoreWest = 0;
westFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
eastFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
} else {
	if (_scoreEast >= _westPlayers) then {
		gamelogic1 globalChat "OPFOR wins the round!";
		sleep 5;
		gamelogic1 globalChat "Respawning players...";
		sleep 3;
		{if (side _x == east) then {_x setDamage 1};} foreach allunits;
		_scoreEast = 0;
		westFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
		eastFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
		};
};
};

Edited by Squ33z3

Share this post


Link to post
Share on other sites

I tried that and it doesn't seem to be looping. I have to manually start the script again to get it to execute that part. I also noticed that the chat messages aren't appearing to everyone in the server. only to whoever started the script. Also, the score doesn't seem to reset either, but I have no idea how to go about resetting the side scores.

Also on a side note, are there any good debugging tools to see if something is going wrong in the script?

Edited by TwiGGy158

Share this post


Link to post
Share on other sites

There is a debug tool ingame. Use your .rpt file which you can find in %appdata%\Local\Arma 3 Alpha\ to spot any errors from the script. A bit more info here: http://forums.bistudio.com/showthread.php?149101-Things-you-should-%28probably%29-do-before-posting-a-new-thread-in-this-section

As squ pointed out you mixed sqf with sqs. As for why your chat is not showing up is because it's not global. You'd have to execute the script client-side to display text properly for everybody. That requires you splitting the script though as running scripts which add scores client-side will result in nasty mixups.

Share this post


Link to post
Share on other sites
There is a debug tool ingame. Use your .rpt file which you can find in %appdata%\Local\Arma 3 Alpha\ to spot any errors from the script. A bit more info here: http://forums.bistudio.com/showthread.php?149101-Things-you-should-%28probably%29-do-before-posting-a-new-thread-in-this-section

As squ pointed out you mixed sqf with sqs. As for why your chat is not showing up is because it's not global. You'd have to execute the script client-side to display text properly for everybody. That requires you splitting the script though as running scripts which add scores client-side will result in nasty mixups.

Ah thank you for that!

But how would I go about making the chat work properly? And as far as splitting the scripts what would I have to split from this script? Sorry for the obvious questions but I have very little experience with being this in depth with scripting in Arma.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×