Home   Help Search Login Register  

Author Topic: NEED HELP... Vehicle cache.  (Read 1282 times)

0 Members and 1 Guest are viewing this topic.

Offline Fanus

  • Members
  • *
NEED HELP... Vehicle cache.
« on: 12 Aug 2006, 10:50:20 »
Hi there. I need help creating script that can put a vehicle into a temporary cache which can be retrieved later if needed. I created a script so far but it doesn't work yet. Can anyone help me please. Here is wat i got so far...

Code: [Select]
; create dialog
_cacheMenu = CreateDialog "CacheDialog"

_cache = []

#start
_vehiclePlayer = vehicle player

btnCache=false
btnSave=false

#loop

; if button pressed "Cache"
? btnCache : btnCache=false;if ((_vehiclePlayer distance garage > 10 ) && (player in _vehiclePlayer)) then {player action ["eject",_vehiclePlayer]; lbAdd [2000, typeof _vehiclePlayer]; deletevehicle _vehiclePlayer} else {hint "exit"}

; if button pressed "Save"
? btnSave : btnSave=false; goto "cache"

goto "loop"

#cache

; list saved to an array
_cache set [(0,lbText [2000, 0])]

goto "start"


By pressing the "Cache" button: The vehicle is deleted and added to a list.

By pressing the "Save" button: The vehicle needs to be added to an array. Then the array must be "saved" and every time the dialog is created, the list must be occupied by all the cached vehicles.

The script must create a Garage. When i drive a vehicle into a garage, the vehicle must be deleted, saved and recovered if needed. This will help me lower the lag of my mission.

Please help. Thx in advance.
Fanus.


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: NEED HELP... Vehicle cache.
« Reply #1 on: 12 Aug 2006, 14:35:26 »
Dialogue scripts are not my thing so unfortunately I can't help, but

Welcome to the forum!
Plenty of reviewed ArmA missions for you to play

Offline Fanus

  • Members
  • *
Re: NEED HELP... Vehicle cache.
« Reply #2 on: 16 Aug 2006, 16:34:43 »
All I want to do is to make an array that can "save" and later on when the file is opened, the array must be loaded first before the script starts. Please!  :banghead:

Offline Silola

  • Members
  • *
Re: NEED HELP... Vehicle cache.
« Reply #3 on: 11 Sep 2006, 14:47:31 »
hi fanus,

here a small suggestion, how it could look.
In the "Init.sqs" the relevant variables must be defined and initialize.

Quote
;init.sqs
;---------------------
LB_Cache = []
btnCache=false
btnSave=false

Then the "CreateDialog.sqs", in order to open the dialogue:

Quote
;createDialog.sqs
;---------------------
_cacheMenu = CreateDialog "CacheDialog"

#fillLB
;///Here the LB is filled by the entries in the array
?(count LB_Cache == 0):goto "loop"
lbclear 2000;_i = 0
while "_i < count LB_Cache" do {_Entry = LB_Cache select _i;_index = lbAdd [2000, _Entry];lbSetData [2000, _index, _Entry];_i = _i + 1}
~0.1
lbSetCurSel [2000, (lbsize 2000 - 1)]

#loop
~1
;///if you hit "ESC" to close the dialog
?(!(ctrlvisible 2000)):btnCache=false;btnSave=false;exit

;///if button pressed "Cache"
?(btnCache):btnCache=false;if(!(vehicle player == player)) then {_vehiclePlayer = vehicle player;if((_vehiclePlayer distance garage < 10 ) && (player in _vehiclePlayer)) then {goto "addEntry"} else {cuttext["not possible","plain",0.2]}} else {cuttext["no vehicle available","plain",0.2]}

;///if button pressed "Save"
? btnSave : btnSave=false; goto "cache"
goto "loop"

#addEntry
;///Adds a new entry, if not yet available
player action ["eject",_vehiclePlayer]
_entry = format["%1",typeof _vehiclePlayer]
~1
deletevehicle _vehiclePlayer
?(_entry in LB_Cache):goto "loop"
_index = lbAdd [2000, _entry]
lbSetData [2000, _index, _entry]
lbSetCurSel [2000, (lbsize 2000 - 1)]
goto "loop"

#cache
;list saved to an array
_entry = lbData[2000, lbCurSel 2000]
?(_entry in LB_Cache):hint "This entry exists already";goto "loop"
LB_Cache = LB_Cache + [_entry]
goto "start"

Even if the empty vehicles are to be generated from the dialogue,
the dialogue would have to contain the Button "create".
The scripts would look as follows then.

Quote
;init.sqs
;---------------------
LB_Cache = []
btnCache=false
btnSave=false
btnCreate=false

Quote
;createDialog.sqs
;---------------------
_cacheMenu = CreateDialog "CacheDialog"

#fillLB
;///Here the LB is filled by the entries in the array
?(count LB_Cache == 0):goto "loop"
lbclear 2000;_i = 0
while "_i < count LB_Cache" do {_Entry = LB_Cache select _i;_index = lbAdd [2000, _Entry];lbSetData [2000, _index, _Entry];_i = _i + 1}
~0.1
lbSetCurSel [2000, (lbsize 2000 - 1)]

#loop
~1
;///if you hit "ESC" to close the dialog
?(!(ctrlvisible 2000)):btnCache=false;btnSave=false;exit

;///if button pressed "Cache"
?(btnCache):btnCache=false;if(!(vehicle player == player)) then {_vehiclePlayer = vehicle player;if((_vehiclePlayer distance garage < 10 ) && (player in _vehiclePlayer)) then {goto "addEntry"} else {cuttext["not possible","plain",0.2]}} else {cuttext["no vehicle available","plain",0.2]}

;///if button pressed "Save"
? btnSave : btnSave=false; goto "cache"
goto "loop"

;///if button pressed "Create"
? btnCreate : btnCreate=false; goto "createVeh"
goto "loop"

#addEntry
;///Adds a new entry, if not yet available
player action ["eject",_vehiclePlayer]
_entry = format["%1",typeof _vehiclePlayer]
~1
deletevehicle _vehiclePlayer
?(_entry in LB_Cache):goto "loop"
_index = lbAdd [2000, _entry]
lbSetData [2000, _index, _entry]
lbSetCurSel [2000, (lbsize 2000 - 1)]
goto "loop"

#createVeh
;///generate a new empty vehicle
_entry = lbCurSel 2000
_newUnit = _entry createvehicle getpos garage
goto "loop"

#cache
;list saved to an array
_entry = lbData[2000, lbCurSel 2000]
?(_entry in LB_Cache):hint "This entry exists already";goto "loop"
LB_Cache = LB_Cache + [_entry]
goto "start"

Please excuse my bad English :-(

bye
silola
« Last Edit: 12 Sep 2006, 06:55:44 by Silola »

PetriHonka

  • Guest
Re: NEED HELP... Vehicle cache.
« Reply #4 on: 18 Sep 2006, 22:01:24 »
May I ask why this script is needed? Where is it going to be used?