Jump to content

[HowTo] Redis DB Trader Cleanup


Brunz

Recommended Posts

any ideas how to fix?

Please post content of your *.CMD which you try to run. And screen or list of content files in directory DB.

And check your redis-server.exe version, it must be newer then 2.6 but I hope it is.

Link to comment
Share on other sites

  • 2 weeks later...

this one from the first post

 

redis-cli -h 127.0.0.1 -p 2456 -a mypass -n 0 --eval clean_ai_items.lua 

You are using the same port from Brunz example?

You can't use the same port, probably your port is not same like example from first post. Default port is 6379 (see your EpochServer.ini)

Copy   clean_ai_items.lua    file to DB directory and then create in DB directory file    clean_ai_items.CMD    containing this(without IP and PORT, yes it works but only if IP and PORT is set to default for Redis 127.0.0.1:6379 in epochserver.ini):

 

@echo off

redis-cli -a YOURPASSWORD -n 0 --eval clean_ai_items.lua

exit

 

Simply run cmd file and i hope it will working

PS: As you know, yourpassword is located in your EpochServer.ini too.

Link to comment
Share on other sites

Any idea why i'm getting (Interger) 5 , I have changed the instance to NA123 and have the correct IP, port & password. I can also connect with redis desktop

 

See my previous post. You may try if it will working. Backup your DB before.

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for this, it took some digging but i got it to work

 

hopefully this helps some others

 

first off, i ended up getting the redis-cli at

https://msopentech.com/opentech-projects/redis/ downloaded the zip and copied the redis.cli.exe to my DB folder

 

then i created

the 3 lua

if using default epochserver.ini

 

InstanceID = NA123

then use the following for each file:

 

clean_ai_items.lua

local count = 0
local valuelist = redis.call('keys', 'AI_ITEMS:NA123:*')
if valuelist then
    for i = 1, #valuelist do
        
		--Delete
		redis.call('del', valuelist[i])

		--Set ( Custom Trader loadouts can be set here)
	        --redis.call('set', valuelist[i], '[[],[]]')

		count = count + 1
       
    end
end
return count

 

clean_vehicles.lua

local count = 0
local valuelist = redis.call('keys', 'Vehicle:NA123:*')
local valueitem
if valuelist then
    for i = 1, #valuelist do
		
                --Purge all vehicles
                count = count + 1
                redis.call('del', valuelist[i]) 

		--Fancy Stuff can go here?
		--valueitem = redis.call('get',valuelist[i])
				
                --if valueitem == '[]' then 
		--  redis.call('del', valuelist[i]) 
		--  count = count + 1
		--end	
        
    end
end
return count

 

clean_sold_vehicles_only.lua

local VEHICLE_ARRAY =	{"C_Offroad_01_EPOCH","C_Quadbike_01_EPOCH","C_Hatchback_01_EPOCH","C_Hatchback_02_EPOCH","C_SUV_01_EPOCH","C_Rubberboat_EPOCH",
				 "C_Rubberboat_02_EPOCH","C_Rubberboat_03_EPOCH","C_Rubberboat_04_EPOCH","C_Van_01_box_EPOCH","C_Van_01_transport_EPOCH","C_Boat_Civil_01_EPOCH",
				 "C_Boat_Civil_01_police_EPOCH","C_Boat_Civil_01_rescue_EPOCH","B_Heli_Light_01_EPOCH","B_SDV_01_EPOCH","B_MRAP_01_EPOCH",
				 "B_Truck_01_transport_EPOCH","B_Truck_01_covered_EPOCH","B_Truck_01_box_EPOCH","O_Truck_02_covered_EPOCH","O_Truck_02_transport_EPOCH",
				 "O_Truck_03_covered_EPOCH","O_Truck_02_box_EPOCH","I_Heli_light_03_unarmed_EPOCH","O_Heli_Light_02_unarmed_EPOCH","I_Heli_Transport_02_EPOCH",
				 "O_Heli_Transport_04_EPOCH","O_Heli_Transport_04_bench_EPOCH","O_Heli_Transport_04_box_EPOCH","O_Heli_Transport_04_covered_EPOCH",
				 "B_Heli_Transport_03_unarmed_EPOCH","K01","K02","K03","K04","B_G_Offroad_01_F","O_MRAP_02_F","I_MRAP_03_F","O_G_Offroad_01_F",
				 "I_G_Offroad_01_F","I_G_VAN_01_transport_F"}
	
local count = 0
local valuelist = redis.call('keys', 'AI_ITEMS:NA123:*')
local valueitem
if valuelist then
    for i = 1, #valuelist do
		
		--Clean Vehicles which have been sold
		valueitem = redis.call('get',valuelist[i])
		
		for v = 1, #VEHICLE_ARRAY do
		
			valueitem = string.gsub(valueitem, VEHICLE_ARRAY[v], "EpochRadio0")		
		
		end
		
			  redis.call('set', valuelist[i], valueitem)
			  count = count + 1
		
        
    end
end
return count

 

Now I made 3 seperate batch files

cleanai.bat

@echo off

echo Now Starting purge of AI Items
redis-cli -h 127.0.0.1 -p 6379 -a mypass -n 0 --eval clean_ai_items.lua
timeout 10
echo Purgecomplete
timeout 3
exit 

 

soldvehicles.bat

@echo off

echo Now Starting purge of Spawned Vehicles
redis-cli -h 127.0.0.1 -p 6379 -a mypass -n 0 --eval clean_sold_vehicles_only.lua
timeout 10
echo Purged
timeout 3
exit 

spawnedvehicles.bat

@echo off

echo Now Starting purge of Spawned Vehicles
redis-cli -h 127.0.0.1 -p 6379 -a mypass -n 0 --eval clean_vehicles.lua
timeout 10
echo Purged
timeout 3
exit 

with the last batch file, it will delete the vehicle key from the db. once you rejoin the server it will regenerate the db key and populate with spawned vehicles based on what you have in your epochconfig file.

Link to comment
Share on other sites

  • 2 weeks later...

You are using the same port from Brunz example?

You can't use the same port, probably your port is not same like example from first post. Default port is 6379 (see your EpochServer.ini)

Copy   clean_ai_items.lua    file to DB directory and then create in DB directory file    clean_ai_items.CMD    containing this(without IP and PORT, yes it works but only if IP and PORT is set to default for Redis 127.0.0.1:6379 in epochserver.ini):

 

@echo off

redis-cli -a YOURPASSWORD -n 0 --eval clean_ai_items.lua

exit

 

Simply run cmd file and i hope it will working

PS: As you know, yourpassword is located in your EpochServer.ini too.

yes my ip and password are as in the ini ive changed-n 0 to -n 1 for my Bornholm server I just used that example as obviously im not posting my ip and redis password

 

I had a thought and ran redis-cli --help

 

in the list of acceptable commands --eval was not listed

Link to comment
Share on other sites

correct me if wrong to add items to the traders do i use this in clean_ai_items.lua

 

redis.call('set', valuelist, '[[],[]]')

 

like this?

 

redis.call('set', valuelist, '[["ItemSodaBurst", "meatballs_epoch", "MortarBucket", "CinderBlocks"],[2,3,4,1]]')

Link to comment
Share on other sites

yes if you want to have specific items in each trader you can do it this way

local valuelist = redis.call('keys', 'AI_ITEMS:NA123:*')
if valuelist then
    for i = 1, #valuelist do

	        redis.call('set', valuelist[i], '[[],[]]')

		count = count + 1
       
    end
end
return count

change the * to the specific ai key

 

so if you use say redis desktop manager you can see what keys are there,
and you will see things like

 

AI_ITEMS:NA123:0

AI_ITEMS:NA123:1

AI_ITEMS:NA123:2

AI_ITEMS:NA123:3

etc

 

the other way is to edit your epochconfig.hpp

 

and look for

//traders

 

and you can edit your list of items here.

though doing it this way every static trader will contain these items.

 

*Note: if you have forcestatictraders=false  then I found this function does not work. as the traders move around the map, go home for the night like a job.

 

Here is my traders section of my config.

// Traders
taxRate = 0.1; // controls the price increase for purchases
starterTraderItems[] = { 
{ 
"Hatchet",
"16Rnd_9x21_Mag",
"HandGrenade",
"30Rnd_9x21_Mag",
"6Rnd_45ACP_Cylinder",
"20Rnd_556x45_UW_mag",
"5Rnd_rollins_mag",
"9rnd_45X88_magazine",
"optic_Holosight_smg",
"30Rnd_65x39_caseless_green",
"20Rnd_762x51_Mag",
"muzzle_snds_H",
"5Rnd_127x108_APDS_Mag",
"arifle_Mk20C_plain_F",
"ChainSaw",
"30Rnd_65x39_caseless_mag_Tracer",
"30Rnd_65x39_caseless_mag",
"muzzle_snds_M",
"muzzle_snds_B",
"C_Van_01_box_EPOCH",
"honey_epoch",
"30Rnd_556x45_Stanag",
"30Rnd_762x39_Mag",
"11Rnd_45ACP_Mag",
"optic_Holosight",
"arifle_MX_F",
"200Rnd_65x39_cased_Box",
"LMG_Mk200_F",
"Binocular",
"arifle_Mk20_plain_F",
"H_14_EPOCH",
"optic_Aco_smg",
"7Rnd_408_Mag",
"200Rnd_556x45_M249",
"9Rnd_45ACP_Mag",
"30Rnd_45ACP_Mag_SMG_01",
"V_4_EPOCH",
"V_16_EPOCH",
"hgun_PDW2000_F",
"jerrycan_epoch",
"100Rnd_65x39_caseless_mag",
"hgun_P07_F",
"NVG_EPOCH",
"MiniGrenade",
"CircuitParts",
"optic_Yorris",
"10Rnd_762x51_Mag",
"5Rnd_127x108_Mag",
"6Rnd_GreenSignal_F",
"hgun_Pistol_Signal_F",
"SmokeShell","optic_Aco",
"hgun_Pistol_heavy_01_F",
"arifle_MXC_F",
"hgun_Rook40_F",
"M14Grn_EPOCH",
"SmokeShellPurple",
"muzzle_snds_H_MG",
"acc_flashlight",
"m249Tan_EPOCH",
"SMG_02_F",
"m249_EPOCH",
"200Rnd_65x39_cased_Box_Tracer",
"30Rnd_556x45_Stanag_Tracer_Yellow",
"optic_DMS",
"acc_pointer_IR",
"ItemSodaBurst",
"meatballs_epoch",
"MortarBucket",
"CinderBlocks",
"VehicleRepair",
"CircuitParts",
"ItemCorrugated",
"PartPlankPack",
"ItemRock",
"ItemRope",
"ItemStick"},{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}
}; // Starter Items for fresh spawned trader first array is classnames second is quantity.
NPCSlotsLimit = 3; // Max number of traders static or dynamic. Warning! Higher the number lower performance.
forceStaticTraders = true; // disables traders moving from work to home

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 7 months later...

One thing i would like to know if possible, is there a way to only clean those vehicles which are not claimed by a player? when i use the spawned vehicles script it deletes every vehicle off the server. What im trying to achieve is to delete spawned vehicles on reboot, but not players vehicles. Would be so much easier if this used mysql database instead of Redis.

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...