Jump to content
Sign in to follow this  
mattxr

Weapons Script

Recommended Posts

WHY Does this script not work on a server. Its for a MP mission.

Quote[/b] ]; ****************************************************************

; Custom unit script for Armed Assault

; Created with ArmA Edit - Version 1.1.3000

; HELP: Run this script from the INITIALIZATION box of the unit.

; CODE: [this] exec "Loadouts\LRDLO.sqs"

; ****************************************************************

; Get the unit parameter given

_unit = _this select 0

; Strip the units current gear

removeAllWeapons _unit

; Add the new gear to the unit

_unit addMagazine "30Rnd_556x45_Stanag"

_unit addMagazine "30Rnd_556x45_Stanag"

_unit addMagazine "30Rnd_556x45_Stanag"

_unit addMagazine "30Rnd_556x45_Stanag"

_unit addMagazine "30Rnd_556x45_Stanag"

_unit addMagazine "30Rnd_556x45_Stanag"

_unit addMagazine "30Rnd_556x45_Stanag"

_unit addMagazine "30Rnd_556x45_Stanag"

_unit addWeapon "M16A4"

_unit selectWeapon "M16A4"

_unit addMagazine "15Rnd_9x19_M9"

_unit addMagazine "15Rnd_9x19_M9"

_unit addMagazine "15Rnd_9x19_M9"

_unit addMagazine "15Rnd_9x19_M9"

_unit addMagazine "15Rnd_9x19_M9"

_unit addMagazine "15Rnd_9x19_M9"

_unit addMagazine "15Rnd_9x19_M9"

_unit addMagazine "15Rnd_9x19_M9"

_unit addWeapon "M9"

_unit addMagazine "HandGrenadeTimed"

_unit addMagazine "HandGrenadeTimed"

_unit addMagazine "SmokeShellGreen"

_unit addMagazine "SmokeShellRed"

_unit addWeapon "Binocular"

_unit addWeapon "NVGoggles"

Exit

Works Flawlessly in my MP Mission Editor but when i add it to the server the guy just starts with his usual weapons. and not the ones the script gives.

Share this post


Link to post
Share on other sites

Where and How exactly do you call the script?

Share this post


Link to post
Share on other sites
Quote[/b] ]; HELP: Run this script from the INITIALIZATION box of the unit.

; CODE: [this] exec "Loadouts\LRDLO.sqs"

I dunno, but me thinks that the "remote player" isn't there when the init of the unit is run.

I'd put that into the init.sqx file instead.

like

[player] exec "Loadouts\LRDLO.sqs"

Share this post


Link to post
Share on other sites
Quote[/b] ]; HELP: Run this script from the INITIALIZATION box of the unit.

; CODE: [this] exec "Loadouts\LRDLO.sqs"

I dunno, but me thinks that the "remote player" isn't there when the init of the unit is run.

No, I don't think so. Actually I'm pretty sure this works fine.

Share this post


Link to post
Share on other sites
No, I don't think so. Actually I'm pretty sure this works fine.

K, I haven't got any player related stuff executed from the init of any unit when playing MP. confused_o.gif

Share this post


Link to post
Share on other sites

I had in some of my missions and if I don't remember it totally wrong it always worked fine. That's why I was asking how he calls the script. If he really does the way which is described in the comments I can't explain this phenoma either.

Share this post


Link to post
Share on other sites

i run this command in the players init.

Quote[/b] ][this] exec "Loadouts\LRDLO.sqs"

Share this post


Link to post
Share on other sites

Just tried, it seems [this] doesn't work properly, as far as my experience go [player] works better.

Share this post


Link to post
Share on other sites
Just tried, it seems [this] doesn't work properly, as far as my experience go [player] works better.

Just tested it doesnt even work at all smile_o.gif

Share this post


Link to post
Share on other sites

try this

I have used some parts of this code in an other script of mine.

Quote[/b] ]

RemoveAllWeapons _this;

RemoveMagazines _this;

hint "rearming!"

~0.5

_this addWeapon "M4SPR";

{_this addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3,4];

_this addMagazine "PipeBomb"

hint "script ok !"

exit;

modify accordingly depending the weapons of your choice.

60.jpg

Share this post


Link to post
Share on other sites

My gues would lay around the loadouts dir. have you tryed running the script in the main folder instead of a sub folder, if that aint it my next gues would be with removeallweapons.

Share this post


Link to post
Share on other sites

try placing these commands at the very end of your init.sqs or init.sqf...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

processInitCommands;

finishMissionInit;

Share this post


Link to post
Share on other sites

why its not part of the init. its a seporite init.sqs script. sad_o.gif

Share this post


Link to post
Share on other sites

processInitCommands; won't do much for your situ... but is good practice to have it sitting at the end of your initialization scripting for your mission.

I was always (rightly or wrongly) under the impression 'finishMissionInit;' forced the engine to 'complete' the initialization of ALL 'world' objects and this included for example 'characters' such as playable & non-playable infantry units.

Which in your case would mean that prior to you being able to move around in your mission the characters init field would be processed.

dunno... personally have never had any issues with getting init fields to do what they have to... so my point is it's got to be an implementation issue and not a bug.

also, you don't 'need' to pass 'this' in an array to your script and have the script pull the param out with a '_this select 0'... you can just do 'this exec myscript.sqs' in your init field...

Share this post


Link to post
Share on other sites

I had same problem with creating crates in mfcti. After crates were created I ran a similar script that worked in SP but not in MP. I resorted to putting the pre made crates into an addon. Thougt it was just a MFCTI error.

Share this post


Link to post
Share on other sites

WTF BIS WTF HAVE YOU DONE.. I add this into the players init.

Quote[/b] ]removeAllWeapons Player;Player addMagazine "30Rnd_556x45_Stanag";Player addMagazine "30Rnd_556x45_Stanag";Player addMagazine "30Rnd_556x45_Stanag";Player addMagazine "30Rnd_556x45_Stanag";Player addMagazine "30Rnd_556x45_Stanag";Player addMagazine "30Rnd_556x45_Stanag";Player addMagazine "30Rnd_556x45_Stanag";Player addMagazine "30Rnd_556x45_Stanag";Player addWeapon "M16A4";Player selectWeapon "M16A4";Player addMagazine "15Rnd_9x19_M9";Player addMagazine "15Rnd_9x19_M9";Player addMagazine "15Rnd_9x19_M9";Player addMagazine "15Rnd_9x19_M9";Player addMagazine "15Rnd_9x19_M9";Player addMagazine "15Rnd_9x19_M9";Player addMagazine "15Rnd_9x19_M9";Player addMagazine "15Rnd_9x19_M9";Player addWeapon "M9";Player addMagazine "HandGrenadeTimed";Player addMagazine "HandGrenadeTimed";Player addMagazine "SmokeShellGreen";Player addMagazine "SmokeShellRed";Player addWeapon "Binocular";Player addWeapon "NVGoggles";

and he still just spawns with a M9

JKBUHGY%%^$^&^&£$%EIg WWWTTTFFF !!!! banghead.gif

Share this post


Link to post
Share on other sites

ahhh... hold it... are you trying to get 'respawned' units init lines to run?

'cause you can't - init field values as displayed and entered in the editor do not get run on 'respawned' units of any type.

if you're trying to alter the properties of a 'respawned' unit you have to have a 'script thread' waiting for that units 'aliveness' - once they/it is 'alive' then you can do stuff to it... ie. alter it's loadout.

Share this post


Link to post
Share on other sites

maybe something like this

@ (_unit == player)

@ (Alive player)

? (_side == west):[_unit] Exec "Loadouts\EquipWestSoldierLoadout.sqs"

? (_side == east):[_unit] Exec "Loadouts\EquipEastSoldierLoadout.sqs"

Share this post


Link to post
Share on other sites

Nope i just wanted the players when they started the mission to have thoose weapons but i guess ill just leave them without.

Share this post


Link to post
Share on other sites

Try this, tested and worked on dedicated.

.sqs

Quote[/b] ]

if (local player and player == unitname) then {removeallweapons unitname; unitname addmagazine "30Rnd_556x45_Stanag"; unitname addweapon "M16A4"; unitname SelectWeapon "M16A4"}

Share this post


Link to post
Share on other sites

ahh... ok... then in your init field you posted above... substitue 'player' with the word 'this'....

eg.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

removeAllWeapons this;this addMagazine "30Rnd_556x45_Stanag";this addMagazine "30Rnd_556x45_Stanag";this addMagazine "30Rnd_556x45_Stanag";this addMagazine "30Rnd_556x45_Stanag";this addMagazine "30Rnd_556x45_Stanag";this addMagazine "30Rnd_556x45_Stanag";this addMagazine "30Rnd_556x45_Stanag";this addMagazine "30Rnd_556x45_Stanag";this addWeapon "M16A4";this selectWeapon "M16A4";this addMagazine "15Rnd_9x19_M9";this addMagazine "15Rnd_9x19_M9";this addMagazine "15Rnd_9x19_M9";this addMagazine "15Rnd_9x19_M9";this addMagazine "15Rnd_9x19_M9";this addMagazine "15Rnd_9x19_M9";this addMagazine "15Rnd_9x19_M9";this addMagazine "15Rnd_9x19_M9";this addWeapon "M9";this addMagazine "HandGrenadeTimed";this addMagazine "HandGrenadeTimed";this addMagazine "SmokeShellGreen";this addMagazine "SmokeShellRed";this addWeapon "Binocular";this addWeapon "NVGoggles";

thats of course if that excerpt you posted is from the init field in the editor...

Share this post


Link to post
Share on other sites

Doing it in the init field will do it once initially when the player starts/joins the map. So you can have it there if you want it to only occur once. (this addweapon ""; etc etc)

Or you can have it in the init field (so the initial weapon change occurs) and in something that fires when the players alive to work with the respawning of the player, like: cond: alive player.

(if then statements)

Just to be clear. When a player respawns they keep their editor unitname. So thats not a problem. So you can have multiple if then statements in the one script catering for different units in the same script working off a single trigger.

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  

×