Home   Help Search Login Register  

Author Topic: Another formatting question :-( - ? ({Format["%1", _Insurance]}) : Goto Insura  (Read 825 times)

0 Members and 1 Guest are viewing this topic.

Acecool

  • Guest
_Insurance = Call format ["%1_Insurance", _unit_id]
_Permanent_Insurance = Call format ["%1_Permanent_Insurance", _unit_id]
? ({Format["%1", _Permanent_Insurance]}) : Goto Permanent_Insurance
? ({Format["%1", _Insurance]}) : Goto Insurance
? (not({Format["%1", _Insurance]})) : Goto None
hint Format["%1", _Insurance]

---

Ok, the Hint works...

the ? ....s dont.. gives an error..
ive tried call, with without {} in seperate places etc...

Any help appreciated.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
The thing between the brackets and after the ? should be a boolean but is not.
? (an expression)
should use (an expression) that results in either a True or a False result
eg:  a == b
        (alive unit)
        etc.

All you have is a Format statement

From your code I have no clue as to what you are trying to do.

It seems you are setting the value of  
_Insurance to _unit_id_Insurance
and the value of
_Permanent_Insurance to _unit_id_Permanent_Insurance

Under what circumstances to you wish to excute the relevant goto statements?

 
« Last Edit: 05 Mar 2005, 09:37:58 by THobson »

Acecool

  • Guest
Splicing the variable together..

p1_Insurance..


_Players = ["p1","p2","p3","p4","p5","c1","c2","c3","c4","c5","c6","c7","c8","c9","c10"]
{call format ["%1_Insurance = 0", _x]} forEach _Players
{call format ["%1_Permanent_Insurance = 0", _x]} forEach _Players

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
should  = 0
really be == 0
?
That is - are you trying to assign the  value 0 or the value true or false?
« Last Edit: 05 Mar 2005, 12:25:37 by THobson »

Acecool

  • Guest
A Value:
call format [{%1_Money = 2500}, _unit_id]

   Call format [{%1_Money=%1_Money/4}, _unit_id]
   _Money = Call format ["%1_Money", _unit_id]
   _moneymsg = Format["%1, You died and did not have insurance, you lost 3/4 of your money and have $%2 left.", name _unit,_Money]

Works..

Putting it into an if/else is a bit weird...

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
So what's with all this goto business at the start of this thread? I don't see the connection from there to anything that follows (my first post excepted).

If you now have an answer to question I am happy for you - but I am confused now as to what that question was.

Looking at this and others of your threads I feel you might be better off investigating the use of arrays rather that having a whole range of variable names.
« Last Edit: 05 Mar 2005, 12:34:36 by THobson »

Acecool

  • Guest
The problem with ofp script is its weird...

It should follow c++ syntax rules etc..

Basically, I am trying to return the value of p1_Insurance (Spliced together) to use in an if/ifelse

The Goto part, it so it goes to the correct area...

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
In the absence of arrays why not do it in two steps.  

_Money = Call format ["%1_Money", _unit_id]

if (_Money < blahdeblah) then {doit} else {dosomethingelse}

Otherwise I think you will need to do a call within an if statement condition and I am not sure that will work.

Acecool

  • Guest
Ok, this does not return any errors, but it does not goto the correct area either...

_Insurance = Call format ["%1_Insurance", _unit_id]
_Permanent_Insurance = Call format ["%1_Permanent_Insurance", _unit_id]
? (_Permanent_Insurance>0) : Goto Permanent_Insurance;
? (_Insurance>0) : Goto Insurance;
? (_Insurance<1) : Goto None;

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Your goto labels must be enclosed in quotes.

For example:

Goto Permanent_Insurance

Should be:

Goto "Permanent_Insurance"

And the relevant label should be thus elsewhere in your script:

#Permanent_Insurance


Planck
« Last Edit: 05 Mar 2005, 14:53:15 by Planck »
I know a little about a lot, and a lot about a little.

Acecool

  • Guest
Code: [Select]
_Insurance = Call format ["%1_Insurance", _unit_id]
_Permanent_Insurance = Call format ["%1_Permanent_Insurance", _unit_id]
? (_Permanent_Insurance == Yes) : Goto "Permanent_Insurance"
? (_Insurance == Yes) : Goto "Insurance"
? (_Insurance == No) : Goto "None"
hint "Did not work"


#Insurance
Call format [{%1_Insurance=false}, _unit_id]
_unit_id groupchat _Insurance_msg
Goto "Exit"


#Permanent_Insurance
_unit_id groupchat _Permanent_Insurance_msg
Goto "Exit"


#None
Call format [{%1_Money=%1_Money/4}, _unit_id]
_Money = Call format ["%1_Money", _unit_id]
_unit_id groupchat _No_Insurance_msg
Goto "Exit"

#Exit
exit

Still shows did not work as hint :-(

tried using == "Yes" etc..

;//
;// Insurance
;//
call format [{%1_Insurance = "No"}, _unit_id]
call format [{%1_Permanent_Insurance = "No"}, _unit_id]

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Change your hint to display what is actually being put into _Insurance and _Permanent_Insurance.

You might find it is not what you are expecting to find.


Planck
I know a little about a lot, and a lot about a little.

Acecool

  • Guest
hint _Insurance

Just showed "No" without the quotes

Acecool

  • Guest
_Insurance = Call format ["%1_Insurance", _unit_id]
_Permanent_Insurance = Call format ["%1_Permanent_Insurance", _unit_id]
? (_Permanent_Insurance != "No") : call format [{%1 groupchat "1"}, _unit_id]; Goto "Permanent_Insurance"
? (_Insurance != "No") : call format [{%1 groupchat "2"}, _unit_id]; Goto "Insurance"
? (_Insurance != "Yes") : call format [{%1 groupchat "3"}, _unit_id]; Goto "None"

Solved...

!= not equal worked...

but == equal to doesnt...