Jump to content

Sign in to follow this  
BaronVonRed

How-to question

Recommended Posts

Hello all -

Does anyone know how to make the units reload their weapons once they have spawned in? I have them respawning with a custom layout, but the players have to hit the space bar twice then reload and many of them are complaining about this because they forget and get killed because of it.

Any help would be highly appreciated!

Share this post


Link to post
Share on other sites

removeallweapons player

player addmagazine "G36Amag"

player addmagazine "G36Amag"

player addmagazine "G36Amag"

player addmagazine "G36Amag"

player addweapon "G36A"

player addmagazine "LAWLauncher"

player addmagazine "LAWLauncher"

player addmagazine "LAWLauncher"

player addweapon "LawLauncher"

player selectweapon "G36A"

maybe "player" needs to be replace by a unitname, I dunno, but I think this script should work pretty well....

The trick to make the weapons already reloadedd is to just add one of the magazines or more before U add the weapon, to make it possible to fire the weapon without using space U use unitName selectweapon WeaponName with "" around teh weaponName.

Share this post


Link to post
Share on other sites

Sounds reasonable and pretty straight forward: thank you! I will try it this eve....

Share this post


Link to post
Share on other sites

Here's some script I wrote.  It works with AI too.  You need these two files...

weapons.sqs

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">

;Reload a soldier when they respawn

;by Doolittle

_obj = _this select 0

_type = _this select 1

goto _type

#Soldier

_mag = ["M16", "M16", "M16", "M16", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]

_weapon = ["M16"]

goto "exit"

#SoldierE

_mag = ["AK74", "AK74", "AK74", "AK74", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]

_weapon = ["AK74"]

goto "exit"

#G36

_mag = ["G36aMag", "G36aMag", "G36aMag", "G36aMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]

_weapon = ["G36a"]

goto "exit"

#Steyr

_mag = ["SteyrMag", "SteyrMag", "SteyrMag", "SteyrMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]

_weapon = ["Steyr"]

goto "exit"

#XMS

_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]

_weapon = ["XMS", "NVGoggles"]

goto "exit"

#AA

_mag = ["M16", "M16", "M16", "M16", "AALauncher"]

_weapon = ["M16", "AALauncher"]

goto "exit"

#EAA

_mag = ["AK74", "AK74", "AK74", "AK74", "9K32Launcher"]

_weapon = ["AK74", "9K32Launcher"]

goto "exit"

#AT

_mag = ["M16", "M16", "M16", "M16", "CarlGustavLauncher"]

_weapon = ["M16", "CarlGustavLauncher"]

goto "exit"

#EAT

_mag = ["AK74", "AK74", "AK74", "AK74", "AT4Launcher"]

_weapon = ["AK74", "AT4Launcher"]

goto "exit"

#SaboteurXMS

_mag = ["M4", "M4", "M4", "M4", "PipeBomb", "PipeBomb", "PipeBomb"]

_weapon = ["XMS", "Binocular"]

goto "exit"

#SaboteurHG

_mag = ["UZIMag", "UZIMag", "UZIMag", "UZIMag", "PipeBomb", "PipeBomb", "PipeBomb", "GlockMag", "GlockMag", "GlockMag", "GlockMag"]

_weapon = ["UZI", "NVGoggles", "Glock"]

goto "exit"

#SaboteurS

_mag = ["HK", "HK", "HK", "HK", "PipeBomb", "PipeBomb", "PipeBomb", "GlockSMag", "GlockSMag", "GlockSMag", "GlockSMag"]

_weapon = ["HK", "NVGoggles", "GlockS"]

goto "exit"

#ESaboteurBizon

_mag = ["BizonMag", "BizonMag", "BizonMag", "BizonMag", "PipeBomb", "PipeBomb", "PipeBomb"]

_weapon = ["Bizon", "NVGoggles"]

goto "exit"

#ESaboteurHG

_mag = ["AK74", "AK74", "AK74", "AK74", "PipeBomb", "PipeBomb", "PipeBomb", "SkorpionMag", "SkorpionMag", "SkorpionMag", "SkorpionMag"]

_weapon = ["AK74SU", "NVGoggles", "Skorpion"]

goto "exit"

#Crew

_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]

_weapon = ["M4", "NVGoggles"]

goto "exit"

#ECrew

#EPilot

_mag = ["AK74", "AK74", "AK74", "AK74", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]

_weapon = ["AK74SU", "NVGoggles"]

goto "exit"

#PilotHG

_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "RevolverMag", "RevolverMag", "RevolverMag", "RevolverMag"]

_weapon = ["M4", "NVGoggles", "Revolver"]

goto "exit"

#G

_mag = ["M16", "M16", "M16", "M16", "GrenadeLauncher", "GrenadeLauncher", "GrenadeLauncher"]

_weapon = ["M16GrenadeLauncher"]

goto "exit"

#EG

_mag = ["AK74", "AK74", "AK74", "AK74", "GrenadeLauncher", "GrenadeLauncher", "GrenadeLauncher"]

_weapon = ["AK74GrenadeLauncher"]

goto "exit"

#HeavyG

_mag = ["MM1Magazine", "SmokeShell", "SmokeShell"]

_weapon = ["MM1", "Binocular"]

goto "exit"

#EHeavyG

_mag = ["6G30Magazine", "6G30Magazine", "SmokeShell", "SmokeShell"]

_weapon = ["6G30", "Binocular"]

goto "exit"

#LAW

_mag = ["M16", "M16", "M16", "M16", "LAWLauncher", "LAWLauncher", "LAWLauncher"]

_weapon = ["M16", "LAWLauncher"]

goto "exit"

#ELAW

_mag = ["AK74", "AK74", "AK74", "AK74", "RPGLauncher", "RPGLauncher", "RPGLauncher"]

_weapon = ["AK74", "RPGLauncher"]

goto "exit"

#OfficerHG

_mag = ["M16", "M16", "M16", "M16", "BerettaMag", "BerettaMag", "BerettaMag", "BerettaMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "SmokeShell", "SmokeShell"]

_weapon = ["M16", "Binocular", "Beretta"]

goto "exit"

#OfficerEHG

_mag = ["AK74", "AK74", "AK74", "AK74", "TokarevMag", "TokarevMag", "TokarevMag", "TokarevMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "SmokeShell", "SmokeShell"]

_weapon = ["AK74", "Binocular", "Tokarev"]

goto "exit"

#Sniper

_mag = ["M21", "M21", "M21", "M21"]

_weapon = ["M21"]

goto "exit"

#ESniper

_mag = ["SVDDragunov", "SVDDragunov", "SVDDragunov", "SVDDragunov"]

_weapon = ["SVDDragunov"]

goto "exit"

#MG

_mag = ["M60", "M60", "M60", "M60", "M60"]

_weapon = ["M60"]

goto "exit"

#EMG

_mag = ["PK", "PK", "PK", "PK", "PK"]

_weapon = ["PK"]

goto "exit"

#Medic

_mag = ["M16", "M16", "M16", "M16"]

_weapon = ["M16"]

goto "exit"

#EMedic

_mag = ["AK74", "AK74", "AK74", "AK74"]

_weapon = ["AK74"]

goto "exit"

#Mortar

_mag = ["M16", "M16", "M16", "M16", "Mortar", "Mortar", "Mortar"]

_weapon = ["M16"]

goto "exit"

#exit

removeAllWeapons _obj

"_obj addMagazine _x" forEach _mag

"_obj addWeapon _x" forEach _weapon

_obj selectWeapon (_weapon select 0)

exit

<span id='postcolor'>

serverloop.sqs

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">

;Check to see when the soldier dies

;by Doolittle

;_obj = [uSA1, USA2, RUS1]

;_obj must be after #Beginning

_type = ["OfficerHG", "XMS", "SoldierE"]

;This would mean USA1 is an OfficerHG, USA2 is an XMS dude, and RUS1 is a SoldierE

;Make up your own loadout for peeps and make up whatever name you want in the weapons.sqs file

_count = count _type

;_alive must be same length as _type and _obj and make it all zeros

_alive = [0, 0, 0]

#Beginning

_i = 0

;This MUST be here inside the loop

_obj = [uSA1, USA2, RUS1]

~1

#Next

~0.01

_o = _obj select _i

? not alive _o : _alive set [_i, 0]

? _alive select _i == 0 and alive _o : [_o, _type select _i] exec "weapons.sqs"; _alive set [_i, 1]

_i = _i + 1

? _i == _count : goto "Beginning"

goto "Next"

<span id='postcolor'>

Then make a Game Logic object and in its Initialization put [] exec "serverloop.sqs".  Now, for the soldiers you want to get weapons on respawn, name them (like USA1, USA2, RUS1, etc.).  Then edit serverloop.sqs and make the _obj, _type, and _alive what you want according to the soldiers' names and what type weapon configuration you want them to have.

Enjoy! biggrin.gif

Doolittle

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (InqWiper @ Nov. 05 2002,20:05)</td></tr><tr><td id="QUOTE">removeallweapons player

player addmagazine "G36Amag"

player addmagazine "G36Amag"

player addmagazine "G36Amag"

player addmagazine "G36Amag"

player addweapon "G36A"

player addmagazine "LAWLauncher"

player addmagazine "LAWLauncher"

player addmagazine "LAWLauncher"

player addweapon "LawLauncher"

player selectweapon "G36A"

maybe "player" needs to be replace by a unitname, I dunno, but I think this script should work pretty well....

The trick to make the weapons already reloadedd is to just add one of the magazines or more before U add the weapon, to make it possible to fire the weapon without using space U use unitName selectweapon WeaponName with "" around teh weaponName.<span id='postcolor'>

That actually worked beautifully! They respawn in with the weapon selected and don't have to hit the space bar anymore. Is there any way to get them to reload?

Doolittle: thank you for that script. I have not used scripts before, but I think I see how this one works and this looks like a good opportunity for me. I will try it out, thanks you!

Share this post


Link to post
Share on other sites

I edited and updated my post up above.  Please take note.  It is now really easy to use.

EDIT: DOH I just tried it in multiplayer and it doesn't work!!! I mean the loop is run on all peeps machines. MAN THIS SCRIPTING STUFF IS HARD/FRUSTRATING!!

Doolittle

Share this post


Link to post
Share on other sites

I read in another thread where it was possible to make something run only on the serving machine. Maybe that would fix it?

Share this post


Link to post
Share on other sites

add a Game Logic Unit name it Server

at the top of your script Have

?!(local Server): exit

that will make the script only run on host PC or Server smile.gif

Share this post


Link to post
Share on other sites

If i was doing a respawn like that I would probably do this

Create a Unit. say a Law Guy

and in the init feild do this

[this] exec "wLAW.sqs"

wLAW.sqs

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

?!(local _unit): exit

#Start

@(alive _unit)

removeAllWeapons _unit

_unit addMagazine "LAWLauncher"

_unit addMagazine "LAWLauncher"

_unit addMagazine "LAWLauncher"

_unit addMagazeine "M16"

_unit addMagazeine "M16"

_unit addMagazeine "M16"

_unit addMagazeine "M16"

_unit addWeapon "M16"

_unit addWeapon "LAWLauncher"

_unit selectWeapon "M16"

@(not alive _unit)

goto "Start"

<span id='postcolor'>

This will make the script only run on that units PC would need a script for every different type of unit in the game but what the hey. this way is simple.

Share this post


Link to post
Share on other sites

I LIKE simple, heh, heh. Thanks, I will try it. What does the '@' symbol mean? Also, you said (not alive _unit) - is this different from !(alive _unit)

I'm a real script dummy!

Is there any way to get the gun to reload automatically so the players don't have to?

Share this post


Link to post
Share on other sites

adding the magazines before the weapons that should reload a mag

the @ symbol means wait for a condition

so in simple terms:

wait until _unit is alive

wait untill unit is not alive

Hmm i dont think there is a difference between ! and not alive

But like i said. it's simple smile.gif and to save confusion i just use not alive smile.gif

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">If i was doing a respawn like that I would probably do this

Create a Unit. say a Law Guy

and in the init feild do this

[this] exec "wLAW.sqs"

wLAW.sqs

Code Sample  

_unit = _this select 0

?!(local _unit): exit

#Start

@(alive _unit)

removeAllWeapons _unit

_unit addMagazine "LAWLauncher"

_unit addMagazine "LAWLauncher"

_unit addMagazine "LAWLauncher"

_unit addMagazeine "M16"

_unit addMagazeine "M16"

_unit addMagazeine "M16"

_unit addMagazeine "M16"

_unit addWeapon "M16"

_unit addWeapon "LAWLauncher"

_unit selectWeapon "M16"

@(not alive _unit)

goto "Start"

This will make the script only run on that units PC would need a script for every different type of unit in the game but what the hey. this way is simple.

<span id='postcolor'>

I don't believe this will work as you have "_unit".

When you die a new object is created and assigned the unit's Name.  This way they can leave a body behind.  However upon becoming alive, a player is now controlling a new object with the old name, therefore the only way to track/work on someone in multiplayer is to reference them via the Name alone.

Doolittle

Share this post


Link to post
Share on other sites

Objects name eg: aP

Objects Init feild:

[this] exec "wLAW.sqs"

Script:

_unit = _this select 0

so now _unit = the units name

_unit = aP

Dig ?

Share this post


Link to post
Share on other sites

Hope this hasn't been beat to death already but I got Doolittles script to work although I'm not sure if respawned guys are reloading on their own yet. They do say ammo low but they do have their weapons and ammo and I think they might be reloading but the game is announcing ammo low before they do actually reload. I figure when they have to fire they will reload if they haven't already.

***weapons.sqs***

_obj = _this select 0

_type = _this select 1

goto _type

#G

_mag = ["M16", "M16", "M16", "M16", "GrenadeLauncher",

"GrenadeLauncher", "GrenadeLauncher"]

_weapon = ["M16GrenadeLauncher"]

goto "exit"

#LAW

_mag = ["M16", "M16", "M16", "M16", "LAWLauncher",

"LAWLauncher", "LAWLauncher"]

_weapon = ["M16", "LAWLauncher"]

goto "exit"

#MG

_mag = ["M60", "M60", "M60", "M60", "M60"]

_weapon = ["M60"]

goto "exit"

#Officer

_mag = ["M21", "M21", "M21", "M21", "LAWLauncher",

"LAWLauncher", "LAWLauncher"]

_weapon = ["M21", "LAWLauncher","Binocular"]

#exit

removeAllWeapons _obj

"_obj addMagazine _x" forEach _mag

"_obj addWeapon _x" forEach _weapon

_obj selectMagazine (_Magazine select 0)

_obj selectWeapon (_Weapon Select 0)

exit

***serverloop.sqs***

#Beginning

_i = 0

_count = count _type

_type = ["Officer", "G", "LAW", "MG", "G", "MG", "LAW",

"MG", "G"]

_obj = [s1, s2, s3, s4, s5, s6, s7, s8, s9]

_alive = [0, 0, 0, 0, 0, 0, 0, 0, 0]

~1

#Next

~0.01

_o = _obj select _i

? not alive _o : _alive set [_i, 0]

? _alive select _i == 0 and alive _o : [_o, _type select

_i] exec "weapons.sqs"; _alive set [_i, 1]

_i = _i + 1

? _i == _count : goto "Beginning"

goto "Next"

And I did use Doolittle's Game Logic instruction.

Doolittle, thank you very much for your time and information. biggrin.gifbiggrin.gifbiggrin.gif

Share this post


Link to post
Share on other sites

Yeah my scripts are old & outdated. But glad you took the time to understand them. smile.gif

Doolittle

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  

×