Jump to content
hoverguy

[Release] Simple Weapon Shop System

Recommended Posts

Looking to use this system in an upcoming campaign, but I don't know how the persistent saving is called. I'd like to use the profle save type since I don't have to fiddle around with an external database.

 

Is there a function I can call manually to save Simple Shops stuff?

 

EDIT: Specifically looking to ensure that bought vehicles that aren't stored in a garage are saved where they are currently sitting in the world.

 

Edited by Robert Tyburne
Clarification

Share this post


Link to post
Share on other sites

Hi @Robert Tyburne

 

On 12/20/2019 at 5:51 PM, Robert Tyburne said:

EDIT: Specifically looking to ensure that bought vehicles that aren't stored in a garage are saved where they are currently sitting in the world.

 

A little bit of explanation:

 

Player buys a vehicle

- Vehicle is spawned

- A variable is set on that vehicle and is then broadcasted, that variable contains the owner steam64 ID and a random number that serves as a "plate" number (unique identification)

- Vehicle is inserted into database or saved in server's profile and active variable is set to 1

 

Player opens garage

- Server searches for vehicles owned by that player (in profile or in db according to savingMethod), finds them and returns those with active var = 0

- Dialog displays available vehicles

 

Player stores a vehicle

- Vehicle is deleted from world

- The active variable is set to 0 (in profile or in db)

 

Player disconnects (only works if storeVehiclesOnDisconnect is set to true in HG_Config.h)

- Server scans all vehicles and filter out those that belong to the player (with the help of the variable set on it)

- Destroyed vehicles are removed from the result

- Vehicles are deleted

- The active variable is set to 0 (in profile or in db) for every vehicle

 

There is also this parameter resetGaragesOnServerStart that

- When set to false, will switch the active status on vehicles to 0, meaning that they're available in the garage again

- When set to true, will DELETE every vehicles (from profile or from db), meaning that garage will be empty for everyone

 

So to answer your concern, storeVehiclesOnDisconnect is set to true by default meaning that you don't have to worry about vehicles not being saved because they're removed from the world as explained above.

If you set both storeVehiclesOnDisconnect and resetGaragesOnServerStart to false, all the vehicles will stay available in the world when the owner disconnects and available in your garage once server restarts.

The downside with the second method is: Let's say you disconnect, one of your vehicle is destroyed by another player, that vehicle will be available again when server restarts... simply because there is no thread that monitors what happens to the vehicle when you're not in game.

 

Thanks for using SimpleShops!

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Gotcha, so all the saving is actually being triggered specifically on player disconnect. Is there a way to call those saves through say an addaction script instead? I have a save script that's calling the particular save functions of two other systems that I'm using, and being able to save Simple Shops vehicles through that same way would make for better flow to ensure all the things that need saving are synced in some way. Ideally without using the garage at all, as I'd like to physically limit the amount of space in the motorpool.

 

For instance, if players clear a place then disconnect but forget to hit the save button back at base, and the server restarts, I wouldn't want their vehicles to stay in what would be an active AO again.

Share this post


Link to post
Share on other sites

I've been struggling with this for a while. How do I spawn objects to 70 meters? The mission is based on a carrier. Cars spawn on top but the aircraft spawn below it. 

Share this post


Link to post
Share on other sites
On 5/22/2019 at 8:42 AM, hoverguy said:

Hello @C.Hall

 

I presume that you're using profile namespace as saving method and that the mission is not hosted in that case this code will reset saved stats for you:


uid = getPlayerUID player;
["HG_Cash","HG_Bank","HG_XP","HG_Kills","HG_Gear","HG_Garage"] apply {profileNamespace setVariable [format["%1_%2",_x,uid],nil]; saveProfileNamespace;};

Load up the editor, open the debug console and copy/paste this code then exec local.

 

Thank you so much for this. Is there a way to clear off everyone's progress in one go? We've been testing the mission off and on and I can't remember everyone who had helped me test to get their UIDs.

 

Is the progress tied to the mission name? Could I just rename the mission for everyone's progress to start anew?

Share this post


Link to post
Share on other sites

Hello @NikoWZRD

 

On 1/14/2020 at 11:36 AM, NikoWZRD said:

 

Thank you so much for this. Is there a way to clear off everyone's progress in one go? We've been testing the mission off and on and I can't remember everyone who had helped me test to get their UIDs.

 

Is the progress tied to the mission name? Could I just rename the mission for everyone's progress to start anew?

 

The progress is saved in server's profile (if savingMethod is set to "Profile" in HG_Config.h), the only way to reset it is to either use that code above or delete the <name>.vars.Arma3Profile file

 

To avoid the hassle you could just setup a database, this way you can reset everything in one go... or nil out variables on server start like so (only works with "Profile" as savingMethod):

 

if(!isNil {parsingNamespace getVariable "HG_Profile"}) then
{
    private["_vars","_strs","_str"];

    _vars = parsingNamespace getVariable "HG_Profile";
    _strs = ["hg_cash","hg_bank","hg_xp","hg_kills","hg_gear","hg_garage"];

    {
        _str = _x;

        {
            if([_str,_x,false] call BIS_fnc_inString) then
            {
                profileNamespace setVariable [_x,nil];
                saveProfileNamespace;
            };
        } forEach _vars;
    } forEach _strs;
};

Put that code at the end of HG\Setup\fn_serverInitialization.sqf

 

On large scale missions I recommend using a database though...

  • Like 1

Share this post


Link to post
Share on other sites
41 minutes ago, hoverguy said:

Hello @NikoWZRD

 

 

The progress is saved in server's profile (if savingMethod is set to "Profile" in HG_Config.h), the only way to reset it is to either use that code above or delete the <name>.vars.Arma3Profile file

 

To avoid the hassle you could just setup a database, this way you can reset everything in one go... or nil out variables on server start like so (only works with "Profile" as savingMethod):

 


if(!isNil {parsingNamespace getVariable "HG_Profile"}) then
{
    private["_vars","_strs","_str"];

    _vars = parsingNamespace getVariable "HG_Profile";
    _strs = ["hg_cash","hg_bank","hg_xp","hg_kills","hg_gear","hg_garage"];

    {
        _str = _x;

        {
            if([_str,_x,false] call BIS_fnc_inString) then
            {
                profileNamespace setVariable [_x,nil];
                saveProfileNamespace;
            };
        } forEach _vars;
    } forEach _strs;
};

Put that code at the end of HG\Setup\fn_serverInitialization.sqf

 

On large scale missions I recommend using a database though...

 

This is great, I really appreciate your super fast reply! This isn't a large scale mission, probably only have about 8-12 people total. It's been in testing for the longest time and we're about to go live on Saturday, so I just wanted all the testers to start clean.

 

Does the inventory/garage/etc carry into other missions using the same scripts then? That could be very interesting to play with.

Share this post


Link to post
Share on other sites
40 minutes ago, NikoWZRD said:

Does the inventory/garage/etc carry into other missions using the same scripts then? That could be very interesting to play with.

 

The answer is yes as long as the same profile is used by the server

  • Like 1

Share this post


Link to post
Share on other sites
On 1/15/2020 at 4:41 PM, hoverguy said:

 

The answer is yes as long as the same profile is used by the server

 

On 1/15/2020 at 3:15 PM, hoverguy said:

Hello @NikoWZRD

 

 

The progress is saved in server's profile (if savingMethod is set to "Profile" in HG_Config.h), the only way to reset it is to either use that code above or delete the <name>.vars.Arma3Profile file

 

To avoid the hassle you could just setup a database, this way you can reset everything in one go... or nil out variables on server start like so (only works with "Profile" as savingMethod):

 


if(!isNil {parsingNamespace getVariable "HG_Profile"}) then
{
    private["_vars","_strs","_str"];

    _vars = parsingNamespace getVariable "HG_Profile";
    _strs = ["hg_cash","hg_bank","hg_xp","hg_kills","hg_gear","hg_garage"];

    {
        _str = _x;

        {
            if([_str,_x,false] call BIS_fnc_inString) then
            {
                profileNamespace setVariable [_x,nil];
                saveProfileNamespace;
            };
        } forEach _vars;
    } forEach _strs;
};

Put that code at the end of HG\Setup\fn_serverInitialization.sqf

 

On large scale missions I recommend using a database though...

 

Heya, sorry to keep bugging. I used the above script but I think it actually forced me to spawn naked and with $0, instead of the starter kit & starter money. Did I do something wrong, is there a way around this or should I just find the profiles and delete them?

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

×