Jump to content
Sign in to follow this  
IndeedPete

Concept Question - How to store shop prices / properties / etc?

Recommended Posts

Hello,

I am currently building a small shop / mission control / hiring & firing / whatever-ideas-I-have-system. One part should be buying and selling weapons and items. I'm currently thinking of ways on how to add certain attributes like "price" or "manufacturer" and other additional stuff to the existing weapons. The ideal solution would be a config file I could access like:

getText (configFile >> "CfgWeapons" >> "arifle_something" >> "price")

However, I dont know how to setup something like this without creating an addon. So, my solution now are in fact arrays I define in the init that look like this:

IP_AvailableWeapons = [
["arifle_MX_F", 5000],
["arifle_MX_GL_F", 7500],
["arifle_MX_SW_F", 10000],
["arifle_MXM_F", 12500]
];

But I find this way too complicated and simply not nice. What I need here are some ideas on how to store these values easily accessible and changeable. Maybe someone has some general thoughts on this one or did similiar stuff already?

If you want to get a glimpse at what I did already, I've posted some not-too-old WIP in this thread asking about another issue. ;)

Share this post


Link to post
Share on other sites

as long as you don't want to make an addon for your mission, arrays are the way to go.

If you don't want to clutter your script files with them define/declare them in an extra file and use #include <filename> without ; in your player or server init file.

greetings Na_Palm

Share this post


Link to post
Share on other sites

declare these following lines in description.ext

class whatever

{

class cfgWeapons {class arifle_something {price = 60;};};

class cfgMagazines {class 30Rnd_65x39_caseless_mag {price = 10;};};

};

now you can called by

getNumber (missionConfigFile >> "whatever" >>"CfgWeapons" >> "arifle_something" >> "price");

Share this post


Link to post
Share on other sites

This is how I did it in my Vehicleshop (as Zatan13th said either put it directly into description.ext or make an external file and #include it into the description.ext):

class TRN_set_vehicleshop
{
   class B_APC_Tracked_01_AA_F
   {
       descAdd = "";
       overrideFlares = "";

       isAmbulance = 0;
       canTransportFOB = 0;
       canTransportCrate = 0;
       canLoadFOB = 0;
       canLoadCrate = 0;

       side[] = {0};
       path[] = {1,1};
       price = 10000;
   };

   class B_APC_Tracked_01_CRV_F 
   {
       descAdd = "";
       overrideFlares = "";

       isAmbulance = 0;
       canTransportFOB = 0;
       canTransportCrate = 0;
       canLoadFOB = 0;
       canLoadCrate = 0;

       side[] = {0};
       path[] = {1,1};
       price = 1000;
   };

   class B_APC_Tracked_01_rcws_F 
...
...

Edited by trnapster

Share this post


Link to post
Share on other sites

Ah, that's cool. Didn't think that it would be so easy though. Thank you very much guys, I'll try it ASAP!

Share this post


Link to post
Share on other sites
declare these following lines in description.ext

class whatever

{

class cfgWeapons {class arifle_something {price = 60;};};

class cfgMagazines {class 30Rnd_65x39_caseless_mag {price = 10;};};

};

now you can called by

getNumber (missionConfigFile >> "whatever" >>"CfgWeapons" >> "arifle_something" >> "price");

This is how I did it in my Vehicleshop (as Zatan13th said either put it directly into description.ext or make an external file and #include it into the description.ext):

class TRN_set_vehicleshop
{
....    
   class B_APC_Tracked_01_rcws_F 
...
...

Are we able to EDIT existing config entries with this,too?

Or is it only possible to add new variables to existing classes?

Both possibilities would add a whole bunch of new scenarios where they could be used for.

https://community.bistudio.com/wiki/description.ext indicates that we don't have access to cfgWeapons,cfgMagazines,cfgVehicles in it.

greetings Na_Palm

Share this post


Link to post
Share on other sites

The description.ext writes everything into the missionconfigfile.

This means createVehicle or similiar commands don't have access/don't search at this location

Here is a suggestion on the feedback tracker from me about this topic

Edited by trnapster

Share this post


Link to post
Share on other sites

Thanks, for clearing this up.

Think i need a bit more coffee to clear my mind before i post. :)

Have missed the point about missionconfigfile...

greetings Na_Palm

Share this post


Link to post
Share on other sites

I'd love to be able to edit the configs inside the description.ext. I could finally add some different ranks to my missions without the need of creating an addon.

Share this post


Link to post
Share on other sites

Yes the possibilities would be endless and it would certainly help the public MP... but well BIS

Share this post


Link to post
Share on other sites

Another question I wasn't able to find the answer by searching for: How can I browse through a config file, i.e. looping over all weapon names from CfgWeapons or something similar?

---------- Post added at 01:02 AM ---------- Previous post was at 12:51 AM ----------

Nevermind, got it!

IP_AvailableMissions = [];
_count = count (missionConfigFile >> "ShopMissions");
for "_i" from 0 to (_count - 1) do {
IP_AvailableMissions set [count IP_AvailableMissions, (configName((missionConfigFile >> "ShopMissions") select _i))];
};

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  

×