CPLBuddha 0 Posted December 14, 2001 How do I do an if=then. example: I want a script that will tell if the player is close to another unit it will display a message. Share this post Link to post Share on other sites
DarthBeavis 0 Posted December 14, 2001 I am a senior level programmer. I don't think if=then because "if" and "then" are both reserved key words in most languages. You could dimension a variable, say Var1 and Var2. Then instantiate the variables and assign one of them a value (Var1 = "stuff" ). You can then use the statement Var2 = Var1 thus assigning Var2 the value of Var1 which would be "stuff". Now if you got this far down in my explaination and you are thinking "what the #### is he talking about, that is not what I wanted to know", I realize you really want to know the correct syntax for a conditional "If" statement in OFP's script. Well, I have not looked into it. Â I just wanted to mess with you. If no one else answers this, message me and I will actually look into it and get you the correct syntax. You might also ask if there is an equivilant to "switchcase" or "select case" statements in OFP scripting as they can be easier to use. (Edited by DarthBeavis at 5:25 am on Dec. 14, 2001) Share this post Link to post Share on other sites
HappyG 0 Posted December 14, 2001 ? (Var1 == Var2) : text = "Var1 is equal to Var2" !? (Var1 == Var2) : text = "Var1 is not equal to Var2" Share this post Link to post Share on other sites
Rob 1 Posted December 14, 2001 lol well i think there is a way :biggrin: Share this post Link to post Share on other sites
Rob 1 Posted December 14, 2001 but can u explain wot is there. im a bit confused. where did var1 and var2 com in? Share this post Link to post Share on other sites
HappyG 0 Posted December 14, 2001 Well, it's just an example. He wanted to know an if sentance sytax, right? Share this post Link to post Share on other sites
Rob 1 Posted December 14, 2001 well from experince of now learning c this is wot i know. ?: means not sure !: means false or not (Var1 == Var2): means that when var1 is activated var2 is also. am i right? Share this post Link to post Share on other sites
HappyG 0 Posted December 14, 2001 Hm... OFP sctipts are far away from C syntax.... OFP script: ? (Var1 == Var2) : text = "hehehe" C: if (Var1 == Var2) { text = "hehehe" } OFP script: !? (Var1 == Var2) : text = "hehehe" C: if (Var1 != Var2) { text = "hehehe" } Share this post Link to post Share on other sites
Rob 1 Posted December 14, 2001 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Quote: from HappyG on 7:27 pm on Dec. 14, 2001 Hm... OFP sctipts are far away from C syntax.... OFP script: ? (Var1 == Var2) : text = "hehehe" C: if (Var1 == Var2) { Â text = "hehehe" } OFP script: !? (Var1 == Var2) : text = "hehehe" C: if (Var1 != Var2) { Â text = "hehehe" } <span id='postcolor'> correction!!!! on the last one u forgot to add "!" !if(var1== blablabla and its Printf if ur making exe's Share this post Link to post Share on other sites
HappyG 0 Posted December 14, 2001 Not realy ;-) As you can see I put "!=" and not "==" between the variables :PPPPP Anyway, I forgot that there is a "&" sign before variables in C ;-) CPLBuddha: > I want a script that will tell if the player is close to another unit it will display a message. You need 2 soldiers (sol1 & player) and 1 trigger (trig1) with radius 50m which will only be activated, when your side will be present. Than put this line in sol1 Init field: [] exec "move-trig.sqs" and this in trigger's On Activation field: titletext ["Oh no! You are less than 50m away from Soldier1!","PLAIN"] Than put those lines in "move-trig.sqs" script: #start trig1 setpos getpos sol1 ~1 goto "start" :-) Share this post Link to post Share on other sites
Rob 1 Posted December 14, 2001 so if i added </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Quote: #start trig1 setpos getpos sol1 ~1 goto "start" :-)<span id='postcolor'> in a script then that should work straight away. not even needing to use ?(var1==var2) blablabla? Share this post Link to post Share on other sites
CPLBuddha 0 Posted December 15, 2001 Thanks for all the help. HappyG I could do that, but what if the player is walking and moving about? Share this post Link to post Share on other sites
HappyG 0 Posted December 15, 2001 Buddha: That's why included that little script. It moves the trigger every second right on the place, where soldier is. Rob: This little script is here only for moving the trigger (I hope it's working, I didn't try out). The IF sentence is already included in trigger's On Activation field... Share this post Link to post Share on other sites
Rob 1 Posted December 15, 2001 so wot would i put in a script if a units too close? that might go wel with my campaign Share this post Link to post Share on other sites
HappyG 0 Posted December 15, 2001 Nothing. Triger's radius is 50m. Trigger is triggered, when (let's say) west units are present in that radius. When trigger is triggered it will simply execute comands in "On Activate" field... Share this post Link to post Share on other sites
CPLBuddha 0 Posted December 15, 2001 HappyG Duh. Missed the getpos part. Thanks. Share this post Link to post Share on other sites
HappyG 0 Posted December 17, 2001 Anyway, there is an easier way for doing that. I just found this function today: ? ((sol1 distance player) < 50) : titletext ["Oh no! You are less than 50m away from Soldier1!","PLAIN"] Share this post Link to post Share on other sites