OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Arctic on 12 Feb 2003, 00:36:21
-
I know what event handlers are, but I do not understand how to specify how they are to be used. Like I understand this:
player addEventhandler ["fire",{this exec somescript.sqs}]
I know that it means that when the player fires something, it will execute the script: somescript.sqs
But how do I specify the specifics of the Event handler? i.e,
"Fired" string:weapon,string:muzzle,string:mode,string:ammo?
I've tried putting in the weapon string right after the "fired" thing, but it returned an error.
I've tried it but the official scripting commands doesnt really explain in enough detail for me to understand how to fully use this tool.
-
same prob ,here... i'm waitin' for so long for a tuto about this...plzzzzz :-\
-
You can specify the arguements between the braces there... so you could do something like this:
player addEventhandler ["fire",{hint format ["Player fired: %1",_this select 1]}]
Would make a hint message pop up every time the player fires, displaying the name of the weapon they fired.
If you want to pass arguements to a script, you can do it thusly:
player addEventhandler ["fire",{[_this select 1, _this select 2] exec "somescript.sqs"}]
Just note that _this select 0 always returns the object the event handler is attached to...
-
how do i make it so that it only works when my guy fires a ak47 ?
-
how do i make it so that it only works when my guy fires a ak47 ?
You need to add an eventhandler type: fired to the unit by
using it's init field.
this addEventHandler ["FIRED", {_this exec "script.sqs"}]
Now create the script and put following into:
?(_this select 1 == "AK47"): whatever you want to do then here
exit
@Sui
Just noticed you're passing _this select 0,_this select 1 with
the exec command.
That's not necessary, as you can pass _this and then you can
have access to the elements of _this inside the script aswell.
If you want to check the contents of _this, then you can display
the whole array aswell by:
hint format ["%1", _this]
~S~ CD
-
That's an awfully good point... ;D
So instead of:
player addEventhandler ["fire",{[_this select 1, _this select 2] exec "somescript.sqs"}]
this would be better:
player addEventhandler ["fire",{_this exec "somescript.sqs"}]