Jump to content
gangolf

Problem with Public Variable

Recommended Posts

Hi Guys,

 

i've some problems by setting a global variable.

 

Background:

I try to write a small script to prevent that our mission ll be stolen.

 

The Problem is, my init dont find my publicvariable

// Description.ext - Define End6
class CfgDebriefing
{  
	class End6
	{
		title = "Mission stolen";
		subtitle = "";
		description = "this mission is stolen";
		pictureBackground = "";
		picture = "b_inf";
		pictureColor[] = {0.0,0.3,0.6,1};
	};

};
// init.sqf - Check if Server is mine
execvm "verification.sqf";
wait 2;
if (correctserver) then [ { hint"Starting Server" }, { failmission"END6" } ];

// verification.sqf- Set correctserver true
correctserver= true;
publicVariableServer "correctserver";

Share this post


Link to post
Share on other sites

"wait" does not exist in sqf, try sleep in its place, and if that makes any difference.

Share this post


Link to post
Share on other sites

Sorry, on my phone and didn't see your "if" statement syntax is also bad, "if"s follow:

if (_variable) then { do something } else { do something else };

Share this post


Link to post
Share on other sites

publicVariableServer

 

You trying public variable from server to server.

You don't need public server global variable  to check variable on server machine.

Nonsense.

    // init.sqf - Check if Server is mine
    if (isServer)then {
    [] execVM "verification.sqf";
    sleep 2;

    if (correctserver) then {
     systemChat "Starting Mission";
} else {failmission"END6"};
};
Anyway such security lock is nothing. Look for how to binarize your mission.sqm

Share this post


Link to post
Share on other sites

No need to put that data in debriefing, just store server-side code apart from mission, and it will just not launch on other hosts who do not have server-side scripts.

Share this post


Link to post
Share on other sites

Another way to aproach it:

 

init.sqf (clientside):

#define WAIT_TIME 10

waitUntil {time > 0};
_tCheck = time;
waitUntil {!isNil "correctserver" || (_tCheck + WAIT_TIME < time)};
if(isNil "correctserver") exitWith {
	failMission "END6";
};

hint "Starting server.";

You can use waitUntil and sleep in "init.sqf" as it's run in scheduled environment.

 

Anyway, this kind of protection is useless, someone with averege skill knowledge would override that. I'd recomend looking into a "code transfer", meaning:

 

All the important code of the mission, even the placement of some objects could be stored server side (creating an addon, just like AltisLifeRPG), and when the player joins in, this server addon would be called and would upload the data to the client throught a BIS_fnc_MP function. I could give you an example code if you need it really bad.

Share this post


Link to post
Share on other sites

Another way to aproach it:

 

init.sqf (clientside):

#define WAIT_TIME 10

waitUntil {time > 0};
_tCheck = time;
waitUntil {!isNil "correctserver" || (_tCheck + WAIT_TIME < time)};
if(isNil "correctserver") exitWith {
	failMission "END6";
};

hint "Starting server.";
You can use waitUntil and sleep in "init.sqf" as it's run in scheduled environment.

 

Anyway, this kind of protection is useless, someone with averege skill knowledge would override that. I'd recomend looking into a "code transfer", meaning:

 

All the important code of the mission, even the placement of some objects could be stored server side (creating an addon, just like AltisLifeRPG), and when the player joins in, this server addon would be called and would upload the data to the client throught a BIS_fnc_MP function. I could give you an example code if you need it really bad.

BIS_fnc_MP may be considered outdated since engine-native remoteewxeccall had been introduced. also, transfering functions is also could be done via PublicVariable.

Share this post


Link to post
Share on other sites

BIS_fnc_MP may be considered outdated since engine-native remoteewxeccall had been introduced. also, transfering functions is also could be done via PublicVariable.

 

The thing of publicVariable is... That costs much bandwidth. I have pretty bad experience using it. Didn't know about the new function, will look into it.

Share this post


Link to post
Share on other sites

THX All for the help..

 

i just forgot to launch the mod :lol:

 

My Bad

 

Greetings Gangolf

Share this post


Link to post
Share on other sites

Just because I'm interested, what is the deeper purpose of this "mission stolen" ending? What hinders a thief from simply avoiding the respective if statement and using the mission as it is?

Share this post


Link to post
Share on other sites

Hey 

 

sorry didnt saw your answer.

 

other Clans stole our Mission.. they have absolut no experience in scripting.. so this should stop them :D

 

Greetings Gangolf

Share this post


Link to post
Share on other sites

User asks the community to fix script with the express intention of not giving the mission or indeed, the fix, to the community.

  • Like 3

Share this post


Link to post
Share on other sites

I can't think anything worse than someone else playing a mission I've created.

  • Like 3

Share this post


Link to post
Share on other sites

other Clans stole our Mission.. they have absolut no experience in scripting.. so this should stop them :D

 

 

"wait" does not exist in sqf, try sleep in its place, and if that makes any difference.

Uses 'wait' command then derides another clan for having no scripting experience.

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

×