Jump to content
Sign in to follow this  
RommelFuchs

getMarkerPos using an Array

Recommended Posts

This is a simple script I've put together using an array containing markes. This script creates a suitcase randomly on one of the markers, but I doesn't work for now:

_locs= ["infoloc1","infoloc2","infoloc3","infoloc4","infoloc5"];


// Random location script
_suitcase= "Land_Suitcase_F" createVehicle getMarkerPos  select floor(random count _locs);

The error stated by -showScriptError is a missing ; between select and floor. Can someone help me on this one?

Share this post


Link to post
Share on other sites

why not just go with something like this ?

_locs= ["infoloc1","infoloc2","infoloc3","infoloc4","infoloc5"] call BIS_fnc_selectRandom;

_suitcase= "Land_Suitcase_F" createVehicle (getMarkerPos  _locs);

Share this post


Link to post
Share on other sites

I'll try this one then. Didn't think about using functions, I always forget to make my life easier.

why not just go with something like this ?

_locs= ["infoloc1","infoloc2","infoloc3","infoloc4","infoloc5"] call BIS_fnc_selectRandom;

_suitcase= "Land_Suitcase_F" createVehicle (getMarkerPos  _locs);

Share this post


Link to post
Share on other sites

_suitcase= "Land_Suitcase_F" createVehicle (getMarkerPos ([color="#FF0000"]_locs[/color] select (floor(random (count _locs)))));

You are missing the _locs array before the select command.

Share this post


Link to post
Share on other sites
why not just go with something like this ?

_locs= ["infoloc1","infoloc2","infoloc3","infoloc4","infoloc5"] call BIS_fnc_selectRandom;

_suitcase= "Land_Suitcase_F" createVehicle (getMarkerPos  _locs);

Normaly I would say you are correct but I would adviase against using BIS_fnc_selectRandom right now(Unless they have fixed it and I missed that).

https://dev-heaven.net/issues/69439

Edit: Nevermind I just checked in the function viewer and they did stealth fix this for Arma 3.

scriptName "Functions\arrays\fn_selectRandom.sqf";
/************************************************************
   Random Select
   By Andrew Barron / Rewritten by Warka


Parameters: array


This returns a randomly selected element from the passed array.


Example: [1,2,3] call BIS_fnc_selectRandom
Returns: 1, 2, or 3
************************************************************/


private ["_ret","_i"];


if(count _this > 0) then
{
   _i = floor random (count _this);           //random index


   _ret = _this select _i;           //get the element, return it
};
_ret


Thanks Warka:)

Edited by Riouken

Share this post


Link to post
Share on other sites

to clarify what your original error was,

_suitcase= "Land_Suitcase_F" createVehicle getMarkerPos select floor(random count _locs);

should have been

_suitcase= "Land_Suitcase_F" createVehicle (getMarkerPos select (floor(random count _locs)));

if im not mistaken. often then engine throws a 'expected ;' when a few commands are strung together.

Share this post


Link to post
Share on other sites
to clarify what your original error was

it was already done.... and u re also... selecting from nowhere.......

_suitcase= "Land_Suitcase_F" createVehicle (getMarkerPos ([color="#FF0000"]_locs[/color] select (floor(random (count _locs)))));

You are missing the _locs array before the select command.

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  

×