Jump to content
Sign in to follow this  
cavemans

Param score and timelimit help

Recommended Posts

Can someone please tell me what i am doing wrong with this?

init.sqf

execVM "briefing.sqf";
/ --- Info text
waitUntil{!(isNil "BIS_fnc_init")};
sleep 5;
["Grounded", "Survival of the fittest!"] call BIS_fnc_infoText;
sleep 3;
["Map created by", "critblade & cavemans/zach"] call BIS_fnc_infoText;


execVM "parameters.sqf";

parameters.sqf

_timelimit = (paramsArray select 0);
_scorelimit = (paramsArray select 1);
time = 0;
EastScore = 0;
Westscore = 0;
missionplaying = True;

//score calculation and mission ending loop
While {missionplaying == True} do {
sleep 5;
time = time + 5; 
       hint "working";
}
if ((!alive player) and (side player == West)) then {EastScore = EastScore + 1}; 
if ((!alive player) and (side player == East)) then {WestScore = WestScore + 1};



if ((time >= _timelimit) and (WestScore != Eastscore)) then {if (WestScore > Eastscore) then {hint "Time is up!\nUS forces win!"; sleep 5; endmission "end1"} else {hint "Time is up!\nInsurgents win!"; sleep 5; endmission "end1"};};
if ((time >= _timelimit) and (WestScore == Eastscore)) then {hint "Time is up!\nScore is tied!\nThe match is a draw!"; sleep 5; endmission "end1"};
if (Westscore >= _scorelimit) then {if (side player == West) then {hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"} else {hint "Mission failed!\nThe infidels have taken\nthe town!"; sleep 6; endmission "end1"};};
if (Eastscore >= _scorelimit) then {if (side player == East) then {hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"} else {hint "Mission failed!\nInsurgents have taken\nthe town!"; sleep 6; endmission "end1"};};
if (isServer) then 
		{
	publicVariable "WestScore"; 
	publicVariable "EastScore";
	publicVariable "time"
	};
};

description.exe

OnLoadMission = "Hellstrip";
OnLoadIntro = "Survive";// Title that appears on screen in briefing

respawn="BASE"
respawnDelay= 5
RespawnDialog= 1
disabledAI=True;
debriefing = True;


class Header
{
gameType = DM;
minPlayers = 1;
maxPlayers = 8;
playerCountMultipleOf = 1;

};



class Params  
{

class TimeLimit 
{  	
	title = "Time Until Mission Ends (in minutes)";
			values[] = {10800,60,300,600,900,1200,1500,1800};
	texts[] = {"No Limit","1","5","10","15","20","25","30"};
	default = 10800;
};

class ScoreLimit
{  
	title = "Score needed for Victory";
	values[] = {2,10,20,50,100,150,250,500,1000};
	texts[] = {"2","10","20","50","100","150","250","500","1000"};
	default = 2;
	};
};

Edited by cavemans

Share this post


Link to post
Share on other sites

There's a lot wrong. :)

1. I canged your "time" variable to "timeElapsed". Because time is a reserved command.

2. Move this part into the init.sqf:

[] spawn {
if (!isDedicated) then {
	while {true} do {
		waitUntil {alive player};
		waitUntil {!alive player};
		if (side player == West) then { EastScore = EastScore + 1; publicVariable "EastScore"; };
		if (side player == East) then { WestScore = WestScore + 1; publicVariable "WestScore"; };
	};
};
};

[] spawn {
_timelimit = (paramsArray select 0);
_scorelimit = (paramsArray select 1);
EastScore = 0;
Westscore = 0;
waitUntil {!(isNil "GameOver")};
if ((timeElapsed >= _timelimit) and (WestScore != Eastscore)) then {if (WestScore > Eastscore) then {hint "Time is up!\nUS forces win!"; sleep 5; endmission "end1"} else {hint "Time is up!\nInsurgents win!"; sleep 5; endmission "end1"};};
if ((timeElapsed >= _timelimit) and (WestScore == Eastscore)) then {hint "Time is up!\nScore is tied!\nThe match is a draw!"; sleep 5; endmission "end1"};
if (Westscore >= _scorelimit) then {if (side player == West) then {hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"} else {hint "Mission failed!\nThe infidels have taken\nthe town!"; sleep 6; endmission "end1"};};
if (Eastscore >= _scorelimit) then {if (side player == East) then {hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"} else {hint "Mission failed!\nInsurgents have taken\nthe town!"; sleep 6; endmission "end1"};};
};

3. This is what's left, and should only be executed server side:

if (!isServer) exitWith {};

_timelimit = (paramsArray select 0);
_scorelimit = (paramsArray select 1);
EastScore = 0;
Westscore = 0;

//score calculation and mission ending loop
[] spawn {
timeElapsed = 0;
missionplaying = True;
While {missionplaying} do {
	sleep 5;
	timeElapsed = timeElapsed + 5; publicVariable "timeElapsed";
	hint "working";
};
};

waitUntil {!(isNil "timeElapsed")};
waitUntil {(timeElapsed >= _timelimit) || (Westscore >= _scorelimit) || (Eastscore >= _scorelimit)};

missionplaying = false;
GameOver = true; publicVariable "GameOver";

I've not tested it. But this structure makes more sense. Tell me if something is still not working. :)

Edited by sxp2high

Share this post


Link to post
Share on other sites
There's a lot wrong. :)

I've not tested it. But this structure makes more sense. Tell me if something is still not working. :)

Im confused wehre do I put the bottom part?

Share this post


Link to post
Share on other sites

The last code is your parameters.sqf or whatever you wanna call it. Exec it from your init.sqf like you've done before.

Share this post


Link to post
Share on other sites
The last code is your parameters.sqf or whatever you wanna call it. Exec it from your init.sqf like you've done before.

Not working?

Share this post


Link to post
Share on other sites

Init.sqf:

waitUntil {(isDedicated) || !(isNull player)};

if (isNil "paramsArray") then {
if (isClass (missionConfigFile/"Params")) then {
	for "_i" from 0 to (count (missionConfigFile/"Params") - 1)	do {
		_paramName = configName ((missionConfigFile >> "Params") select _i); _paramValue = getNumber (missionConfigFile >> "Params" >> _paramName >> "default"); call compile format ["%1 = %2", _paramName, _paramValue];
	};
}; ParamInit = true;
} else {
for "_i" from 0 to (count paramsArray - 1) do {
	_paramName = configName ((missionConfigFile >> "Params") select _i); _paramValue = paramsArray select _i; call compile format ["%1 = %2", _paramName, _paramValue];
};	ParamInit = true;
};

if (isNil "EastScore") then { EastScore = 0; };
if (isNil "WestScore") then { WestScore = 0; };

waitUntil {!(isNil "ParamInit")};

execVM "parameters.sqf";

execVM "briefing.sqf";
[] spawn {
if (!isDedicated) then {
	waitUntil {!(isNil "BIS_fnc_init")};
	waitUntil {alive player};
	sleep 5;
	["Grounded", "Survival of the fittest!"] call BIS_fnc_infoText;
	sleep 3;
	["Map created by", "critblade & cavemans/zach"] call BIS_fnc_infoText;
};
};

[] spawn {
   if (!isDedicated) then {
       while {true} do {
           waitUntil {alive player};
           waitUntil {!alive player};
           if (side player == West) then { EastScore = EastScore + 1; publicVariable "EastScore"; };
           if (side player == East) then { WestScore = WestScore + 1; publicVariable "WestScore"; };
       };
   };
};

[] spawn {
   if (!isDedicated) then {
	waitUntil {!(isNil "GameOver")};
	if ((timeElapsed >= TimeLimit) and (WestScore != Eastscore)) then {if (WestScore > Eastscore) then {hint "Time is up!\nUS forces win!"; sleep 5; endmission "end1"} else {hint "Time is up!\nInsurgents win!"; sleep 5; endmission "end1"};};
	if ((timeElapsed >= TimeLimit) and (WestScore == Eastscore)) then {hint "Time is up!\nScore is tied!\nThe match is a draw!"; sleep 5; endmission "end1"};
	if (Westscore >= ScoreLimit) then {if (side player == West) then {hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"} else {hint "Mission failed!\nThe infidels have taken\nthe town!"; sleep 6; endmission "end1"};};
	if (Eastscore >= ScoreLimit) then {if (side player == East) then {hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"} else {hint "Mission failed!\nInsurgents have taken\nthe town!"; sleep 6; endmission "end1"};};
};
};

parameters.sqf:

if (!isServer) exitWith {};
//score calculation and mission ending loop
[] spawn {
   timeElapsed = 0;
   missionplaying = True;
   While {missionplaying} do {
       sleep 5;
       timeElapsed = timeElapsed + 5; publicVariable "timeElapsed";
       hint "working";
   };
};

waitUntil {!(isNil "timeElapsed")};
waitUntil {(timeElapsed >= TimeLimit) || (Westscore >= ScoreLimit) || (Eastscore >= ScoreLimit)};

GameOver = true; publicVariable "GameOver";
missionplaying = false;

Try this! :bounce3:

Edited by sxp2high

Share this post


Link to post
Share on other sites

Thank you, it works. Now to get rid of the line with the hint on it. Hopefully i dont mess it up. By the way how close was I with my script? It looks like i was no were close to it.

EDIT: nope sorry actauly it isnt counting the time limit right and the score right. We played for 3 minutes and it counted it as 10, it also said it was a tie when it wasnt.

Edited by cavemans

Share this post


Link to post
Share on other sites

OK fixed again :D

And this time i tested it myself... was all working fine.

Your approach wasn't that bad. You just need to learn multipalyer locality which is pretty complicated at the beginning. :) Just search the forums for locality and try to understand what i've written for you. If you have any questions i will explain it to you.

Description.ext (had some missing ; which i didn't notice before):

OnLoadMission = "Hellstrip";
OnLoadIntro = "Survive";// Title that appears on screen in briefing

respawn="BASE";
respawnDelay= 5;
RespawnDialog= 1;
disabledAI=True;
debriefing = True;


class Header {
gameType = DM;
minPlayers = 1;
maxPlayers = 8;
};



class Params {

class TimeLimit {  	
	title = "Time Until Mission Ends (in minutes)";
	values[] = {10800,60,300,600,900,1200,1500,1800};
	texts[] = {"No Limit","1","5","10","15","20","25","30"};
	default = 10800;
};

class ScoreLimit {  
	title = "Score needed for Victory";
	values[] = {2,10,20,50,100,150,250,500,1000};
	texts[] = {"2","10","20","50","100","150","250","500","1000"};
	default = 2;
	};
};

Init.sqf:

waitUntil {(isDedicated) || !(isNull player)};

if (isNil "paramsArray") then {
   if (isClass (missionConfigFile/"Params")) then {
       for "_i" from 0 to (count (missionConfigFile/"Params") - 1)    do {
           _paramName = configName ((missionConfigFile >> "Params") select _i); _paramValue = getNumber (missionConfigFile >> "Params" >> _paramName >> "default"); call compile format ["%1 = %2", _paramName, _paramValue];
       };
   }; ParamInit = true;
} else {
   for "_i" from 0 to (count paramsArray - 1) do {
       _paramName = configName ((missionConfigFile >> "Params") select _i); _paramValue = paramsArray select _i; call compile format ["%1 = %2", _paramName, _paramValue];
   };    ParamInit = true;
};

if (isNil "EastScore") then { EastScore = 0; };
if (isNil "WestScore") then { WestScore = 0; };

waitUntil {!(isNil "ParamInit")};

execVM "parameters.sqf";
execVM "briefing.sqf";

[] spawn {
   if (!isDedicated) then {
       waitUntil {!(isNil "BIS_fnc_init")};
       waitUntil {alive player};
       sleep 5;
       ["Grounded", "Survival of the fittest!"] call BIS_fnc_infoText;
       sleep 3;
       ["Map created by", "critblade & cavemans/zach"] call BIS_fnc_infoText;
   };
};

if (!isDedicated) then {
if (side player == West) then {
	_ScoreEH = player addMPEventHandler ["mpkilled", {
		EastScore = EastScore + 1; publicVariable "EastScore";
	}]; 
};
if (side player == East) then {
	_ScoreEH = player addMPEventHandler ["mpkilled", {
		WestScore = WestScore + 1; publicVariable "WestScore";
	}]; 
};
};

[] spawn {
   if (!isDedicated) then {

       waitUntil {!(isNil "GameOver")};

       if ((timeElapsed >= TimeLimit) and (WestScore != Eastscore)) then {
		if (WestScore > Eastscore) then {
			hint "Time is up!\nUS forces win!"; sleep 5; endmission "end1"
		};
		if (Eastscore > WestScore) then {
			hint "Time is up!\nInsurgents win!"; sleep 5; endmission "end1"
		};
	};

       if ((timeElapsed >= TimeLimit) and (WestScore == Eastscore)) then {
		hint "Time is up!\nScore is tied!\nThe match is a draw!"; sleep 5; endmission "end1"
	};

       if (Westscore >= ScoreLimit) then {
		if (side player == West) then {
			hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"
		} else {
			hint "Mission failed!\nThe infidels have taken\nthe town!"; sleep 6; endmission "end1"
		};
	};

       if (Eastscore >= ScoreLimit) then {
		if (side player == East) then {
			hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"
		} else {
			hint "Mission failed!\nInsurgents have taken\nthe town!"; sleep 6; endmission "end1"
		};
	};
   };
};

parameters.sqf:

if (!isServer) exitWith {};

[] spawn {
   timeElapsed = 0;
   missionplaying = True;
waitUntil {time > 0};
   While {missionplaying} do {
       sleep 5;
       timeElapsed = timeElapsed + 5; publicVariable "timeElapsed";
   };
};

waitUntil {!(isNil "timeElapsed")};
waitUntil {(timeElapsed >= TimeLimit) || (Westscore >= ScoreLimit) || (Eastscore >= ScoreLimit)};

GameOver = true; publicVariable "GameOver";
missionplaying = false;

Share this post


Link to post
Share on other sites
OK fixed again :D

[/php]

Thank you and to add another parameter like fog,rain and time of day, which i already have the thing for on another mission, I would just past it to the bottom of the scripts right?

sorry for the late reply was busy doing some stuff then we got a storm that was messing with the power yesterday.

Share this post


Link to post
Share on other sites

Sorry for the bump but i need an answer.

---------- Post added at 02:41 PM ---------- Previous post was at 02:39 PM ----------

Sorry for the double post but i need an answer

Share this post


Link to post
Share on other sites

did you even try pasting into bottom of script?

or are you content on sitting twiddling your tumbs and waiting for someone to say something...

Share this post


Link to post
Share on other sites

whats been posted already in part of description.ext:

class Params {

   class TimeLimit {      
       title = "Time Until Mission Ends (in minutes)";
       values[] = {10800,60,300,600,900,1200,1500,1800};
       texts[] = {"No Limit","1","5","10","15","20","25","30"};
       default = 10800;
   };

   class ScoreLimit {  
       title = "Score needed for Victory";
       values[] = {2,10,20,50,100,150,250,500,1000};
       texts[] = {"2","10","20","50","100","150","250","500","1000"};
       default = 2;
    };

[b][i]    class twiddling_tumbs {  
       title = "here goes another thing or option to use";
       values[] = {1,2,3,4};
       texts[] = {"sitting","trying","experimenting","reading"};
       default = "reading";
    };[/i][/b]
};  

Share this post


Link to post
Share on other sites

Yes I put them int he description.exe but in order to activate them i need to put them in the init or the parameter file BUT I dont know where i can put them in it.

Share this post


Link to post
Share on other sites

how was it done in the mission you took them from? look there and copy the same stuff.

Share this post


Link to post
Share on other sites

The mission I took them from didnt have the stuff i had and the script is is a weird order so I dont know.

switch (paramsArray select 0) do {

case 0: { 0 setOvercast 0; 0 setRain 0; };

case 1: { 0 setOvercast 0.8; 0 setRain 0.3; };

case 2: { 0 setOvercast 0.9; 0 setRain 0.6; };

case 3: { 0 setOvercast 1; 0 setRain 1; };

};

switch (paramsArray select 1) do {

case 0: { 0 setFog 0; };

case 1: { 0 setFog 0.3; };

case 2: { 0 setFog 0.6; };

case 3: { 0 setFog 1; };

};

thats what was put in the init of the other mission.

Share this post


Link to post
Share on other sites

Sorry for the bump but I need an answer to this.

Share this post


Link to post
Share on other sites

Hi,

Add the following to your description.ext;

   class WeatherType {  
       title = "What's the weather like?";
       values[] = {0,1,2,3};
       texts[] = {"Clear","Overcast with slight rain","Cloudy with more rain","English Summer Day"};
       default = 0;
    };
   class FogType {  
       title = "Is it a pea-souper?";
       values[] = {0,1,2,3};
       texts[] = {"Clear","Slightly Misty","London on a good day","Christ, where's my hand gone?"};
       default = 0;
    }; 

Then in your init.sqf add the following;

switch (WeatherType) do {
case 0: { 0 setOvercast 0; 0 setRain 0; };
case 1: { 0 setOvercast 0.8; 0 setRain 0.3; };
case 2: { 0 setOvercast 0.9; 0 setRain 0.6; };
case 3: { 0 setOvercast 1; 0 setRain 1; };
};

switch (FogType) do {
case 0: { 0 setFog 0; };
case 1: { 0 setFog 0.3; };
case 2: { 0 setFog 0.6; };
case 3: { 0 setFog 1; };
};  

it will need to go AFTER

waitUntil {!(isNil "ParamInit")};

Full code below...

description.ext

OnLoadMission = "Hellstrip";
OnLoadIntro = "Survive";// Title that appears on screen in briefing

respawn="BASE";
respawnDelay= 5;
RespawnDialog= 1;
disabledAI=True;
debriefing = True;


class Header {
   gameType = DM;
   minPlayers = 1;
   maxPlayers = 8;
};



class Params {

   class TimeLimit {      
       title = "Time Until Mission Ends (in minutes)";
       values[] = {10800,60,300,600,900,1200,1500,1800};
       texts[] = {"No Limit","1","5","10","15","20","25","30"};
       default = 10800;
   };

   class ScoreLimit {  
       title = "Score needed for Victory";
       values[] = {2,10,20,50,100,150,250,500,1000};
       texts[] = {"2","10","20","50","100","150","250","500","1000"};
       default = 2;
    };
[b]     
   class WeatherType {  
       title = "What's the weather like?";
       values[] = {0,1,2,3};
       texts[] = {"Clear","Overcast with slight rain","Cloudy with more rain","English Summer Day"};
       default = 0;
    };
   class FogType {  
       title = "Is it a pea-souper?";
       values[] = {0,1,2,3};
       texts[] = {"Clear","Slightly Misty","London on a good day","Christ, where's my hand gone?"};
       default = 0;
    };[/b]          
};  

init.sqf

waitUntil {(isDedicated) || !(isNull player)};

if (isNil "paramsArray") then {
   if (isClass (missionConfigFile/"Params")) then {
       for "_i" from 0 to (count (missionConfigFile/"Params") - 1)    do {
           _paramName = configName ((missionConfigFile >> "Params") select _i); _paramValue = getNumber (missionConfigFile >> "Params" >> _paramName >> "default"); call compile format ["%1 = %2", _paramName, _paramValue];
       };
   }; ParamInit = true;
} else {
   for "_i" from 0 to (count paramsArray - 1) do {
       _paramName = configName ((missionConfigFile >> "Params") select _i); _paramValue = paramsArray select _i; call compile format ["%1 = %2", _paramName, _paramValue];
   };    ParamInit = true;
};

if (isNil "EastScore") then { EastScore = 0; };
if (isNil "WestScore") then { WestScore = 0; };

waitUntil {!(isNil "ParamInit")};

execVM "parameters.sqf";
execVM "briefing.sqf";
[b]
switch (WeatherType) do {
case 0: { 0 setOvercast 0; 0 setRain 0; };
case 1: { 0 setOvercast 0.8; 0 setRain 0.3; };
case 2: { 0 setOvercast 0.9; 0 setRain 0.6; };
case 3: { 0 setOvercast 1; 0 setRain 1; };
};

switch (FogType) do {
case 0: { 0 setFog 0; };
case 1: { 0 setFog 0.3; };
case 2: { 0 setFog 0.6; };
case 3: { 0 setFog 1; };
};  
[/b]


[] spawn {
   if (!isDedicated) then {
       waitUntil {!(isNil "BIS_fnc_init")};
       waitUntil {alive player};
       sleep 5;
       ["Grounded", "Survival of the fittest!"] call BIS_fnc_infoText;
       sleep 3;
       ["Map created by", "critblade & cavemans/zach"] call BIS_fnc_infoText;
   };
};

if (!isDedicated) then {
   if (side player == West) then {
       _ScoreEH = player addMPEventHandler ["mpkilled", {
           EastScore = EastScore + 1; publicVariable "EastScore";
       }]; 
   };
   if (side player == East) then {
       _ScoreEH = player addMPEventHandler ["mpkilled", {
           WestScore = WestScore + 1; publicVariable "WestScore";
       }]; 
   };
};

[] spawn {
   if (!isDedicated) then {

       waitUntil {!(isNil "GameOver")};

       if ((timeElapsed >= TimeLimit) and (WestScore != Eastscore)) then {
           if (WestScore > Eastscore) then {
               hint "Time is up!\nUS forces win!"; sleep 5; endmission "end1"
           };
           if (Eastscore > WestScore) then {
               hint "Time is up!\nInsurgents win!"; sleep 5; endmission "end1"
           };
       };

       if ((timeElapsed >= TimeLimit) and (WestScore == Eastscore)) then {
           hint "Time is up!\nScore is tied!\nThe match is a draw!"; sleep 5; endmission "end1"
       };

       if (Westscore >= ScoreLimit) then {
           if (side player == West) then {
               hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"
           } else {
               hint "Mission failed!\nThe infidels have taken\nthe town!"; sleep 6; endmission "end1"
           };
       };

       if (Eastscore >= ScoreLimit) then {
           if (side player == East) then {
               hint "Mission successful!\nOur forces are victorious!\nThe town is ours!"; sleep 6; endmission "end1"
           } else {
               hint "Mission failed!\nInsurgents have taken\nthe town!"; sleep 6; endmission "end1"
           };
       };
   };
};  

I tested this (hosted server only), and it works for me!

Regards

Share this post


Link to post
Share on other sites
Hi,

I tested this (hosted server only), and it works for me!

Regards

Thanks for the help!

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  

×