Home   Help Search Login Register  

Author Topic: "typeof" command  (Read 786 times)

0 Members and 1 Guest are viewing this topic.

bored_onion

  • Guest
"typeof" command
« on: 08 Dec 2004, 18:46:55 »
ive used the "typeof" command in scripts before like this

Code: [Select]
_type = typeof _object
and then used

Code: [Select]
? type != typeof _object
to check whether it still exists (i think thats the right syntax, either way i can get it to work)

however, i was just wondering what the command returns. i looked it up in the comref but "typeof" isnt in there - least not in the official comref. could anyone quickly tell me if they know?

thanks
« Last Edit: 08 Dec 2004, 18:47:22 by bored_onion »

Offline Fire-Fox

  • Members
  • *
  • Violence is just a friend walking on the right way
Re:"typeof" command
« Reply #1 on: 08 Dec 2004, 18:49:27 »
The typeOf command returns the type of the object, for example SoldierW.

Have a look here:
http://www.ofpec.com/editors/comref.php?letter=T#typeOf

:)

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:"typeof" command
« Reply #2 on: 08 Dec 2004, 20:26:38 »
local variable _type
_type = typeof _object

global variable type
? type != typeof _object

Catch my drift?  :)

Still you got to wonder what you're trying to achieve with this. You're checking if an object is still the same type as it was before? That's like changing Bob the granadier to Bob the officer and asking it they're still the same.  ???
Not all is lost.

bored_onion

  • Guest
Re:"typeof" command
« Reply #3 on: 08 Dec 2004, 20:44:35 »
i used it to check whether a bullet is still there or not because you cannot use setdammage or alive with them. if it is not the type it started with and is now "null" then they arent the same so it isnt there - catch my drift? :)

thanks for help
problem solved (i leave it open just in case you dont get why i used it)
« Last Edit: 08 Dec 2004, 20:45:23 by bored_onion »

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:"typeof" command
« Reply #4 on: 08 Dec 2004, 23:35:46 »
Ah right. That'll work. Could use the objnull command too  ;)

Quote
objNull
Type of returned value:
    Object
Description:
    non-existing object. This values is not equal to anything, even to itself.

Example:
    player == objNull , result is false


Quote
isNull obj
Operand types:
    obj: Object
Type of returned value:
    Boolean
Description:
    Check if value is equal to ObjNull. Note: a==ObjNull does not work, because ObjNull is not equal to anything, even to itself.

Example:
    isNull objNull , result is true
Not all is lost.