Home   Help Search Login Register  

Author Topic: Prob with 'IF' [SOLVED]  (Read 1240 times)

0 Members and 1 Guest are viewing this topic.

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Prob with 'IF' [SOLVED]
« on: 16 Mar 2010, 18:13:00 »
Ello guys

For some reason i cant work out why this command isnt working:

Code: [Select]
if ((count giMines) > 0) then {goto "skip"}

it comes up with an error: type number expected array

the command is supposed to work by going to another part of the script when a condition is met. But when run it comes up with the error above.

Any ideas why?

Thx in advance

Gruntage
« Last Edit: 17 Mar 2010, 17:55:27 by Gruntage »
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Krieg

  • Mission Maker
  • Members
  • *
  • Who dares wins.
Re: Prob with 'IF'
« Reply #1 on: 16 Mar 2010, 18:24:51 »
Hmm... :whistle:

Unsure if this will work, but try following code:
Code: [Select]
?((count giMines) > 0) : goto "skip"
If you see a light at the end of the tunnel, then it's probably an enemy tank.

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Prob with 'IF'
« Reply #2 on: 16 Mar 2010, 18:48:29 »
Your if command looks fine to me. Sounds to me most likely that giMines wasn't defined correctly. :confused:
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Prob with 'IF'
« Reply #3 on: 16 Mar 2010, 19:16:19 »
Ok heres the entire script:

Code: [Select]
_obj = _this select 0
_man = _this select 1
_index = _this select 2


;Only the player is allowed to place mines
if (_obj != _man) then {hint"Only the player can place a mine";exit}

;But not if he is in a vehicle (exception is car bomb)
if (vehicle _man != _man) then {hint"Not while you are in a vehicle";exit}

;and only if he still has mines left
if ((count giMines) < 1) then {hint"You have no more GI Mines left";exit}


#PlaceMine
_mine = giMines select 0
_distance = 1.25

giMines = giMines - [_mine]
if ((count giMines) > 0) then {goto"skip"}
_obj removeAction _index
;if ((count apMines) < 1) then {_obj removeAction countMineAction;8 setRadioMsg "NULL";9 setRadioMsg "NULL";MinesOn = nil}

#skip


_minePos = [(getPos _man select 0) + _distance * sin(getDir _man),(getPos _man select 1) + _distance * cos(getDir _man),0]
_man switchmove "CombatToPutDown"
titletext ["Planting Mine","PLAIN DOWN"]
~0.5
titletext ["Planting Mine","PLAIN DOWN"]
~0.5
titletext ["Planting Mine","PLAIN DOWN"]
~0.5
titletext ["Mine Planted","PLAIN DOWN"]
~0.5
gimines=gimines-1


hint format ["You have %1 AV Mines left!", gimines]
;player switchmove"HandGunStandToHandGunTakeFlag"
_case = "bomb" createVehicle [0,0,0]

_case setPos [_minePos select 0,_minePos select 1,-0.35]
~0.75


~ ArmDelay - 1 + random 2

_mine setPos _minePos
_case addAction["Disarm mine","DisarmMine.sqs"]


exit

This script basically allows the player to place mines (not the ones u get in ur gear section). I tried what u said krieg but it didnt work. The 'gimines' are the triggers that have the camcreated shells in e.g. heat125.  The amount of 'gimines' are defined in the init.sqs like gimines=9.

Are there any obvious probs with this script?

Thx for ur help so far

Gruntage
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Prob with 'IF'
« Reply #4 on: 16 Mar 2010, 22:30:10 »
You didn't show where in the game you define giMines. (Misread your post, see below). My suspicion that you didn't define them correctly is furthered by this line:

Code: [Select]
gimines=gimines-1
Is gimines a number or an array? If it an array, then that line of code makes no sense, and if it's a number, then your line

Code: [Select]
if ((count giMines) > 0) then {goto "skip"}
will make no sense. (count can only be used on arrays, it doesn't need to be used on numbers!)

EDIT: plus you said you defined them as gimines=9 . I'm 99% certain that that's your problem. Part of your script (copied below) is written as though you had an array of gimines. I doubt that OFP will recognize the difference between giMines and gimines btw. Your IF command is probably fine.

Code: [Select]
#PlaceMine
;SELECT ONLY WORKS WITH ARRAYS!
_mine = giMines select 0
_distance = 1.25

;AGAIN, GIMINES TREATED AS AN ARRAY!
giMines = giMines - [_mine]
if ((count giMines) > 0) then {goto"skip"}
_obj removeAction _index
;if ((count apMines) < 1) then {_obj removeAction countMineAction;8 setRadioMsg "NULL";9 setRadioMsg "NULL";MinesOn = nil}
« Last Edit: 16 Mar 2010, 22:47:44 by RKurtzDmitriyev »
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Prob with 'IF'
« Reply #5 on: 17 Mar 2010, 17:55:13 »
got it working now. i had to change gimines=9 to something else=9, and then have 'something else'='something else'-1 in the script. Thx for ur help.

topic solved
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba