geekm0nkey

New XM8 App coding?

186 posts in this topic

So it's no secret that I hate Exiles version of the Virtual Garage, so I'm sticking with ExAds. However I can't stand there being two apps for Virtual Garage, so let re-purpose that main VG app button. For this you will need to follow the first step in Spazz711 instructions. You're not creating an App button for this.

We will be creating an overwrite for ExileClient_gui_virtualGarageDialog_show and we'll be using the 3 original overwrites for ExAd:

Spoiler

//ExAd
ExileServer_system_territory_database_load = "ExAdClient\VirtualGarage\CustomCode\ExileServer_system_territory_database_load.sqf";
ExileClient_gui_virtualGarageDialog_show = "overwrites\ExileClient_gui_virtualGarageDialog_show.sqf";
ExileClient_gui_xm8_slide = "ExAdClient\XM8\CustomCode\ExileClient_gui_xm8_slide.sqf";
ExileClient_gui_xm8_show = "ExAdClient\XM8\CustomCode\ExileClient_gui_xm8_show.sqf";

Add this to your ExileClient_gui_virtualGarageDialog_show overwrite
 

Spoiler

private["_flag", "_buildRights", "_territoryLevel", "_maxNumberOfVehicles", "_control"];
disableSerialization;
try 
{
    if ((getNumber(missionConfigFile >> 'CfgVirtualGarage' >> 'enableVirtualGarage')) isEqualTo 0) then 
    {
        throw "This server has Virtual Garage disabled! Ask the server owner to enable it!";
    };
    if ((getNumber(missionConfigFile >> "CfgVirtualGarage" >> "canAccessGarageInCombat") isEqualTo 1) && {ExileClientPlayerIsInCombat}) then 
    {
        throw "You cannot access Virtual Garage while in combat!";    
    };
    _flag = player call ExileClient_util_world_getTerritoryAtPosition;
    if (isNull _flag) then 
    {
        throw "You must be in your territory in order to access Virtual Garage";
    };
    _buildRights = _flag getVariable ["ExileTerritoryBuildRights", []];
    if !((getPlayerUID player) in _buildRights) then 
    {
        throw "You do not have permission to access this territory's Virtual Garage";
    };
    _control = ['ExAd_VG', 0] call ExileClient_gui_xm8_slide;
}
catch 
{
    [_exception, 'Okay'] call ExileClient_gui_xm8_showWarning;
};
true

This setup still uses the Exile Config settings in your mission config minus the number of vehicles allowed. I left the other checks in for more customization options, so make sure you have a 1 next to enableVirtualGarage in your config or you'll get the first message.

Uh oh, when we click back on the VG screen it takes us back to ExtraApps. Lets fix that. Go to mission >> ExAdClient >> XM8 >> Apps >> VG and edit onLoad.sqf

Spoiler

Locate this line (should be line 28):
[_display,_slide,(["ExAd_VG","backButton"] call ExAd_fnc_getNextIDC),[27.6 * _pW, 17.7 * _pH, 6 * _pW, 1 * _pH],'["extraApps", 1] call ExileClient_gui_xm8_slide;',STR_ExAd_VG_APP_BTN_BACK] call ExAd_fnc_createButton;

And change it to this:
[_display,_slide,(["ExAd_VG","backButton"] call ExAd_fnc_getNextIDC),[27.6 * _pW, 17.7 * _pH, 6 * _pW, 1 * _pH],'["apps", 1] call ExileClient_gui_xm8_slide;',STR_ExAd_VG_APP_BTN_BACK] call ExAd_fnc_createButton;

If you've implemented Exiles VG then this may not work correctly. You'll need to edit your exile.ini and database to be compatible. Also there is a bug with vehicles previously in the database when updating to 1.0.4 just run this SQL query after updating and it will fix the issue:
 

Spoiler

UPDATE Vehicle SET deleted_at = NULL WHERE deleted_at IS NOT NULL AND territory_id IS NOT NULL

 

Edited by Beowulfv
  • Like 8

Share this post


Link to post
Share on other sites
Advertisement

Not sure why, but I guess when updating to Exile 1.0.4 it deleted all the vehicles in ExAds Virtual Garage. Never ran the SQL update, and it happened on both servers. Strange. Anyway, original post has been updated with the SQL query to fix the issue.

Share this post


Link to post
Share on other sites

Thought it is a wrong garbage collection...

[markDeleteOldVehicles]
SQL1_1 = UPDATE vehicle SET deleted_at = NOW() WHERE last_updated_at < DATE_SUB(NOW(), INTERVAL ? DAY) AND deleted_at IS NULL
Number Of Inputs = 1
SQL1_INPUTS = 1

Vehicles in the VG must not marked as deleted.

SQL1_1 = UPDATE vehicle SET deleted_at = NOW() WHERE last_updated_at < DATE_SUB(NOW(), INTERVAL ? DAY) AND deleted_at IS NULL AND territory_id IS NOT NULL

Perhaps this statement is better???

Edited by Capu

Share this post


Link to post
Share on other sites
18 minutes ago, Capu said:

Thought it was a wrong garbage collection...


[markDeleteOldVehicles]
SQL1_1 = UPDATE vehicle SET deleted_at = NOW() WHERE last_updated_at < DATE_SUB(NOW(), INTERVAL ? DAY) AND deleted_at IS NULL
Number Of Inputs = 1
SQL1_INPUTS = 1

Vehicles in the VG must not marked as deleted.


SQL1_1 = UPDATE vehicle SET deleted_at = NOW() WHERE last_updated_at < DATE_SUB(NOW(), INTERVAL ? DAY) AND deleted_at IS NULL AND territory_id IS NOT NULL

Perhaps this statement is better???

You are stating that you only want to remove vehicles inside a virtual garage with that statement. You only want to touch NULL values so you need to have it as:
 

SQL1_1 = UPDATE vehicle SET deleted_at = NOW() WHERE last_updated_at < DATE_SUB(NOW(), INTERVAL ? DAY) AND deleted_at IS NULL AND territory_id IS NULL

 

  • Like 2

Share this post


Link to post
Share on other sites

That's right... But i'm thinking that everyone who is updating 1.0.3 -> 1.0.4 take the new exile.ini and don't do the edits that are in the ExAd master... So most of the people will get the problem that vehicles suddenly disappear from VG...

Share this post


Link to post
Share on other sites
1 hour ago, aussie battler said:

@Beowulfv Nice work, having two button was annoying.

Did you have a backup of the database? You could probably just pull out all the vehicles in your save & paste them back into the current database.

People who have already updated to 1.0.4 should only need to run this query:

Spoiler

ALTER TABLE `vehicle` DROP `nickname`;

But even having that in the database shouldn't cause any issues. This is the exile.ini if needed:
 

Spoiler

;1. Find following sections and replace the commented lines;

[loadVehicleIdPage]
SQL1_1 = SELECT id FROM vehicle WHERE deleted_at IS NULL AND territory_id IS NULL LIMIT ?,?
Number Of Inputs = 2
SQL1_INPUTS = 1,2
OUTPUT = 1    

; Removes vehicles that were not used within ? days
[deleteOldVehicles]
SQL1_1 = DELETE FROM vehicle WHERE territory_id IS NULL AND deleted_at < DATE_SUB(NOW(), INTERVAL ? DAY)
Number Of Inputs = 1
SQL1_INPUTS = 1

; Marks for deletion vehicles that were not used within ? days
[markDeleteOldVehicles]
SQL1_1 = UPDATE vehicle SET deleted_at = NOW() WHERE last_updated_at < DATE_SUB(NOW(), INTERVAL ? DAY) AND deleted_at IS NULL AND territory_id IS NULL
Number Of Inputs = 1
SQL1_INPUTS = 1

;2. Add all below in the end of the file.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Virtual Garage related queries | ADDED BY [ExAd]Jan
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[loadTerritoryVehicles]
SQL1_1 = SELECT id, class FROM vehicle WHERE territory_id = ?
Number Of Inputs = 1
SQL1_INPUTS = 1
OUTPUT = 1,2-STRING

[loadVehFromVG]
SQL1_1 = UPDATE vehicle SET territory_id = NULL WHERE id = ?
Number Of Inputs = 1
SQL1_INPUTS = 1

[loadVehToVG]
SQL1_1 = UPDATE vehicle SET territory_id = ? WHERE id = ?
Number Of Inputs = 2
SQL1_INPUTS = 1,2

And remove these:
 

Spoiler

[storeVehicle]
SQL1_1 = UPDATE vehicle SET territory_id = ?, nickname = ?, last_updated_at = NOW() WHERE id = ?
Number of Inputs = 3
SQL1_INPUTS = 1,2,3

[retrieveVehicle]
SQL1_1 = UPDATE vehicle SET territory_id = NULL, last_updated_at = NOW(), nickname = '' WHERE id = ?
Number of Inputs = 1
SQL1_INPUTS = 1

[confirmVehicleOwnership]
SQL1_1 = SELECT id, territory_id FROM vehicle WHERE nickname = ?
Number of Inputs = 1
SQL1_INPUTS = 1
OUTPUT = 1,2

[loadTerritoryVirtualGarage]
SQL1_1 = SELECT class, nickname FROM vehicle WHERE territory_id = ?
Number of Inputs = 1
SQL1_INPUTS = 1
OUTPUT = 1-STRING,2-STRING

 

Edited by Beowulfv
  • Like 2

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.