OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: punisher on 24 Dec 2005, 18:42:51
-
how do i get east respawned soldiers to not have the default AK when respawning?
-
add a killed eventhandler to the unit
by placing the following in the units init field
this addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
and have that event script run code something like the following
UNITKILLED.SQS
the following will rearm the unit with the weapons it died with
_unit = _this select 0
_weapons = weapons _unit
_mags = magazines _unit
_primary = primary weapon _unit
@ alive _unit
_unit removeAllEventHandlers "Killed"
removeallweapons _unit
{_unit addMagazine _x} forEach _mags
{_unit addWeapon _x} forEach _weapons
;;;;;;;;;; BIS Standard
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
_unit selectWeapon _primary
_unit addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
or if you want to rearm it specifically by the classtype of the unit, then do something like the following
UNITKILLED.SQS
the following will rearm a specific class of unit wioth a loadout for that class
_unit = _this select 0
@ alive _unit
removeallweapons _unit
_typeof = typeof _unit
_unit removeAllEventHandlers "Killed"
goto _typeof
;; eg goto label that is same as classtype of unit
#SoldierWB
_mags = ["G36aMag", "G36aMag", "G36aMag", "G36aMag"]
_weapons = ["Binocular","NVGoggles","G36a"]
goto "REARM"
#SoldierWSniper
_mags = ["M21", "M21", "M21", "M21"]
_weapons = ["Binocular","NVGoggles","M21"]
goto "REARM"
#REARM
{_unit addMagazine _x} forEach _mags
{_unit addWeapon _x} forEach _weapons
;;;;;;;;;; BIS Standard
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
_unit selectWeapon _primary
_unit addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
-
Hi Terox,
This seems very cool but guess I'm to new at it...
Could you tell me what I'm doing wrong?
Added the eventhandler to the init field of each soldier & made unitkilled.sqs like this but all respawn with ak47 / 1clip
_unit = _this select 0
@ alive _unit
removeallweapons _unit
_typeof = typeof _unit
_unit removeAllEventHandlers "Killed"
goto _typeof
;; eg goto label that is same as classtype of unit
#fdf_ww2_jaakariOfficer
_mags = ["FDF_L35Mag","FDF_L35Mag","FDF_L35Mag","FDF_L35Mag"]
_weapons = ["Binocular","FDF_L35"]
goto "REARM"
#fdf_ww2_jaakariKasapanos
_mags = ["FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag"]
_weapons = ["FDF_ukkopekka"]
goto "REARM"
#fdf_ww2_jaakariPzSchreck
_mags = ["FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_PanzerSchreckMag","FDF_PanzerSchreckMag"]
_weapons = ["FDF_ukkopekka","FDF_PanzerSchreck"]
goto "REARM"
#fdf_ww2_jaakariSVT
_mags = ["FDF_SVT40Mag","FDF_SVT40Mag","FDF_SVT40Mag","FDF_SVT40Mag","FDF_SVT40Mag","FDF_SVT40Mag"]
_weapons = ["FDF_SVT40"]
goto "REARM"
#fdf_ww2_jaakariLMG
_mags = ["FDF_emmaMag","FDF_emmaMag","FDF_emmaMag","FDF_emmaMag"]
_weapons = ["FDF_emma"]
goto "REARM"
#fdf_ww2_jaakariMedic
_mags = ["FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag"]
_weapons = ["FDF_ukkopekka"]
goto "REARM"
#fdf_ww2_jaakariSMG
_mags = ["FDF_suomikpMag","FDF_suomikpMag","FDF_suomikpMag","FDF_suomikpMag","FDF_stickGrenade","FDF_stickGrenade"]
_weapons = ["FDF_suomikp"]
goto "REARM"
#fdf_ww2_jaakariMessanger
_mags = ["FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag"]
_weapons = ["FDF_ukkopekka"]
goto "REARM"
#REARM
{_unit addMagazine _x} forEach _mags
{_unit addWeapon _x} forEach _weapons
;;;;;;;;;; BIS Standard
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
_unit selectWeapon _primary
_unit addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
Thx in advance ::)
-
Also tried the 1st unitkilled.sqs you posted & it returns this error:
'_primary = primary |#|weapon _unit': Error Unknown operator weapon
so removed the space between primary & weapon & get no error msg; but still the units respawn with ordenary ak's :s
Once again,
thanks in advance!
Seven 8)
*edit* This script (http://www.ofpec.com/editors/resource_view.php?id=474)did the job for me; although I would love to know where I was wrong
-
oops my mistake
primary weapon
should be one word
primaryweapon _unit
also on the second example script, place the following line just after the
@ alive _unit
hint "I am alive"
I have a feeling you probably wont see the Hint line
Reason being that the newly created _unit will be a copy of the dead _unit
and therefore you would have to use the "name _unit" as a check to see if the unit is onmce again alive
I have to go out right now, but when i get back early this evening, i will dig the system out and post it
2 questions
1) The unit you want to rearm on respawn, is that a player only / any unit in a players group, or server controlled enemy AI
can you give more info
2) Do you want the unit to have the weapons it started with or a custom loadout or the weapons it died with
-
2 questions
1) The unit you want to rearm on respawn, is that a player only / any unit in a players group, or server controlled enemy AI
can you give more info
2) Do you want the unit to have the weapons it started with or a custom loadout or the weapons it died with
Lo Terox ;)
1) It's a MPmission with one group of 9 players; AI should not be involved but the option is there to take them with you.
2) The weapons it started with (as I tried in your 2nd unitkilled.sqs found out the units classnames & classes of their weapons; so thought that would do the thing)
3) respawn happens at respawn_guerilla
Greetz,
Seven
-
I take it you only want this respawn rearming for players
then
That makes it a whole lot easier
____________________________________________________
so to rearm with the weapons they started with use the following
INIT.SQS
tx_mags = magazines player
tx_weps = weapons player
tx_prim = primaryweapon player
tx_Kevent = Player addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
UNITKILLED.SQS
Player removeEventhandler tx_Kevent
@ alive Player
removeallweapons Player
{Player addMagazine _x} forEach tx_mags
{_unit addWeapon _x} forEach tx_weps
;;;;;;;;;; BIS Standard
?(tx_prim == "M16GrenadeLauncher"): tx_prim = "M16Muzzle"
?(tx_prim == "Ak74GrenadeLauncher"): tx_prim = "AK74Muzzle"
?(tx_prim == "Ak47GrenadeLauncher"): tx_prim = "AK47Muzzle"
Player selectWeapon tx_prim
tx_Kevent = Player addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
Each player will reload on respawn with the weapons they started with
All you need to do is add to the ?(tx_Prim == XXXX)
any fdf grenade launcher weapons
-
Hi again Terox,
This just won't work :-\
I know get this error when I kill myself or another player to test the script
'Player removeEventhandler tx_Kevent|#|': Error removeeventhandler: Type Number, expected Array
If I tk another player for testing that is, I also loose all my weapons...
eh ???
ps: replaced the prim with ?(tx_prim == "FDF_HK69"): tx_prim = "HK69A1"
-
ps: replaced the prim with ?(tx_prim == "FDF_HK69"): tx_prim = "HK69A1"
I dont think you understand what i meant by restating tx_prim
Basically weapons like the M16GL and the AK74GL have more than one muzzle mode
For these specific type of weapons, you have to state which muzzle mode you need to select when selecting the weapon as primary otherwise as a player, you have to press spacebar to get a weapon mode, be it gl or auto, semi auto etc
so if the FDF_HK69 was an assault rifle/grenade launcher you would probably have to type
?(tx_prim == "FDF_HK69"): tx_prim = "HK69muzzle"
what you are actually stating is
if my primary weapon is a fdf_hk69 then i need to select it in "Muzzle mode" not grenade launcher mode
If its a standard, 1 ammo type weapon, then you dont need to add it to the
?(tx_Prim == "XXXXX"):
as there is only 1 muzzle to select and that will be done automatically
I Have changed the killed event handler lines (I cant remember how to specifically remove a certain eventhandler, but as it would appear that you havent used any yourself, the script simply removes all of them on death
INIT.SQS
tx_mags = magazines player
tx_weps = weapons player
tx_prim = primaryweapon player
Player addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
UNITKILLED.SQS
Player removeallEventhandlers "Killed"
@ alive Player
removeallweapons Player
{Player addMagazine _x} forEach tx_mags
{_unit addWeapon _x} forEach tx_weps
;;;;;;;;;; BIS Standard
?(tx_prim == "M16GrenadeLauncher"): tx_prim = "M16Muzzle"
?(tx_prim == "Ak74GrenadeLauncher"): tx_prim = "AK74Muzzle"
?(tx_prim == "Ak47GrenadeLauncher"): tx_prim = "AK47Muzzle"
Player selectWeapon tx_prim
Player addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
-
I dont think you understand what i meant by restating tx_prim
I do now thx :)
Will try the script next week after all the food & drink madness... :-X
-
There are lots of scripts in the Ed Depot that respawn players with different weapons (such as the ones they died with, for example).
Search for 'respawn' and here is what you get:
http://www.ofpec.com/editors/browse.php?browseon=&browsewhat=-1&catselected=-1_-1&catagory=-1&subcategory=-1_-1&numreturn=25&displayformat=0&ofpv=1&searchwhat=1&searchlevel=0&searchwhat=1&searchopts=&searchstring=respawn&x=0&y=0