Jump to content
Sign in to follow this  
cookies2432

Loot system help

Recommended Posts

So, i'm trying to create a loot system but i'm not able to get it to work, I want it to spawn the items when I approach them (200m as of now)

 

This is my code: (called from the player)

fnc_nearbyHouses = {

  _plr = _this select 1;

        _houses = nearestObjects [_plr, ["house"], 200];
        _count = count _houses;

        for "_i" from 0 to (_count-1) do

        {
        houseClass = _houses select _i;

        if (houseClass isKindOf "house") then {

          for "_n" from 0 to 50 do {

            buildingSpots=_house buildingpos _n;
   if (str buildingSpots == "[0,0,0]") exitwith {};

            call fnc_lootSpawn;
        };

      } forEach _houses;


};


fnc_lootSpawn = {

_plr = _this select 1;

_lootItems = selectRandom [1,2,3,4];

      while {_lootItems > 0} do {

  _loot = ["hgun_Rook40_F","arifle_Katiba_F","U_I_Wetsuit","V_PlateCarrier2_blk"];


  _spawnItem = selectRandom _loot;

  _spawnedItem = createVehicle _spawnItem position houseClass;

_lootItems = _lootItems - 1;

      };
};

I appriciate any help!

 

Share this post


Link to post
Share on other sites

I would  do this in this way:

 

1. Create array with weapons/magazines classnames

2. Get all enterable buildings in one array.

    Here is something to re- think.

    Maybe would be better to set some locations and its  buildings arrays.

3. Set distance detector to any player for each building

4. Spawn random gear in random building when distance match

5. Despawn gear when distance not match again.

6. Set timer to delay spawn gear again for buildings where gear was taken

 

Anyway there are so many loot spawners already created.

Share this post


Link to post
Share on other sites

I would  do this in this way:

 

1. Create array with weapons/magazines classnames

2. Get all enterable buildings in one array.

    Here is something to re- think.

    Maybe would be better to set some locations and its  buildings arrays.

3. Set distance detector to any player for each building

4. Spawn random gear in random building when distance match

5. Despawn gear when distance not match again.

6. Set timer to delay spawn gear again for buildings where gear was taken

 

Anyway there are so many loot spawners already created.

I know, but I wanna make my own one to learn and not to copy anyone else's work :)

  • Like 1

Share this post


Link to post
Share on other sites

Wrong approach to the matter.

 

The best and easy method to learn or get some idea is to have a look how others most skilled scripters had make its own projects.

While you analyze such code it would be astonishing for you how they have done that.

In meantime while you still learn you have not much clues what you can use and how.

Analyzing someones script can give you more experience as you think.

You do not need to use it if you are such individual person. Just have a look.

  • Like 1

Share this post


Link to post
Share on other sites

Wrong approach to the matter.

 

The best and easy method to learn or get some idea is to have a look how others most skilled scripters had make its own projects.

While you analyze such code it would be astonishing for you how they have done that.

In meantime while you still learn you have not much clues what you can use and how.

Analyzing someones script can give you more experience as you think.

You do not need to use it if you are such individual person. Just have a look.

Alright, thanks :)

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  

×