Jump to content

[Tutorial] Dynamic Cop Weapon Shop 5.0


Recommended Posts

Intro:

Spoiler

Note: As pointed out by others, this tutorial is a little redundant, and if anything takes us back to how the shops used to work, wherein there were multiple classes, and multiple addActions. This was close to a previous way to have one addAction for multiple shops, although this is no longer needed as the current build can do this without the tutorial, but is nice for anyone who enjoys how the weapon shops were previously setup, I think the code was more appealing to read, and easier to edit, so here it is.

Hey there!

First off, I'll start with a disclaimer. I'm not the greatest script writer, I'm not even decent. Nor am I used to posting on these forums, so I may make a mistake regarding the format, etc. However, if I have knowledge that even one other person might find useful, it would be awesome to help them out!

The idea of this functionality is not mine, I used a tutorial long ago by Grimm and always enjoyed the level of simplicity it added to the scroll menu of cop shops. His tutorial can no longer be utilized with the current structure of the fn_weaponShopMenu.sqf file, so I found another simple way to make it work. I'll attempt to do my best to translate the code into simple English so those who are less adept may have a better understanding. If there's some way to improve my post, or my code please let me know!

Description:

Spoiler

What this tutorial will accomplish.

When you first install the base framework, you'll only need one class for all the cop weapon shops. It used to be you'd have multiple classes and multiple addActions. People found ways to have only one addAction for all of their classes, and the class called would be dependent on your cop level. Instead of having one single class for all the weapon shops, this tutorial will show you how to have multiple classes to organize your shops(more so like it used to be), while still using the one addAction. This changes zero functionality, and is simply for those who appreciated some of the previous structure. Although this could be applied to other shops, we'll be sticking to the cop weapon shops for this tutorial.

Tutorial:

Spoiler

Step 1: 

You'll want to pull up the following files for this tutorial.

Mission_File.Map\core\shops\fn_weaponShopMenu.sqf

Mission_File.Map\config\Config_Weapons.sqf

Mission_File.Map\mission.sqm

 

Step 2:

Within the fn_weaponShopMenu.sqf file, go to the ninth line, and press enter once. Paste the following onto what is now the tenth line.

Spoiler

private _myCopLevel = switch (player getVariable["myLevel", (call life_coplevel)]) do { case 1:{"cop_level_one"}; case 2:{"cop_level_two"}};

A private variable with the name _myCopLevel to be used later on within this file, and we're going to use switch to find the database cop level assigned to our player, assign this to a case, which has a string inside of it, which will then be what our variable is equal to. Essentially if you're cop level 1 in the database, the switch will go to case 1 which then assigns the string "cop_level_one" to our variable.

Within the same file, you'll want to find the following lines, 

Spoiler

...
private _shopTitle = M_CONFIG(getText,"WeaponShops",(_this select 3),"name");
private _shopSide = M_CONFIG(getText,"WeaponShops",(_this select 3),"side");
private _conditions = M_CONFIG(getText,"WeaponShops",(_this select 3),"conditions");
...
uiNamespace setVariable ["Weapon_Shop",(_this select 3)];
...

and replace them with.

Spoiler

...
private _shopTitle = M_CONFIG(getText,"WeaponShops", _myCopLevel,"name");
private _shopSide = M_CONFIG(getText,"WeaponShops", _myCopLevel,"side");
private _conditions = M_CONFIG(getText,"WeaponShops", _myCopLevel,"conditions");
...
uiNamespace setVariable ["Weapon_Shop", _myCopLevel];
...

The ellipsis in the above lines of code simply recognize that there are lines of code above, between, and below the lines we're looking at. In the above block of code, we're replacing what previously took the variable from our addAction(I think), and are now passing our new variable into it. You're now done with the fn_weaponShopMenu.sqf file.

 

Step 3:

Within the Config_Weapons.sqf file, go to your cops shops, which if unedited will look like the following. 

Spoiler

//Cop Shops
    class cop_basic {
        name = "Altis Cop Shop";
        side = "cop";
        conditions = "";
        items[] = {
          ...
        };
        mags[] = {
          ...
        };
        accs[] = {
          ...
        };
    };

Then you'll want to edit it so that it looks like the following. The ellipsis in the above and below, simply recognize that there are lines of code, that we don't care about for this tutorial.

Spoiler

//Cop Shops
    class cop_level_one {
        name = "Cop Level One Shop";
        side = "cop";
        conditions = "";
        items[] = {
          ...
        };
        mags[] = {
          ...
        };
        accs[] = {
          ...
        };
    };
    class cop_level_two {
        name = "Cop Level Two Shop";
        side = "cop";
        conditions = "";
        items[] = {
          ...
        };
        mags[] = {
          ...
        };
        accs[] = {
          ...
        };
    };

Above you can see that we edited the class name to match the first case within the first file we edited. We also added a second class with a name, one number above the other, which matches the second case within the first file we edited. You're now done with the Config_Weapons.sqf file.

 

Step 4: 

Within the mission.sqm file, press Ctrl+F and paste the following into the Find field.

Spoiler

this addAction[localize""STR_MAR_Cop_Weapon_Shop"",life_fnc_weaponShopMenu,""cop_basic""];  this addAction[localize""STR_MAR_Patrol_Officer_Weapon_Shop"",life_fnc_weaponShopMenu,""cop_patrol""];  this addAction[localize""STR_MAR_Sergeant_Weapon_Shop"",life_fnc_weaponShopMenu,""cop_sergeant""];

In the top left of the Find window, click on the Replace tab, and in the new field called Replace With, you'll paste in the following.

Spoiler

this addAction[localize""STR_MAR_Cop_Weapon_Shop"",life_fnc_weaponShopMenu,""cop_level_one""];

This simply removes the old addActions from the cop NPC, and replaces them with a newer one, with our variable.

Closing:

Spoiler

That's basically it, you can go through and edit it, add more shops, they'll still all open with that one addAction(if you add them proprly, ask below if you need help), bla bla bla. If you have questions, suggestions for me on my post or code, or have any information that would be useful to me, or if you were simply able to make this work, please reply below! I hope this helped someone, and I'd be happy to help out further if I can. :)

Note: As pointed out by others, this tutorial is a little redundant, and if anything takes us back to how the shops used to work, wherein there were multiple classes, and multiple addActions. This was close to a previous way to have one addAction for multiple shops, although this is no longer needed as the current build can do this without the tutorial, but is nice for anyone who enjoys how the weapon shops were previously setup, I think the code was more appealing to read, and easier to edit, so here it is.

 

Edited by Blue
  • Like 1
Link to post
Share on other sites
6 hours ago, Wackbatt said:

I don't understand the purpose of this release. This functionality is already in the framework. 

I’m currently headed to class, I’ll make a video or take screenshots. As far as I am aware, this functionality is most certainly not in the base framework. It was not when I installed mine, or any previous versions, ever. Maybe I didn’t explain it right, and can add some clarification for you later on today.

Link to post
Share on other sites
20 minutes ago, Blue said:

I’m currently headed to class, I’ll make a video or take screenshots. As far as I am aware, this functionality is most certainly not in the base framework. It was not when I installed mine, or any previous versions, ever. Maybe I didn’t explain it right, and can add some clarification for you later on today.

The ability is present to have certain items available depending on the cop level

  • Thanks 1
Link to post
Share on other sites
3 hours ago, Deadlesszombie said:

The ability is present to have certain items available depending on the cop level

Of course, I never claimed it wasn’t, nor am I adding that or taking that away, maybe I explained it poorly. What this does, is it removes all weapon shop addActions except for one. All cop players regardless of cop level use the same, singular, addAction. When used, it grabs your cop level, and opens the corresponding shop. Instead of having two addActions for two ranks(or three for three, etc.), there’s one addAction for any number of ranks, and shops. 

In your Config_Weapons.sqf file, you can have any number of shops, so long as they have a case within the fn_weaponShopMenu.sqf. Instead of having to add an additional addAction to your init, you update their cop level on the database, they go and use the same addAction they’ve always used, and it'll open a new shop for them, even though you have not edited the addAction. If I was to NOT do what I've done, and I had three cop levels, and made a fourth, I would have to make a new shop, and also make a new addAction on my NPC, or crate, or whatever, for the player to be able to access their respective rank. If I did not add a new addAction, then the player would only see, and have access to old three shops.

I downloaded the 5.0.0 mission file when installing, this want not at all the way it worked, there were separate addActions for each different shop. If I’m still wrong, or it still sounds like I’m doing what’s already there, please tell me. I’ll go make a video right now, so it’s better understood, and we can see what it is.

I hope I’m not coming across as rude, because I'm genuinely confused as to what Wackbatt is saying, but when I’m told the functionality that I’ve added is already there, but I had to add it for it to be there, is confusing, and I don’t see how that can be claimed, from a logical standpoint. Something that works a certain way, and was edited to work your way, could not have always worked your way, as you had to edit it to do so. I assume I just suck at explaining stuff.

 

I'm making a video now, to better explain what this does, because I'm not a good teacher.

Edited by Blue
  • Like 1
Link to post
Share on other sites
16 minutes ago, Deadlesszombie said:

What I was talking about is this

91D8437D-772E-4C81-9632-7CBFE5F4A60D.thumb.png.396be51e6efa3873922a03552f2a7546.png

 

It it is one shop with everything in it 

Ahhh I see what you guys are talking about, I'm blind as hell. Well then yeah of course, this isn't much of a tutorial then. I have mine setup as the following, 

Spoiler
class cop_level_one {
		name = "Cadet Shop";
        side = "cop";
        conditions = "";
        items[] = {
            { "Binocular", "", 150, 75, "" },
            { "ItemGPS", "", 100, 50, "" },
            { "FirstAidKit", "", 150, 75, "" },
            { "NVGoggles", "", 2000, 1000, "" },
            { "hgun_P07_snds_F", $STR_W_items_StunPistol, 2000, 1000, "" },
            { "hgun_P07_F", "", 7500, 3750, "" },
            { "hgun_P07_khk_F", "", 7500, 3750, "" }
        };
        mags[] = {
            { "16Rnd_9x21_Mag", "", 125, 60, "" },
            { "30Rnd_9x21_Mag", "", 250, 125, "" }
        };
        accs[] = {
            { "acc_flashlight_pistol", "", 250, 125, "" }
        };
    };
	
	class cop_level_two {
		name = "Patrol Officer Shop";
        side = "cop";
        conditions = "";
        items[] = {
            { "Binocular", "", 150, 75, "" },
            { "ItemGPS", "", 100, 50, "" },
            { "FirstAidKit", "", 150, 75, "" },
            { "NVGoggles", "", 2000, 1000, "" },
            { "HandGrenade_Stone", $STR_W_items_Flashbang, 1700, 850, "" },
            { "hgun_P07_snds_F", $STR_W_items_StunPistol, 2000, 1000, "" },
            { "arifle_SDAR_F", $STR_W_items_TaserRifle, 20000, 10000, "" },
            { "hgun_P07_F", "", 7500, 3750, "" },
            { "hgun_P07_khk_F", "", 7500, 3750, "" },
            { "hgun_Pistol_heavy_01_F", "", 9500, 4750, "" },
            { "SMG_02_ACO_F", "", 30000, 15000, "" },
            { "arifle_MX_F", "", 35000, 17500, "" },
            { "hgun_ACPC2_F", "", 17500, 8750, "" },
            { "arifle_MXC_F", "", 30000, 15000, "" },
            { "srifle_DMR_07_blk_F", "", 32000, 16000, "" }
        };
        mags[] = {
            { "16Rnd_9x21_Mag", "", 125, 60, "" },
            { "20Rnd_556x45_UW_mag", $STR_W_mags_TaserRifle, 125, 60, "" },
            { "11Rnd_45ACP_Mag", "", 130, 65, "" },
            { "30Rnd_65x39_caseless_mag", "", 130, 65, "" },
            { "30Rnd_9x21_Mag", "", 250, 125, "" },
            { "9Rnd_45ACP_Mag", "", 200, 100, "" },
            { "20Rnd_650x39_Cased_Mag_F", "", 200, 100, "" }
        };
        accs[] = {
            { "muzzle_snds_L", "", 650, 325, "" },
            { "optic_MRD", "", 2750, 1375, "" },
            { "acc_flashlight_pistol", "", 250, 125, "" },
            { "acc_flashlight", "", 750, 375, "" },
            { "optic_Holosight", "", 1200, 600, "" },
            { "optic_Arco", "", 2500, 1250, "" },
            { "muzzle_snds_H", "", 2750, 1375, "" }
        };
    };

 

so that I can make each class a shop, and keep it "clean" I suppose. Guess this just made more sense to me than the way it was setup, especially since the devs left all the old addActions in the inits and what not, one spring cleaning lead to a remodel. There's really no point in the "tutorial" then, feel free to remove this post. :) Thanks for bringing it up guys!

 

Edited by Blue
Link to post
Share on other sites
1 hour ago, Blue said:

Ahhh I see what you guys are talking about, I'm blind as hell. Well then yeah of course, this isn't much of a tutorial then. I have mine setup as the following, 

  Reveal hidden contents

class cop_level_one {
		name = "Cadet Shop";
        side = "cop";
        conditions = "";
        items[] = {
            { "Binocular", "", 150, 75, "" },
            { "ItemGPS", "", 100, 50, "" },
            { "FirstAidKit", "", 150, 75, "" },
            { "NVGoggles", "", 2000, 1000, "" },
            { "hgun_P07_snds_F", $STR_W_items_StunPistol, 2000, 1000, "" },
            { "hgun_P07_F", "", 7500, 3750, "" },
            { "hgun_P07_khk_F", "", 7500, 3750, "" }
        };
        mags[] = {
            { "16Rnd_9x21_Mag", "", 125, 60, "" },
            { "30Rnd_9x21_Mag", "", 250, 125, "" }
        };
        accs[] = {
            { "acc_flashlight_pistol", "", 250, 125, "" }
        };
    };
	
	class cop_level_two {
		name = "Patrol Officer Shop";
        side = "cop";
        conditions = "";
        items[] = {
            { "Binocular", "", 150, 75, "" },
            { "ItemGPS", "", 100, 50, "" },
            { "FirstAidKit", "", 150, 75, "" },
            { "NVGoggles", "", 2000, 1000, "" },
            { "HandGrenade_Stone", $STR_W_items_Flashbang, 1700, 850, "" },
            { "hgun_P07_snds_F", $STR_W_items_StunPistol, 2000, 1000, "" },
            { "arifle_SDAR_F", $STR_W_items_TaserRifle, 20000, 10000, "" },
            { "hgun_P07_F", "", 7500, 3750, "" },
            { "hgun_P07_khk_F", "", 7500, 3750, "" },
            { "hgun_Pistol_heavy_01_F", "", 9500, 4750, "" },
            { "SMG_02_ACO_F", "", 30000, 15000, "" },
            { "arifle_MX_F", "", 35000, 17500, "" },
            { "hgun_ACPC2_F", "", 17500, 8750, "" },
            { "arifle_MXC_F", "", 30000, 15000, "" },
            { "srifle_DMR_07_blk_F", "", 32000, 16000, "" }
        };
        mags[] = {
            { "16Rnd_9x21_Mag", "", 125, 60, "" },
            { "20Rnd_556x45_UW_mag", $STR_W_mags_TaserRifle, 125, 60, "" },
            { "11Rnd_45ACP_Mag", "", 130, 65, "" },
            { "30Rnd_65x39_caseless_mag", "", 130, 65, "" },
            { "30Rnd_9x21_Mag", "", 250, 125, "" },
            { "9Rnd_45ACP_Mag", "", 200, 100, "" },
            { "20Rnd_650x39_Cased_Mag_F", "", 200, 100, "" }
        };
        accs[] = {
            { "muzzle_snds_L", "", 650, 325, "" },
            { "optic_MRD", "", 2750, 1375, "" },
            { "acc_flashlight_pistol", "", 250, 125, "" },
            { "acc_flashlight", "", 750, 375, "" },
            { "optic_Holosight", "", 1200, 600, "" },
            { "optic_Arco", "", 2500, 1250, "" },
            { "muzzle_snds_H", "", 2750, 1375, "" }
        };
    };

 

so that I can make each class a shop, and keep it "clean" I suppose. Guess this just made more sense to me than the way it was setup, especially since the devs left all the old addActions in the inits and what not, one spring cleaning lead to a remodel. There's really no point in the "tutorial" then, feel free to remove this post. :) Thanks for bringing it up guys!

 

You can keep it for those who still appreciate your work :)

Edited by Deadlesszombie
  • Thanks 1
Link to post
Share on other sites
11 minutes ago, Deadlesszombie said:

You can keep it for those who still appreciate your work :)

Sounds good to me! I have edited my original post, to not only correct a few things, but to forewarn others that it has been pointed out that while the tutorial is redundant based upon the current build, it can still work for those who wish to see the shop classes closely to what they previously were. 

Once again, thanks Deadlesszombie, and Wackbatt!

Edited by Blue
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.