Jump to content
Sign in to follow this  
halex1316

Random Spawning

Recommended Posts

x = floor(random 30);

this setpos [getmarkerpos (markerArray select x)];

markerArray = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","19","21","22","23","24","25","26","27","28","29","30"];

I created this code in a seperate script to allow for three civilians to spawn randomly at created markers, named 1-30.

I placed

_nul = this execVM "civviespawn.sqf"

in the initialization and nothing happened.

Can anyone help me?

Share this post


Link to post
Share on other sites

Hi... where do you actually spawn the civilians?

There's no code there for spawning anything.

Please search the forums... there are lots of posts on spawning. There's one right now on this same page!

Answering the same questions over and over is getting old.

It's really easy.... you want scripts... learn to script by reading other scripts and spending many, many hours testing. We've all been through this. The people that are still here after many years anyway.

Share this post


Link to post
Share on other sites

I have searched, and can't quite find what I'm looking for.

I created three playable characters, and named them civ1, civ2, civ3. I created 30 random markers around the map, and figured it would set the position "setpos" at the randomly chosen marker position [getmarkerpos (markerArray select x)];

You tell me to read other people's scripts, yet your signature says "Learn by doing", which is exactly what I'm doing. I now know what I made won't do, and so I've learned something. Don't be so hypocritical.

---------- Post added at 00:54 ---------- Previous post was at 00:52 ----------

I have searched, and can't quite find what I'm looking for.

I created three playable characters, and named them civ1, civ2, civ3. I created 30 random markers around the map, and figured it would set the position "setpos" at the randomly chosen marker position [getmarkerpos (markerArray select x)];

You tell me to read other people's scripts, yet your signature says "Learn by doing", which is exactly what I'm doing. I now know what I made won't do, and so I've learned something. Don't be so hypocritical.

Share this post


Link to post
Share on other sites

Mate... there's now three posts on this page about random spawning.... if they don't help you then I can't... because I'm just going to type the same stuff in those posts stuff all over again.

And how could "asking" possibly mean "doing"???

Share this post


Link to post
Share on other sites

I created the script and it didn't work. I LEARNED I WAS WRONG.

If you can't help, then don't post. If you're going to ask me that, then tell me how reading other people's scripts is doing anything either?

Share this post


Link to post
Share on other sites

I just typed "random spawning" into the search box and got pages of info..... don't be friggin' lazy!!!!

Share this post


Link to post
Share on other sites

You get pages of useless information. I went through all 20 pages of "random spawning" and only about three or four even pertained to random spawning, and those didn't even answer the question I needed. I wouldn't have come here and posted my OWN QUESTION if I didn't search for it first. FFS.

Share this post


Link to post
Share on other sites

http://forums.bistudio.com/showthread.php?133509

http://forums.bistudio.com/showthread.php?94646

http://forums.bistudio.com/showthread.php?141871

http://forums.bistudio.com/showthread.php?139699

http://forums.bistudio.com/showthread.php?138515

These are just some of the posts I might might read if it was me..... just sayin'

---------- Post added at 02:06 PM ---------- Previous post was at 02:05 PM ----------

You get pages of useless information. I went through all 20 pages of "random spawning" and only about three or four even pertained to random spawning, and those didn't even answer the question I needed. I wouldn't have come here and posted my OWN QUESTION if I didn't search for it first. FFS.

Man you sure read all that shit real fast!!

---------- Post added at 02:09 PM ---------- Previous post was at 02:06 PM ----------

More.... if you think it's useless information then you just don't have the patience for this...... I suggest you give up now!

Share this post


Link to post
Share on other sites

One out of those five links were useful, and on my results (as I just went back and checked) it was on the 15th page. As you can see, it would have been difficult to find it.

Thanks for the link now that you've actually decided to help me instead of chastising me for something I actually put some work into looking for.

Edit ~

Man you sure read all that shit real fast!!
Epic sarcasm.
More.... if you think it's useless information then you just don't have the patience for this...... I suggest you give up now!

I'm working in steps. You think I'm going to remember everything I've read if I can't apply it right away? I'll find what I need, use it, remember it, and keep progressing.

I've been working with mission editing for the past 6 months on and off, so I have the patience for it. I just don't have the patience for idiots like you who pull out their pitchforks and torches when someone who's trying to learn doesn't do things their way.

Get your head out of your ass and let me learn at my own pace.

Share this post


Link to post
Share on other sites

Good... I'm glad you got some joy. Take it easy.

Share this post


Link to post
Share on other sites

Twirly is one of the nicest, most helpful people on the forums. At any rate, here's some shit I wrote awhile ago. It's not fancy, but it works to spawn random groups, I suppose it could work for spawning random objects, civs etc.

//null = [alpha, pad1] execVM "groups.sqf";
private ["_group", "_spawnLocation","_randomGroup","_groupArray"];

_group = _this select 0;
_spawnLocation = _this select 1;

_groupArray = [1,2,3,4,5,6,7,8,9,10,11,12,13,14];
_randomGroup = _groupArray select (floor(random(count _groupArray)));

switch (_randomGroup) do

    {
        case 1:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "RU_InfSquad")] call BIS_fnc_spawnGroup;
        };

        case 2:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "RU_InfSection")] call BIS_fnc_spawnGroup;
        };

        case 3:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "RU_InfSection_AT")] call BIS_fnc_spawnGroup;
        };

        case 4:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "RU_InfSection_MG")] call BIS_fnc_spawnGroup;
        };

        case 5:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "RU_InfSection_MG")] call BIS_fnc_spawnGroup;
        };

        case 6:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "RU_SniperTeam")] call BIS_fnc_spawnGroup;
        };

        case 7:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "RUS_ReconTeam")] call BIS_fnc_spawnGroup;
        };

        case 8:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "MVD_AssaultTeam")] call BIS_fnc_spawnGroup;
        };

        case 9:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Motorized" >> "RU_MotInfSquad")] call BIS_fnc_spawnGroup;
        };

        case 10:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Motorized" >> "RU_MotInfSection_Recon")] call BIS_fnc_spawnGroup;
        };

        case 11:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Motorized" >> "RU_MotInfSection_Patrol")] call BIS_fnc_spawnGroup;
        };

        case 12:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Mechanized" >> "RU_MechInfSquad_1")] call BIS_fnc_spawnGroup;
        };

        case 13:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Mechanized" >> "RRU_MechInfSquad_2")] call BIS_fnc_spawnGroup;
        };

        case 14:

        {
            _group = [getPos _spawnLocation, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Armored" >> "RU_TankPlatoon")] call BIS_fnc_spawnGroup;
        };



   };


nul=[_group, position _spawnLocation, 150] call BIS_fnc_taskPatrol;

Obvioulsy you'll need to modify it to do what you want, instea dof spawning groups maybe it spawn random objects or markers where civs may spawn? idk, use it however

Share this post


Link to post
Share on other sites

@Iceman... thanks bud!

If he had done any reading at all in these forums he would know that all I do is try to help people! Anyway... water under the bridge.

Share this post


Link to post
Share on other sites

twirly has certaintly helped me alot and always pointed me in the right direction if he couldnt help with my exact question, and i will agree definatly one of the most friendly guys on here.

just my 2cents ;)

Share this post


Link to post
Share on other sites

I've figured it out through some more trouble shooting.

Ignore the commented out stuff.

_x=round(random 2); //This gives a number between 0 and 2, not a string.

//_x = 2;

//p1 setpos [getPos b select 0, getPos b select 1, (getPos b select 2) +10];

_y = [_x, 1, 0] call CBA_fnc_formatNumber; //This converts the number into a string with a single digit, but no decimal places.

Make sure the character's name is "p1" and that the markers are named "0","1", and "2"

//hint format ["%1", "The answer was", _y];
hint _y; //This hint displays the string value of the number.

_pos = getMarkerPos _y; //This gets the position of the marker with the same name as the string's returned value.

p1 setpos (_pos); //This sets the position to the same value that the marker is at. i.e. "_pos"






if (_x==0) then //make sure that the
{
	hint "The answer was 0";
} else
{

hint "It was not 0";
};

Make sure that the player is called "p1" and the markers are called "0", "1", and "2". Because the _x=round(random 2) refers to numbers that are 0-2.

Edited by halex1316

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  

×