OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: FiLL2d on 10 May 2004, 18:39:47
-
?(side player == west): goto "Menu-allies"
?(side player == east): goto "Menu-axis"
#null
boolean = false
@ boolean
#Menu-allies
?(local player):[] exec "spawn/alliesmenu.sqs"
boolean = false
@ boolean
#Menu-axis
?(local player):[] exec "spawn/axismenu.sqs"
boolean = false
@ boolean
--------------------
alliesmenu.sqs
--------------------
Menu1 = createDialog "Menuwest"
--------------------
need help, how can i make it so only the player that activates this script can see the menu
-
Script seems a little odd to me
If a player was Side WEST
he would instantly run the following blue lines, wait for the red line to become true and not run the green lines at all
?(side player == west): goto "Menu-allies"
?(side player == east): goto "Menu-axis"
#null
myboolean = false
@ myboolean
#Menu-allies
?(local player):[] exec "spawn/alliesmenu.sqs"
myboolean = false
wait at the following line until the boolean becomes true again
@ myboolean
then run the following blue lines instantly
#Menu-axis
?(local player):[] exec "spawn/axismenu.sqs"
myboolean = false
wait at the following line until the boolean becomes true again
@ myboolean
the following makes more sense
******************************************************************
?!(local player): exit
#START
myboolean = false
@ myboolean
?(side player == west): goto "Menu-allies"
?(side player == east): goto "Menu-axis"
#Menu-allies
[] exec "spawn/alliesmenu.sqs"
myboolean = false
goto "START"
#Menu-axis
[] exec "spawn/axismenu.sqs"
myboolean = false
goto "START"
**************************************************
If the boolean is not public variabled, or made true by a trigger global to all then only the client where the boolean became true would get past the @ statement
In addition, a more efficient way of running the boolean check would be to remove the @ stament which refreshes at the fps and instead use a slow loop like the following example
#START
~1
myboolean = false
?(myboolean) && (side player == west): goto "Menu-allies"
?(myboolean) && (side player == east): goto "Menu-axis"
goto "START"
-
So this would mean you can set seperate objectives for 2 sides and niether could see the other sides?
-
Dont be afraid of using the @ with a boolean variable, in fact there is an argument to say it's more efficent that using the ~ in a loop. For starters there is more code in the ~ loop for OFP to compile. If you check it every second, OFP has to keep track of the time between each call.
But remember it's a boolean variable and not a command that returns a boolean as a result. I have 200+ @ conditions checking a single boolean variable without any ill effect.
-
Greetings,
Indeed, Unnamed, a good point. However, the difficulty comes when you want to check for more than one condition (such as boolean1 or !alive player). Then you have to use a loop to test for all the conditions. As in
#loop4576
? !(alive player): exit
? boolean1: goto "detonate"
? x == y: a=b+x
~0.5
goto "loop4576"
-Supr. Cmdr. PsyWarrior
-Psychic Productions
-
Yeah, I can only guess at what OFP does behind the scenes and whats involved with things like the Alive command.
Another side effect of using the @ command is the scripts run at the current frame rate. I have not had chance to test if this is the same when using ~, although I do know if you tried say ~0.0004 it would never run any faster than the @ command, which on my PC executes every ~0.03 (on the desert island).
I will stick my neck out ::) and say as a rule of thumb only use it on variables, and then nothing more complex than:
@(Call {Boolean1 Or Boolean2})
But then, it wont be the first or last time I get it wrong :) :-X