Jump to content
Sign in to follow this  
hridaysabz

Need help with this script(again...)

Recommended Posts

 /*
Welcome to the Sea Ammobox script. This script places a random ammobox in the sea at defined markers.
Variables defined can be changed to suit your needs. 
Code by : Hridaysabz
*/
//Ammobox types listed for your discretion.
//Classnames      |      Type
//Box_NATO_Ammo_F | Ammo
//Box_NATO_Wps_F  | Weapons
//Box_NATO_AmmoOrd_F | Explosives
//Box_NATO_Grenades_F| Grenades
//Box_NATO_WpsLaunch_F| Launchers
//Box_NATO_WpsSpecial_F| Special Weapons
//B_supplyCrate_F | Supply Box
//Box_NATO_Support_F | Support Box
//Box_NATO_AmmoVeh_F | Vehicle Ammo Box
//Variables
_ammobox = [box_NATO_Ammo_F, Box_NATO_Wps_F, Box_NATO_AmmoOrd_F, Box_NATO_Grenades_F, Box_NATO_WpsLaunch_F, Box_NATO_WpsSpecial_F, B_supplyCrate_F, Box_NATO_Support_F, Box_NATO_AmmoVeh_F] call bis_fnc_selectRandom;
_spawnpoints = [diverbox, diverbox2, diverbox3, diverbox4, diverbox5, diverbox6]; //Markers to be spawned on.
//Do not edit below this.
if (!isServer) exitWith {};
_ammoboxcreate = "_ammobox" createVehicle (getpos _spawnpoints);
_pos = getpos "_ammobox";
//hint with ammobox details and marker - Editable
hint "hint format ["Located ammocrate at %1",_pos. It has been marked on the map. It is an underwater stash so you will need to get diver equipment."];   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
_marker = createMarker ["DiverMarker", _pos];
"DiverMarker" setMarkerType "Flag";
"DiverMarker" setMarkerText "Underwater Stash";

This doesn't work for some reason...need help!

Edited by Hridaysabz
Updated Code

Share this post


Link to post
Share on other sites

You're missing semicolons everywhere. Also, the while loop will not work. Put your variables inside the while loop, or else it will repeatedly spawn a single type of ammo crate ontop of the selected position. By the way, enable -showScriptErrors in your launch parameters and post the errors (if there are any left after you've fixed what I mentioned) in this topic. Log can be found in Appdata\Local\ArmA3\.rpt (open the one that is the most recently edited)

Also the hint needs to be written in format:

hint format ["Located ammocrate at %1",_pos];

Share this post


Link to post
Share on other sites

Alright, i'll get to it. thanks.

---------- Post added at 09:44 ---------- Previous post was at 07:44 ----------

Hey, how would I go about putting all the variables in the while loop?

---------- Post added at 10:50 ---------- Previous post was at 09:44 ----------

While triggering the script I get this issue:

error getpos: undefined variable in expression box_nato_ammo_F

Share this post


Link to post
Share on other sites

First af all, don't forget the ; at the end of instruction line.

_pos = getpos _spawncrate ;

Share this post


Link to post
Share on other sites

I think you have a problem with the SQF language.

http://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

have a look at createvehicle.

the object in your case is _ammoboxcreate.

So you have to get the position of the object you created.

_pos = getpos _ammoboxcreate;

as your spawn points are in an array, use createvehicle array instead of createvehicle.

Edited by Mariodu62

Share this post


Link to post
Share on other sites

I see a few possible errors some of which due to not knowing if markers are markers or logics.

_ammobox = [ Box_NATO_Ammo_F, shouldn't these be strings "Box_NATO_Ammo_F"

_spawnpoints [diverbox, if they are logics this is fine but if markers they should be strings ["diverbox", I'm assuming logics

also there is no selection associated with this array so you need to add one call bis_fnc_selectRandom;

_ammoboxcreate = createVehicle [_ammobox,getpos _spawnpoints,[], 0, "none"];// less demand on cpu

_pos = getpos _ammoboxpoints; as mentioned above

%1 will be substituted for _pos when run

hint "hint format ["Located ammocrate at %1 It has been marked on the map. It is an underwater stash so you will need to get diver equipment.",_pos ];

I've not tested just looked at it

/*
Welcome to the Sea Ammobox script. This script places a random ammobox in the sea at defined markers.
Variables defined can be changed to suit your needs. 
Code by : Hridaysabz
*/
//Ammobox types listed for your discretion.
//Classnames      |      Type
//Box_NATO_Ammo_F | Ammo
//Box_NATO_Wps_F  | Weapons
//Box_NATO_AmmoOrd_F | Explosives
//Box_NATO_Grenades_F| Grenades
//Box_NATO_WpsLaunch_F| Launchers
//Box_NATO_WpsSpecial_F| Special Weapons
//B_supplyCrate_F | Supply Box
//Box_NATO_Support_F | Support Box
//Box_NATO_AmmoVeh_F | Vehicle Ammo Box
//Variables

_ammobox = ["Box_NATO_Ammo_F", "Box_NATO_Wps_F", "Box_NATO_AmmoOrd_F", "Box_NATO_Grenades_F", "Box_NATO_WpsLaunch_F", "Box_NATO_WpsSpecial_F", "B_supplyCrate_F", "Box_NATO_Support_F", "Box_NATO_AmmoVeh_F"] call bis_fnc_selectRandom;
_spawnpoints = [diverbox, diverbox2, diverbox3, diverbox4, diverbox5, diverbox6] call bis_fnc_selectRandom; //Markers to be spawned on.

//Do not edit below this.
if (!isServer) exitWith {};
_ammoboxcreate =  createVehicle [_ammobox,getpos _spawnpoints,[], 0, "none"];// less demand on cpu
_pos = getpos _spawnpoints;

//hint with ammobox details and marker - Editable

hint format ["Located ammocrate at %1 : %2  It has been marked on the map. It is an underwater stash so you will need to get diver equipment.",round (_pos select 0)/100,round (_pos select 1)/100 ];  

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
_marker = createMarker ["DiverMarker", _pos];
"DiverMarker" setMarkerType "Flag";
"DiverMarker" setMarkerText "Underwater Stash";

Mariodu62

as your spawn points are in an array, use createvehicle array instead of createvehicle.

are you sure you can pass _spawnpoints as an array I did a quick check and it failed.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

You can if the array contains markers

---------- Post added at 13:34 ---------- Previous post was at 13:32 ----------

it will choose a random one of the array.

Share this post


Link to post
Share on other sites

I see I know they can if grouped so it makes sense, in that case if _spawnpoints are actual markers then this should be close.

/*
Welcome to the Sea Ammobox script. This script places a random ammobox in the sea at defined markers.
Variables defined can be changed to suit your needs. 
Code by : Hridaysabz
*/
//Ammobox types listed for your discretion.
//Classnames      |      Type
//Box_NATO_Ammo_F | Ammo
//Box_NATO_Wps_F  | Weapons
//Box_NATO_AmmoOrd_F | Explosives
//Box_NATO_Grenades_F| Grenades
//Box_NATO_WpsLaunch_F| Launchers
//Box_NATO_WpsSpecial_F| Special Weapons
//B_supplyCrate_F | Supply Box
//Box_NATO_Support_F | Support Box
//Box_NATO_AmmoVeh_F | Vehicle Ammo Box
//Variables

_ammobox = ["Box_NATO_Ammo_F", "Box_NATO_Wps_F", "Box_NATO_AmmoOrd_F", "Box_NATO_Grenades_F", "Box_NATO_WpsLaunch_F", "Box_NATO_WpsSpecial_F", "B_supplyCrate_F", "Box_NATO_Support_F", "Box_NATO_AmmoVeh_F"] call bis_fnc_selectRandom;
_spawnpoints = ["diverbox","diverbox2", "diverbox3","diverbox4","diverbox5","diverbox6"];//Markers to be spawned on.

//Do not edit below this.
if (!isServer) exitWith {};
_ammoboxcreate =  createVehicle [_ammobox,getmarkerpos "diverbox",_spawnpoints, 0, "none"];// less demand on cpu
_pos = getpos _ammoboxcreate;

//hint with ammobox details and marker - Editable

hint format ["Located ammocrate at %1 : %2  It has been marked on the map. It is an underwater stash so you will need to get diver equipment.",round (_pos select 0)/100,round (_pos select 1)/100 ];   

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
_marker = createMarker ["DiverMarker", _pos];
"DiverMarker" setMarkerType "hd_objective";
"DiverMarker" setMarkerText "Underwater Stash";

Edited by F2k Sel

Share this post


Link to post
Share on other sites

for me it is more like this

_ammoboxcreate = createVehicle [_ammobox,getmarkerpos "diverbox",_spawnpoints, 0, "none"];// less demand on cpu

where getmarkerpos "diverbox" is the "default" position.

Share this post


Link to post
Share on other sites

what is not working ?

this is wrong for example

hint "hint format ["Located ammocrate at %1 It has been marked on the map. It is an underwater stash so you will need to get diver equipment.",_pos ];

must be:

hint format ["Located ammocrate at %1 It has been marked on the map. It is an underwater stash so you will need to get diver equipment.",_pos ];

Edited by Mariodu62

Share this post


Link to post
Share on other sites

Yes thanks Mariodu62 fixed in previous script and also rounded the numbers to be more readable.

Tested and working.

Share this post


Link to post
Share on other sites

this one is working fine too.

/*
Welcome to the Sea Ammobox script. This script places a random ammobox in the sea at defined markers.
Variables defined can be changed to suit your needs. 
Code by : Hridaysabz
*/
//Ammobox types listed for your discretion.
//Classnames      |      Type
//Box_NATO_Ammo_F | Ammo
//Box_NATO_Wps_F  | Weapons
//Box_NATO_AmmoOrd_F | Explosives
//Box_NATO_Grenades_F| Grenades
//Box_NATO_WpsLaunch_F| Launchers
//Box_NATO_WpsSpecial_F| Special Weapons
//B_supplyCrate_F | Supply Box
//Box_NATO_Support_F | Support Box
//Box_NATO_AmmoVeh_F | Vehicle Ammo Box
//Variables

_ammobox = ["Box_NATO_Ammo_F", "Box_NATO_Wps_F", "Box_NATO_AmmoOrd_F", "Box_NATO_Grenades_F", "Box_NATO_WpsLaunch_F", "Box_NATO_WpsSpecial_F", "B_supplyCrate_F", "Box_NATO_Support_F", "Box_NATO_AmmoVeh_F"] call bis_fnc_selectRandom;
_spawnpoints = ["diverbox","diverbox2", "diverbox3","diverbox4","diverbox5","diverbox6"];//Markers to be spawned on.

//Do not edit below this.
if (!isServer) exitWith {};
_ammoboxcreate = createVehicle [_ammobox,getmarkerpos "diverbox",_spawnpoints, 0, "none"];// less demand on cpu
_pos = getpos _ammoboxcreate;

//hint with ammobox details and marker - Editable

hint format ["Located ammocrate at %1  It has been marked on the map. It is an underwater stash so you will need to get diver equipment.",_pos ];   

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
_marker = createMarker ["DiverMarker", _pos];
_marker setMarkerType "Flag";
_marker setMarkerText "Underwater Stash"; 
*/
_text = "Underwater Stash";
_marker = CreateMarker ["DiverMarker", _pos];
_marker setMarkerShape "Icon"; 
_marker setMarkerType "mil_circle";
_marker setMarkerText format["%1",_text];
_marker setMarkerColor "ColorBlack";

Share this post


Link to post
Share on other sites

Thanks guys, works now credit goes to you guys! You guys make me feel bad about my coding skills every single day.

---------- Post added at 09:24 ---------- Previous post was at 09:23 ----------

Anyway to make a trigger exec this on random times?

Share this post


Link to post
Share on other sites
Thanks guys, works now credit goes to you guys! You guys make me feel bad about my coding skills every single day.

---------- Post added at 09:24 ---------- Previous post was at 09:23 ----------

Anyway to make a trigger exec this on random times?

Don't be silly, maybe you need to understand more about the way this game is working.

I think the best way is too learn by creating a mission with the editor then with the script.

Don't forget there is a lot of function developped by BIS you can use to do a simple but Great Mission.

Have a look in the Fx from the editor.

for the trigger tell us more...

Share this post


Link to post
Share on other sites

Alright, yes, I've been making things on this from the alpha but yes, I will use the fx more now. I don't seem to understand how to implement it though. Nevermind about the trigger, random times seem to be working fine. Thanks guys, I owe you guys one.

---------- Post added at 19:27 ---------- Previous post was at 19:23 ----------

If you're interested, check out my maps on steam. Same name there as here.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×