Jump to content
Sign in to follow this  
satory

How do you make a script MPable?

Recommended Posts

Hey everyone, I have a script which I made, with help from a previous thread on this board. But I have a problem with it its grand when I preview a mission, but once I upload the mission onto a server it doesn't work at all.

The script is called on every playable characters init box like so,

nul=[this] execVM "ChangeW.sqf"

And the script itself is:

_punit = _this select 0;
_unittype=typeof _punit;



removeAllWeapons _punit;
_punit addWeapon "Binocular";
_punit addWeapon "NVGoggles";



switch (_unittype) do
{
case "USMC_Soldier_AT":
{
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addWeapon "M4A1_AIM_SD_camo"; 
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addWeapon "M9SD"; 
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "SMAW_HEAA";		
	_punit addWeapon "SMAW"; 
	_punit addMagazine "SMAW_HEAA";
	_punit addMagazine "SMAW_HEDP";
	_punit addMagazine "HandGrenade";
	_punit addMagazine "HandGrenade";

};
case "USMC_Soldier_SL":
{
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addWeapon "M4A1_AIM_SD_camo"; 
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addWeapon "M9SD"; 
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "SmokeShell";
	_punit addMagazine "SmokeShell";
	_punit addMagazine "SmokeShellGreen";
	_punit addMagazine "SmokeShellRed";


};
case "FR_Sapper":
{
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addWeapon "M4A1_AIM_SD_camo"; 
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addWeapon "M9SD"; 
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "Pipebomb";
	_punit addMagazine "Pipebomb";
	_punit addMagazine "Pipebomb";
};
case "USMC_Soldier":
{
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addWeapon "M4A1_AIM_SD_camo"; 
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addWeapon "M9SD"; 
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "HandGrenade";
	_punit addMagazine "HandGrenade";
};
default 
{
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addWeapon "M4A1_AIM_SD_camo"; 
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "30Rnd_556x45_StanagSD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addWeapon "M9SD"; 
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "15Rnd_9x19_M9SD";
	_punit addMagazine "HandGrenade";
	_punit addMagazine "HandGrenade";

};
}	




What do I need to change to make it work for MP?

Share this post


Link to post
Share on other sites

I would perform an locality-check, but aside from that it should work.

_punit = _this select 0; 
_unittype=typeof _punit; 

if (local _punit) then {

removeAllWeapons _punit; 
_punit addWeapon "Binocular"; 
_punit addWeapon "NVGoggles"; 

switch (_unittype) do 
{ 
	case "USMC_Soldier_AT": 
	{ 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addWeapon "M4A1_AIM_SD_camo";
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addWeapon "M9SD";
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "SMAW_HEAA"; 
		_punit addWeapon "SMAW";
		_punit addMagazine "SMAW_HEAA"; 
		_punit addMagazine "SMAW_HEDP"; 
		_punit addMagazine "HandGrenade"; 
		_punit addMagazine "HandGrenade"; 		
	}; 
	case "USMC_Soldier_SL": 
	{ 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addWeapon "M4A1_AIM_SD_camo";
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addWeapon "M9SD";
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "SmokeShell"; 
		_punit addMagazine "SmokeShell"; 
		_punit addMagazine "SmokeShellGreen"; 
		_punit addMagazine "SmokeShellRed"; 		
	}; 
	case "FR_Sapper": 
	{ 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addWeapon "M4A1_AIM_SD_camo";
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addWeapon "M9SD";
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "Pipebomb"; 
		_punit addMagazine "Pipebomb"; 
		_punit addMagazine "Pipebomb"; 
	}; 
	case "USMC_Soldier": 
	{ 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addWeapon "M4A1_AIM_SD_camo";
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addWeapon "M9SD";
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "HandGrenade"; 
		_punit addMagazine "HandGrenade"; 
	}; 
	default
	{ 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addWeapon "M4A1_AIM_SD_camo";
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "30Rnd_556x45_StanagSD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addWeapon "M9SD";
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "15Rnd_9x19_M9SD"; 
		_punit addMagazine "HandGrenade"; 
		_punit addMagazine "HandGrenade"; 
	}; 
}
};

oh btw, where did you put the scriptfile ?

Share this post


Link to post
Share on other sites

I usually put the script file in the Twin_Towns.Utes folder. I only have 2 scripts running, this and the UPS one I found on armaholic?

I'll add this now and try and upload it to a server.

---------- Post added at 08:14 PM ---------- Previous post was at 07:53 PM ----------

No it didn't seem to work, just tried it there and I start off with the default weapons.

Share this post


Link to post
Share on other sites

If it works the same was as it did in ArmA 1, you may need to unPBO the new multiplayer mission folder and drop the scripts into that, then re-pbo it back up. Unless that's what your already doing, then I dunno.

Share this post


Link to post
Share on other sites

how do you mean?

Surely if I extract it as a multiplayer map, the script should be put in the pbo?

I'll have a look at the rpt file in the morning and see if that shows any problems

Share this post


Link to post
Share on other sites

I'm not completely sure how it works, but I remember back in ArmA 1 when you saved from the editor as export to MP game, it didn't take the scripts with it, always had to use cPBO or soemthing to extract the PBO, put the scripts into the mission folder, then re-PBO it back up. Just a thought, might be fixed in ArmA2, haven't checked it out yet.

Share this post


Link to post
Share on other sites

The script should be in the same folder as your mission you made.

Then when you save it in the editor with the export to Multi-Player, its packs all the contents of the mission folder, scripts and all into a pbo file so it will work in multi-player. If you have not done this, then no other user joining your server will have the files for that mission!

Share this post


Link to post
Share on other sites
when you saved from the editor as export to MP game, it didn't take the scripts with it

Never had problems like that in ArmA1/2 atleast not as far as I remember.

Share this post


Link to post
Share on other sites

all the scripts that are inside the mission folder at the moment that you save the mission, will copy the whole folder with scripts and everything, so this cant be possible unless you have done something else inside the folder

Share this post


Link to post
Share on other sites

You might find that the script is activating before the unit is created - try delaying the script for a few secs..

Share this post


Link to post
Share on other sites

so would a "sleep 1" command be better than something like this

"waituntil (alive _this select 0)"

encompassing the existing code?

Share this post


Link to post
Share on other sites

waituntil (alive _this select 0)

That should be the better, more reliable solution.

Share this post


Link to post
Share on other sites
so would a "sleep 1" command be better than something like this

"waituntil (alive _this select 0)"

encompassing the existing code?

you can try that yes - if that doesnt work try calling the script from a trigger or even the Init.sqf - for some reason doing loadouts and calling it in the units init does for some reason misfire..

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  

×