Jump to content
Sign in to follow this  
satory

Player Class?

Recommended Posts

First off I'm probably blind, and its been looking back at me all this time, but I cant see what Im looking for...

My plan is to write a script that will change the teams weapons to silenced ones.

I want to write a case statement that checks a players class/role on the team, so for example

Switch(class/role)
{
"USMC_Soldier_AA": blah blah

"USMC_Soldier_Medic": blah blah
}

I'd like to run the case statement against the names in this thread

I have been using this page here and staring at it for ages but I cant see what I'm looking for, any suggestions?

Share this post


Link to post
Share on other sites

Cheers Ghost, I have that link up in one of my tabs all ready, what I'm looking for is the condition for the case statement?

The code in the OP was just written quickly to try and give people an idea of what I'm looking to do.

I'm at work at the moment so I don't have everything with me, but here is a more syntax proper example

_pUnit = _this select 0;

removeAllWeapons _pUnit;



switch (CONDITION?) do {
case "USMC_Soldier_AA" : {
_pUnit addWeapon "M4A1_AIM_SD_camo"; 
_pUnit addMagazine "30Rnd_556x45_StanagSD";
};
case "USMC_Soldier_Medic" : {
_pUnit addWeapon "M4A1_HWS_GL_SD_Camo"; 
_pUnit addMagazine "30Rnd_556x45_StanagSD";
};
};

Edited by satory

Share this post


Link to post
Share on other sites

not able to check atm but try

_pUnit = _this select 0;

removeAllWeapons _pUnit;

switch (typeof _punit) do {
case USMC_Soldier_AA : {
_pUnit addWeapon "M4A1_AIM_SD_camo"; 
_pUnit addMagazine "30Rnd_556x45_StanagSD";
};
case USMC_Soldier_Medic : {
_pUnit addWeapon "M4A1_HWS_GL_SD_Camo"; 
_pUnit addMagazine "30Rnd_556x45_StanagSD";
};
};

Share this post


Link to post
Share on other sites

Unit classes are strings. -> "USMC_Soldier_AA".

Btw. you will only add one magazine to the soldier. :D

Share this post


Link to post
Share on other sites

Yeah dropping the "" on the player classes in the switch statement didnt do anything.

Just before I do anything else, this is the right code iin the units init?

nul=[this] execVM "ChangeWeapon.sqf"

With ChangeWeapon.sdf being the name of the script? and this being the first argument.

---------- Post added at 12:24 PM ---------- Previous post was at 10:25 AM ----------

Okay, typeof definitely works as I've used it to return a string to the screen.

So somewhere along the line of my unit entering the script it falls apart, since it doesn't actually remove all weapons before entering the switch/case statement.

Share this post


Link to post
Share on other sites

Have a look in the RPT file. Scripting errors are recorded in that file.

Share this post


Link to post
Share on other sites

Ok I'm going to assume that since there is no mention of my script in the RPT file its not actually being run?

Here is my RPT file,

=====================================================================

== E:\Bohemia Interactive\ArmA 2\arma2.exe

== "E:\Bohemia Interactive\ArmA 2\arma2.exe"

=====================================================================

Exe timestamp: 2009/07/01 03:58:29

Current time: 2009/07/12 22:50:26

Error: JoystickDevices - CoInitilizeEx return 80010106

Error: CoInitilizeEx (XAudio2-1st trial) return 80010106

Exe version: 1.02.58134

barracks1 is not soldier nor transport.

No transport

UnExpected call of CreateVehicle for 'Logic', pos(0.000000.2,0.749948.2,0.000000.2). Vehicles with brain cannot be created using 'createVehicle'!

Creating debriefing

If that is so the case, and the script is not being run can some one point me in the right direction?

Here is the players init field:

this moveincargo boat1; nul=[this] execVM "ChangeWeapon.sqf"

note the playable unit starts off in a boat.

And here is a copy of the script, its called ChangeWeapon.sqf

_punit = _this select 0;
_unittype=typeof _punit;



removeAllWeapons _punit;


switch (_unittype) do
{
case "USMC_Soldier_AT":
{
	_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";
};
case "USMC_Soldier_SL":
{
	_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";
};
case "FR_Sapper":
{
	_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";
};
case "USMC_Soldier":
{
	_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";
};
default 
{
	_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";
};
}	

Oh, one question, do scripts have an 8.3 filename limit?

---------- Post added at 11:14 PM ---------- Previous post was at 11:06 PM ----------

Oh, one question, do scripts have an 8.3 filename limit?

:(:(:(

I think this has solved my problem...

Thanks all who helped!!!!

Share this post


Link to post
Share on other sites

Oh, and just a quick advice to however you manage to solve this:

Add one magazine before the weapon, so that it is readily loaded. Otherwise the weapon will have to be reloaded at start :)

Share this post


Link to post
Share on other sites

Yeah cheers, I noticed that while I was testing this out.

Lets just say I died a few times in working out where my ammo had gone, and if I had actually in fact added the correct sort of ammo :rolleyes:

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  

×