OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blanco 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.
-
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 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.
-
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
-
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).
-
Great, seems to work fine. :thumbsup:
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?
-
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).