Home   Help Search Login Register  

Author Topic: An idea for a function (getcargonum)  (Read 1275 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
An idea for a function (getcargonum)
« on: 19 Sep 2006, 18:15:53 »
I would like a function that returns the available cargo positions in a vehicle,
I call it getcargonum.sqf

You can do this:

- create gamelogics and update a number
- cargo them in
- check if they are inside the vehicle and if they are not, the vehicle is full.
- delete all gamelogics

I can script this, but I think it will be better in a function
Thing is, I don't know how to write functions.



Search or search or search before you ask.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: An idea for a function (getcargonum)
« Reply #1 on: 19 Sep 2006, 18:28:28 »
Have you tried reading snypirs tutorials on functions.

Both are available in the Temporary Editors Depot:

http://www.ofpec.com/ed_depot/tutes.htm

Intro to Functions (.sqf)
Writing Functions (.sqf)


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

Offline bdfy85

  • Contributing Member
  • **
Re: An idea for a function (getcargonum)
« Reply #2 on: 19 Sep 2006, 22:02:39 »
I can script this, but I think it will be better in a function
Thing is, I don't know how to write functions.
go ahead - script it ;) I'llhelp you to make it a function afterwards.
Liberation Mod scripts&balance

Offline benreeper

  • Members
  • *
  • I'm a llama!
Re: An idea for a function (getcargonum)
« Reply #3 on: 19 Sep 2006, 23:55:54 »
Yeah but once you assign someone the seat, if you do this function again, and they haven't made it to the seat yet (using "AssignAs" rather than "MoveIn"), the GL will get in and report that the seat is free.  I had to make a vehicle database for every vehicle that I use which listed all of its seats as numbers.  I would then subtract one for each assigned seat until it was zero.  Therefore, I need to know the seats available before hand, in order to create the DB.  A lot of addon creators thwart me by not listing their crew and cargo positions in their docs and then locking the PBO.
--Ben

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: An idea for a function (getcargonum)
« Reply #4 on: 23 Sep 2006, 11:38:02 »
Here you go. Here is a demo mission showing my function (CrewCapacity.sqf). The function returns a four element array. The first element represents the driver position, the second is the gunner position, the third is the commander position and the fourth is the cargo area. In the driver/gunner/commander elements, a 1 indicates that the crew position exists and a 0 indicates that the vehicle does not have that crew position. For the forth element (the cargo), the number indicates the number of cargo seats. The values returned by the function are not affected if the vehicle has units in it. It does not return the current available positions, just the potential crew/cargo positions (whether occupied or not).

There is further explaination in the function header. The included script (crewcap.sqs) is just a means to return the function values.

See my post below for the latest version (it now returns aditional information - cargo seats availabe and total seats available). Invalid postitions are indicated by -1, valid but unavailabel postition are indicated by 0 and available postition are indicated by a 1 or higher value (for cargo).
« Last Edit: 24 Sep 2006, 04:55:34 by Raptorsaurus »

Offline Blanco

  • Former Staff
  • ****
Re: An idea for a function (getcargonum)
« Reply #5 on: 23 Sep 2006, 17:20:10 »
Great, seems to work fine.  :thumbsup:

Quote
It does not return the current available positions, just the potential crew/cargo positions (whether occupied or not).

Is it possible to return the unoccupied seats?






 
Search or search or search before you ask.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: An idea for a function (getcargonum)
« Reply #6 on: 24 Sep 2006, 01:34:07 »
Yes, Here is the latest version. It now returns a 6 element array. [driver, gunner, commander, cargo cap, cargo avail, total avail].

Invalid postitions are indicated by -1, valid but unavailable postition are indicated by 0 and available postition are indicated by a 1 or higher value (for cargo).
« Last Edit: 24 Sep 2006, 04:56:26 by Raptorsaurus »