Home   Help Search Login Register  

Author Topic: What's wrong with this?  (Read 1508 times)

0 Members and 1 Guest are viewing this topic.

klavan

  • Guest
What's wrong with this?
« on: 16 Jul 2004, 00:54:32 »
#Sightning
?(_Unit knowsabout _Shilka1 >0) then (_Marker1 SetMarkerType "WARNING")
?(_Unit knowsabout _Shilka2 >0) then (_Marker2 SetMarkerType "WARNING")
?!(alive _Shilka1) and ?!(alive _Shilka2) : goto "Done"
~1
goto "Sightning"

I want to put two markers over the Shilkas when _Unit detect 'em and then close the script when both are destroyed. I'had put two "empty" markers on the map, named 'em, etc... But I gained no effect.
In addiction an error message occour in the line (4th) that should be determining the Shilkas's status. Where's the problem? I tried various sintax combinations, but no one seem to be the right one!
Thanks in advance for any help to a newbie scripter!
CiaoCiao!!!

ponq

  • Guest
Re:What's wrong with this?
« Reply #1 on: 16 Jul 2004, 01:02:52 »
replace "then" with  ":"

?(_Unit knowsabout _Shilka1 >0) : (_Marker1 SetMarkerType "WARNING")
« Last Edit: 16 Jul 2004, 01:03:04 by ponq »

klavan

  • Guest
Re:What's wrong with this?
« Reply #2 on: 16 Jul 2004, 01:14:41 »
I tried, but nothing appear!  ???
Here's the full script:

_Unit = _this select 0
_Shilka1 = _this select 1
_Shilka2 = _this select 2
_Marker1 = _this select 3
_Marker2 = _this select 4

#Sightning
?(_Unit knowsabout _Shilka1 >0) : (_Marker1 SetMarkerType "WARNING")
?(_Unit knowsabout _Shilka2 >0) : (_Marker2 SetMarkerType "WARNING")
?!(alive _Shilka1) and ?!(alive _Shilka2) : goto "Done"
~1
goto "Sightning"

#Done
"2" objstatus "DONE"
_Unit addrating 1500
~2
savegame
exit
« Last Edit: 16 Jul 2004, 01:16:43 by klavan »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:What's wrong with this?
« Reply #3 on: 16 Jul 2004, 01:19:41 »
If you get an erro message quote it here exactly so we know what it says.

setMarker commands need strings as arguments so maybe it should be

"_marker1"

You have too many ? in the fourth line, one at the start is sufficient.   Thereafter use brackets ( ) to make it make sense logically.

Also, it's not always good practice to use alive with a vehicle:  the vehicle can look destroyed when it isn't, which is confusing for the player.     Better is

not canMove S1 and not canFire S1

you can add not alive conditions for the crew as well if you like.  
Plenty of reviewed ArmA missions for you to play

klavan

  • Guest
Re:What's wrong with this?
« Reply #4 on: 16 Jul 2004, 01:36:06 »
Well, i Think it's too late for a test, just now. Tomorrow I'm sure that all will be much more clear than now. Goodnight to all the folks and thanks.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:What's wrong with this?
« Reply #5 on: 16 Jul 2004, 02:03:39 »
Code: [Select]
?((_Unit knowsabout _Shilka1) >0) : ("_Marker1" SetMarkerType "WARNING")
?((_Unit knowsabout _Shilka2) >0) : ("_Marker2" SetMarkerType "WARNING")
?!(alive _Shilka1) and !(alive _Shilka2) : goto "Done"
~1
goto "Sightning"

that should do it i think... ':' and 'then' are the same thing
one thing i'm wondering about is isn't the knowsabout a little small? this script will fire very early on as the unit aproaches the shilka...
« Last Edit: 16 Jul 2004, 02:05:27 by Messiah »
Proud Member of the Volunteer Commando Battalion

ponq

  • Guest
Re:What's wrong with this?
« Reply #6 on: 16 Jul 2004, 12:05:19 »
Quote
':' and 'then' are the same thing

Does that mean you can use both in ofp?

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:What's wrong with this?
« Reply #7 on: 16 Jul 2004, 12:21:02 »
i can't see why not, but i've never used 'then' before in a script - ':' is much simpler to use
Proud Member of the Volunteer Commando Battalion

klavan

  • Guest
Re:What's wrong with this?
« Reply #8 on: 16 Jul 2004, 13:15:34 »
Ok, here's the last version:

;Objective2 Script
;EXECUTION:
;[_UnitName,_MateName,_Shilka1Name,_Shilka2Name,"_Marker1Name","_Marker1Name"] exec "obj2.sqs"


_Unit = _this select 0
_Mate = _this select 1
_Shilka1 = _this select 2
_Shilka2 = _this select 3
_Marker1 = _this select 4
_Marker2 = _this select 5


#Sightning
?((_Unit knowsabout _Shilka1) >2) or ((_Mate knowsabout _Shilka1) >2) : (_Marker1 SetMarkerType "WARNING")
?((_Unit knowsabout _Shilka2) >2) or ((_Mate knowsabout _Shilka2) >2) : (_Marker2 SetMarkerType "WARNING")
?!(canmove _Shilka1 and canfire _Shilka1) and !(canmove _Shilka2 and canfire _Shilka2) : goto "Done"
~1
goto "Sightning"

#Done
"2" objstatus "DONE"
_Unit addrating 1500
~2
savegame
exit

The line determining the Shilkas status now run properly.  ;)
Those that should place the Markers, not. If I'm not in mistake, passing string into a script is determined by the " in the execution commands, as reported above. So quoting the names of the markers transform 'em into strings that should be read by the setmarkertype command, making unecessary quoting _Marker1 and _Marker2 in the scripts.
Or not.......  ???
   

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:What's wrong with this?
« Reply #9 on: 16 Jul 2004, 13:24:10 »
read my original post - u've missed out the "" again on the marker bit  ::)

Code: [Select]
("_Marker1" SetMarkerType "WARNING")

that should now work, so you script will look like this:

Code: [Select]
Objective2 Script
;EXECUTION:
;[_UnitName,_MateName,_Shilka1Name,_Shilka2Name,_Marker1Name,_Marker1Name] exec "obj2.sqs"


_Unit = _this select 0
_Mate = _this select 1
_Shilka1 = _this select 2
_Shilka2 = _this select 3
_Marker1 = _this select 4
_Marker2 = _this select 5


#Sightning
?((_Unit knowsabout _Shilka1) >2) or ((_Mate knowsabout _Shilka1) >2) : ("_Marker1" SetMarkerType "WARNING")
?((_Unit knowsabout _Shilka2) >2) or ((_Mate knowsabout _Shilka2) >2) : ("_Marker2" SetMarkerType "WARNING")
?!(canmove _Shilka1 and canfire _Shilka1) and !(canmove _Shilka2 and canfire _Shilka2) : goto "Done"
~1
goto "Sightning"

#Done
"2" objstatus "DONE"
_Unit addrating 1500
~2
savegame
exit


also noticed this:

Code: [Select]
[_UnitName,_MateName,_Shilka1Name,_Shilka2Name,"_Marker1Name","_Marker1Name"] exec "obj2.sqs"
don't add the "" on the marker bits there, just use their name, "" is just quoting them for the script, not their name. Also, _name is a local variable, as in local to the script, so i don't think you can exec a new script using a local variable... it has to be without the '_', so their editor name
Proud Member of the Volunteer Commando Battalion

Offline Tomb

  • Contributing Member
  • **
  • in2 Metal? Go 2 my sig
Re:What's wrong with this?
« Reply #10 on: 16 Jul 2004, 13:39:08 »
 ;D hehehe... them quote marks...  ;D ;D (*shakes head*) :noo:  ;D

klavan

  • Guest
Re:What's wrong with this?
« Reply #11 on: 16 Jul 2004, 16:25:20 »
This is a previously script created by me, that run properly:

EXECUTION: [aa,papabear,"Bingo!","Radio"] exec "obj1.sqs"

_Unit = _this select 0
_Hq = _this select 1
MarkerG = _this select 2
MarkerR = _this select 3

~240
"1" ObjStatus "DONE"
_Unit addRating 1000
MarkerG SetMarkerType "WARNING"
~1
_Unit SideChat "blablabla"
~3
_Hq SideChat "blablabla"
~1
"2" ObjStatus "ACTIVE"
"3" ObjStatus "ACTIVE"
MarkerR SetMarkerType "WARNING"
~5
savegame
Exit

The main difference here, as you notice, is that I have setted the markers as global variables, because I want ‘em to remain visible for the entire duration of the scenario (a thing that I will implement in the script that we're talking about).

Here's how I ran the f****d script the last time before to scold my poor niece for nothing: :-[
EXECUTION:[aa,ab,s1,s2,Ma,Mb] exec "obj2.sqs"

_Unit = _this select 0
_Mate = _this select 1
_Shilka1 = _this select 2
_Shilka2 = _this select 3
_Marker1 = _this select 4
_Marker2 = _this select 5

#Sightning
?((_Unit knowsabout _Shilka1) >2) or ((_Mate knowsabout _Shilka1) >2) : ("_Marker1" SetMarkerType "WARNING")
?((_Unit knowsabout _Shilka2) >2) or ((_Mate knowsabout _Shilka2) >2) : ("_Marker2" SetMarkerType "WARNING")
?!(canmove _Shilka1 and canfire _Shilka1) and !(canmove _Shilka2 and canfire _Shilka2) : goto "Done"
~1
goto "Sightning"

#Done
"2" objstatus "DONE"
_Unit addrating 1500
~2
savegame
exit

NOW: I ‘ve tried to quote and unquote the names and the variables; I've tried to change the variables from locals to globals (Huu!…Bad omen!); I've tried to bracket and unbracket the --("_Marker1" SetMarkerType "WARNING")-- section; I've tried to pray God…But nothing… :'(


Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:What's wrong with this?
« Reply #12 on: 16 Jul 2004, 17:19:44 »
Couple of facts:
- OFP does not need that humangous amount of brackets... Too much of them actually screws up the script as OFP engine gets confused on what section is supposed to be dealt with first. (afaik... I can be wrong of course ::) )
- markers must be passed into scripts as strings. They are not regular objects, which is probably the reason...
At least I didn't get this script working if I passed the marker names like regular unit names (global variable)...
But when I passed them as strings, it worked...
Actually, I have never had any succes with passing markers into a script if they have not been passed as strings...

Working sript:
Quote
_unit = _this select 0
_mate = _this select 1
_shilka1 = _this select 2
_shilka2 = _this select 3
_marker1 = _this select 4
_marker2 = _this select 5

#sightning
? (_unit knowsAbout _shilka1) > .5 || (_mate knowsAbout _shilka1) > .5: _marker1 setMarkerType "warning"
? (_unit knowsAbout _shilka2) > .5 || (_mate knowsAbout _shilka2) > .5: _marker2 setMarkerType "warning"
? !(canMove _shilka1 && canFire _shilka1) && !(canMove _shilka2 && canFire _shilka2): goto "done"
~1
goto "sightning"

#done
"2" objstatus "done"
_unit addrating 1500
~2
savegame
exit

With knowsAbout .5 the marker appeared when I was about 150 meters away from the vehicle... But of course it's up to you how you want to set it ;)
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

klavan

  • Guest
Re:What's wrong with this?
« Reply #13 on: 17 Jul 2004, 00:48:03 »
 Oh my God! It works!   :thumbsup:
Thanks to all you guys!!  :D