Jump to content
Sign in to follow this  
NeV3rKilL

Script works on localserver but internet.

Recommended Posts

I have create a little script which I launch the script with:

_an = [this,"godall","ha"] execVM "car.sqf";

Putted in vehicles init. It works perfect if I create a localserver or preview in my editor but I have upload a test mission with this in a internet server and the script not works.

Why??

Thank you.

The mission is: http://www.megaupload.com/?d=AMT8RL3W

Share this post


Link to post
Share on other sites

Surprisingly, allowDamage needs to be run on all clients, not just the server and not just the machine where the unit is local. This kinda complicates any script that uses it. You will have to replace each allowDamage useage with setting a variable to true of false and then using publicVariable on it, and then have a separate script that runs on all machines with an infinite loop that waits for the variable to become true to do the allowDamage true and then wait until it becomes false to do the allowDamage false. Of course you'd need a variable+running script for each vehicle for each client as well as the server.

Also it makes it easier if you just post the script within code tags rather than upload the whole mission.

Share this post


Link to post
Share on other sites

This is the whole script.

if (!isServer) exitWith {};
private ["_car","_godmode","_damBol"];

_car = _this select 0;
_godmode = _this select 1;
_damBol = _this select 2;

switch (_godmode) do
{
   case "godall":
   {
       if  (0 != (count crew _car)) then 
	{
		{_x allowDamage false} foreach crew _car;
	};

	_car addEventHandler ["GetIn", {(_this select 2) allowDamage false;}];
	_car addEventHandler ["GetOut", {(_this select 2) allowDamage true;}];

   };
case "godcargo":
   {
       if  (0 != (count crew _car)) then 
	{
		{_x allowDamage false} foreach crew _car;
		(gunner _car) allowDamage true;
		(driver _car) allowDamage true;
		(commander _car) allowDamage true;
	};

	_car addEventHandler ["GetIn", {(_this select 2) allowDamage false;(gunner _car) allowDamage true;(commander _car) allowDamage true;(driver _car) allowDamage true;  }];
	_car addEventHandler ["GetOut", {(_this select 2) allowDamage true;}];

   };
case "godallheli":
   {
       if  (0 != (count crew _car)) then 
	{
		{_x allowDamage false} foreach crew _car;
	};

	_genAct = _car addAction ["Saltar al Vehiculo!", "getin.sqf", _this ,10 , true , true , "GetOut", "!(_this in _target)"];

	_car addEventHandler ["GetIn", {(_this select 2) allowDamage false;}];
	_car addEventHandler ["GetOut", {_this Call Compile PreProcessFile "DMG_Godalleli.sqf";}];

   };
};

switch (_damBol) do
{
   case "ha":
   {
       _car AddEventHandler ["handleDamage",{_this Call Compile PreProcessFile "DMG_Armour.sqf";}];

   };

   case "tercio":
   {
       _car addEventHandler ["handleDamage", {  _this Call Compile PreProcessFile "DMG_Tercio.sqf" }];
   };

};

How can i do to run code in every machine?

hint dosen't work on the internet machines :( Why? This is by allowdamage?

Edited by NeV3rKilL

Share this post


Link to post
Share on other sites

if (!isServer) exitWith {};

This line makes you not execute the script if you are not the server. Init lines are executed by everyone (but not sure about JIP players), which is why this line is used at the start of server-only scripts.

I'm assuming addAction also has similar issues to allowDamage, but I don't really know.

Share this post


Link to post
Share on other sites

if (!isServer) exitWith {};

All was that line. I don't understand why, but i have commented that line and all works perfect now.

Some good document explaining difference between exec in server or in clients??

Thank you very much.

Share this post


Link to post
Share on other sites

This line tells the script to exit if the machine that is running it is not the server. It is that simple.

When it comes to who runs which scripts:

init.sqf runs for everyone, as well as vehicle init lines (except I'm not sure about how they work for JIP players).

Triggers are created separately for each machine, and each machine will activate it when its condition is met and execute the "on act" field. A machine where the trigger had been deleted (or not created in the firstplace) will not execute it. Not sure about waypoints I think it's similar.

Just remember that each machine runs scripts separately, and sometimes you want a script to run for everyone, and sometimes you want just a specific machine (ex: only the server, or only the machine where a unit is local) to execute the script. It all depends on which commands you want the script to execute.

Edited by galzohar

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  

×