After some inspiration, and a load of help from PsyWarrior, I've completed my first script that is useful!
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Random Loadouts.... Originally by PsyWarrior
;Edited by Homefry
;To Use: [unitname] exec "randomweapons.sqs"
_man = _this select 0
;Weapons are removed:
removeAllWeapons _man
;Determine what side the unit is on
?side _man == west : goto "westweapons"
?side _man == east : goto "eastweapons"
?side _man == resistance : goto "resistanceweapons"
?side _man == civilian : goto "civilianweapons"
#westweapons
_primaryArray = ["m16", "M60", "M4", "G36A", "FAL", "Steyr", "HKG3"]
_BulletArray = ["m16", "M60", "M4", "G36AMag", "FALMag", "SteyrMag", "HKG3Mag"]
goto "randomize"
#eastweapons
_primaryArray = ["AK47", "AK74", "AK74SU", "PK"]
_BulletArray = ["AK47", "AK74", "AK74", "PK"]
goto "randomize"
#resistanceweapons
_primaryArray = ["AK47", "AK47CZ", "HuntingRifle", "PK", "FAL"]
_BulletArray = ["AK47", "AK47", "HuntingRifleMag", "PK", "FALMag"]
goto "randomize"
#civilianweapons
_primaryArray = ["Beretta", "CZ75", "Glock", "Ingram", "Revolver", "Skorpion", "Tokarev"]
_BulletArray = ["BerettaMag", "CZ75Mag", "GlockMag", "IngramMag", "RevolverMag", "SkorpionMag", "TokarevMag"]
goto "randomize"
;Generate random number based on number of elements in array.
#randomize
_n = 0
_n = count _primaryArray
_random1 = random _n + 1
goto "loopstart"
#loopstart
_ammo = _BulletArray select _random1
_man addmagazine _ammo
_man addmagazine _ammo
_man addmagazine _ammo
_man addmagazine _ammo
_primaryWeap = _primaryArray select _random1
_man addWeapon _primaryWeap
exit[/QUOTE]
Test mission: Here
What I need is suggestions and/or requests to make this thing better.
P.S. Is the "+1" at the end of "_random1 = random _n + 1" neccesary?
HOME 
Reply With Quote
