Jump to content

Custom Doner Loadout SQL


rbell2473

Recommended Posts

i got the table created just need help with the trigger

 

CREATE TABLE `cust_loadout` (
	`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
	`inventory` VARCHAR(2048) NOT NULL,
	`backpack` VARCHAR(2048) NOT NULL,
	`model` VARCHAR(100) NULL DEFAULT NULL,
	`description` VARCHAR(1024) NULL DEFAULT NULL,
	PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=4;
Link to comment
Share on other sites

I was hoping to get something like this working, for loyal/frequent players to choose from a few starter packs. Nothing to substantial, mostly just a different civilian starting skin. The problem with epoch comes with the Male / Female choice, if you remove this it is very easy to set up a few custom loadouts for different player groups on your server with a program like Heidi or Navicat.

Link to comment
Share on other sites

I was hoping to get something like this working, for loyal/frequent players to choose from a few starter packs. Nothing to substantial, mostly just a different civilian starting skin. The problem with epoch comes with the Male / Female choice, if you remove this it is very easy to set up a few custom loadouts for different player groups on your server with a program like Heidi or Navicat.

i have no prob removing the Male / Female as long as i can have custom loadouts

 

could you help me with this?

thanks

Link to comment
Share on other sites

Look at the MySQL docs for creating triggers, could probably do it via a BEFORE INSERT trigger on character data. Lookup their donation loadout and set NEW.[inventory|Backpack|Model] on the new record. I'm sure there are plenty of examples out there.

i have looked all over for some examples and i am unable to find any for this

Link to comment
Share on other sites

i have looked all over for some examples and i am unable to find any for this

 

Well, google returns a fair few results for this sort of stuff, and it doesn't hurt to tinker!

 

You could try something like this, although I'm not 100% on how DayZ "creates" the new character:

DELIMITER $$

CREATE TRIGGER custom_loadout BEFORE INSERT ON character_data
FOR EACH ROW
BEGIN
    DECLARE _count INT;
    DECLARE _inventory LONGTEXT;
    DECLARE _backpack LONGTEXT;
    DECLARE _model VARCHAR(50);

    SELECT COUNT(*), Inventory, Backpack, Model
    INTO _count, _inventory, _backpack, _model
    FROM custom_loadouts
    WHERE custom_loadouts.PlayerUID=NEW.PlayerUID;

    IF _count = 1 THEN
      SET NEW.Backpack = _backpack;
      SET NEW.Inventory = _inventory;
      SET NEW.Model = _model;
    END IF;
END;$$

DELIMITER ;

You will need a table with PlayerUID, Backpack, Inventory, Model fields as a bare minimum - where the PlayerUID equals that of the player. Probably best to set a unique constraint on the PlayerUID column too.

Link to comment
Share on other sites

I get this error when running
 
 

/* SQL Error (1235): This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table' */


 
i have created the custom_loadouts table with
 
PlayerUID - inventory - backpack - model - description
 
and thanks for your help

Link to comment
Share on other sites

  • 5 months later...

I know this topic is kinda old but I was trying to do something similar and came up with a couple possible solutions, but havent been able to fully test them yet. I came up with slightly different method for my trigger but it seems to work fine in testing with basic INSERTs, but I have not had a chance to test it on a live server.  Maybe this will help someone though and they can test to see if it works and post back:

-- Create table for storing custom loadout/spawn/skin data
CREATE TABLE `character_custom` (
  `PlayerName` varchar(64) NOT NULL DEFAULT '',
  `PlayerUID` varchar(20) NOT NULL,
  `Inventory` longtext NOT NULL DEFAULT '[["ItemFlashlight"],["ItemBandage","ItemPainkiller"]]',
  `Backpack` longtext NOT NULL DEFAULT '["DZ_Patrol_Pack_EP1",[[],[]],[[],[]]]',
  `Worldspace` varchar(128) NOT NULL DEFAULT '[]',
  `CurrentState` varchar(200) NOT NULL DEFAULT '[]',
  `Model` varchar(50) NOT NULL DEFAULT 'Survivor2_DZ',
  PRIMARY KEY (`PlayerUID`)
) ENGINE=InnoDB;

-- Add a test entry for Mr Guy PlayerUID 12345678
INSERT INTO `character_custom` VALUES ('Mr Guy', '12345678', '[[\"M4A1_AIM_SD_camo\",\"Colt1911\",\"NVGoggles\",\"ItemCompass\",\"ItemMatchbox\",\"ItemKnife\",\"ItemFlashlight\",\"ItemWatch\",\"ItemHatchet\",\"ItemEtool\",\"ItemToolbox\",\"ItemGPS\",\"Binocular_Vector\",\"MeleeFlashlightRed\"],[\"ItemBloodbag\",\"ItemMorphine\",\"30Rnd_556x45_StanagSD\",\"30Rnd_556x45_StanagSD\",\"30Rnd_556x45_StanagSD\",\"30Rnd_556x45_StanagSD\",\"30Rnd_556x45_StanagSD\",\"30Rnd_556x45_StanagSD\",\"FoodSteakCooked\",\"ItemWaterbottle\",\"ItemBandage\",\"ItemBandage\",\"ItemBandage\",\"ItemBandage\",\"7Rnd_45ACP_1911\",\"7Rnd_45ACP_1911\",\"7Rnd_45ACP_1911\",\"7Rnd_45ACP_1911\"]]', '[\"DZ_Backpack_EP1\",[[\"M4SPR\"],[1]],[[\"ItemBloodbag\",\"HandGrenade_West\",\"ItemWaterbottle\",\"FoodSteakCooked\"],[1,5,1,1]]]', '[]', '[]', 'Survivor2_DZ');

-- Create trigger to check for VIP before INSERT on character_data (`dayz_epoch` is the name of the database)
CREATE TRIGGER `dayz_epoch`.`checkVIP`
    BEFORE INSERT ON `character_data` FOR EACH ROW
    BEGIN
        IF NEW.PlayerUID IN (SELECT PlayerUID FROM `character_custom`)
        THEN
            SET NEW.Inventory = (SELECT cc.Inventory FROM `character_custom` cc WHERE cc.PlayerUID = NEW.PlayerUID),
                NEW.Backpack = (SELECT cc.Backpack FROM `character_custom` cc WHERE cc.PlayerUID = NEW.PlayerUID),
                NEW.Worldspace = (SELECT cc.Worldspace FROM `character_custom` cc WHERE cc.PlayerUID = NEW.PlayerUID),
                NEW.CurrentState = (SELECT cc.Backpack FROM `character_custom` cc WHERE cc.PlayerUID = NEW.PlayerUID),
                NEW.Model = (SELECT cc.Model FROM `character_custom` cc WHERE cc.PlayerUID = NEW.PlayerUID);
        END IF;
    END;

I know the trigger syntax probly isn't the best and some SQL gurus could write it waaay more efficient, but I ran some tests just through MySQL console and there wasn't really any significant performance hit on the time it took to do INSERTs, but again this was only a test environment.

 

However, I'm wondering if what axeman said is true, and the data the trigger changes would just be overwritten anyways...if so then that won't work in a live server.  But you could do a different trigger for BEFORE UPDATE, etc, etc.  If that's the case, and I can't find another way to do it, I may try making a BEFORE UPDATE trigger and see if that works...

Link to comment
Share on other sites

couldn't u people to a simple script like this 

//Admin Loadout
if ((getPlayerUID player) in ["150456582","238930182", "238354566", "142451590"]) then {  //Admins: Nobody, Somebody
	DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","ItemMorphine","ItemPainkiller","ItemBloodbag","ItemWaterbottleBoiled","ItemWaterbottleBoiled","FoodSteakCooked","20Rnd_B_AA12_74Slug","20Rnd_B_AA12_Pellets","20Rnd_B_AA12_Pellets","ItemGoldBar10oz"];
	DefaultWeapons = ["glock17_EP1","AA12_PMC","Binocular_Vector","NVGoggles","ItemMap","ItemCompass","ItemGPS","ItemWatch","ItemKnife","Itemtoolbox","ItemCrowbar","Itemetool","ItemHatchet"];
	DefaultBackpack = "DZ_LargeGunBag_EP1";
	DefaultBackpackWeapon = "";
	};

Link to comment
Share on other sites

 

couldn't u people to a simple script like this 

//Admin Loadout
if ((getPlayerUID player) in ["150456582","238930182", "238354566", "142451590"]) then {  //Admins: Nobody, Somebody
	DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","ItemMorphine","ItemPainkiller","ItemBloodbag","ItemWaterbottleBoiled","ItemWaterbottleBoiled","FoodSteakCooked","20Rnd_B_AA12_74Slug","20Rnd_B_AA12_Pellets","20Rnd_B_AA12_Pellets","ItemGoldBar10oz"];
	DefaultWeapons = ["glock17_EP1","AA12_PMC","Binocular_Vector","NVGoggles","ItemMap","ItemCompass","ItemGPS","ItemWatch","ItemKnife","Itemtoolbox","ItemCrowbar","Itemetool","ItemHatchet"];
	DefaultBackpack = "DZ_LargeGunBag_EP1";
	DefaultBackpackWeapon = "";
	};

 

Here's the problem.  On my server we have a donor gear management system (DGMS).  Players can make changes to their gear real time and see the changes on their next death.  Players pick which primary, secondary, skin, and backpack they want to spawn with.

 

We limit the frequency of gear changes to 12 hours however we want to retain instant gear changes.

 

I don't have the time to manually edit SQF files, sure it could be automated but it would be very dirty and require a restart for changes to take effect.

 

we wound up using a 3rd party MySQL wrapper for arma2.

Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...