Brunz Posted February 2, 2015 Report Share Posted February 2, 2015 Hi, I am going to post some scripts which are for Redis DB to solve the following problems. 1. Vehicles Stuck in Traders causing low vehicle count on map2. Traders who are way overstocked3. Reset all vehicles back to random pos Important Information before starting1. Shutdown Arma 3 Server2. Shutdown Redis3. Backup you DB, then back it up again4. Understand that you could break your db if you mess up, refer to step 3. PrerequisitesDownload redis-cli.exe - https://msopentech.com/opentech-projects/redis/ Purge Traders Itemsclean_ai_items.lua Reveal hidden contents local count = 0 local valuelist = redis.call('keys', 'AI_ITEMS:1:*') 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 countPurge Vehicle Spawns ( reset all vehicles and contents )clean_vehicles.lua Reveal hidden contents local count = 0 local valuelist = redis.call('keys', 'Vehicle:1:*') 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 Replace Traders Items - Vehicles Only, will replace with specified itemclean_sold_vehicles_only.lua Reveal hidden contents 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:1:*') 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 How to Run 1. Ensure you have taken backups2. Shutdown Arma 3 Server3. Startup REDIS DB4. Create file above "clean_ai_items.lua" in same directory4. In the directory where redis-cli.exe is located open a command prompt ( SHIFT + RIGHT CICK --> Open Command WIndows here)5. Execute below command in command prompt changing inputs to suit your environment, if your unsure what the below flags are run a redis-cli --help for info.redis-cli -h 127.0.0.1 -p 2456 -a mypass -n 0 --eval clean_ai_items.lua6. You should get a count outputted of how many traders were purged of there items7. The changes should save eventually but to do a manual save run the followingredis-cli -h 127.0.0.1 -p 2456 -a mypass -n 0 127.0.0.1:2456> save OK 127.0.0.1:2456> shutdown not connected>8. I recommend taking another db backup9. Startup DB 10. Startup Arma 3 Server11. Enjoy Clean Traders and freed up vehicles Special NotesIf you want to get fancy and do preloaded traders then you can use the commented section in the clean_ai_items.lua file matrixmark, mgm, happydayz and 1 other 4 Link to comment Share on other sites More sharing options...
Gr8 Posted February 8, 2015 Report Share Posted February 8, 2015 Nice ! Thanks For sharing Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted February 9, 2015 Report Share Posted February 9, 2015 Does this wipe the traders every time it is run? Link to comment Share on other sites More sharing options...
Gr8 Posted February 9, 2015 Report Share Posted February 9, 2015 On 2/9/2015 at 1:08 AM, BetterDeadThanZed said: Does this wipe the traders every time it is run? Yes, It will wipe everything on a trader once its executed. Not a thing i would ever do. But just an example you can execute when needed Link to comment Share on other sites More sharing options...
ulli_123 Posted February 10, 2015 Report Share Posted February 10, 2015 When I call the clean_ai_items.lua comes only <integer> 0 Link to comment Share on other sites More sharing options...
Brunz Posted February 10, 2015 Author Report Share Posted February 10, 2015 On 2/10/2015 at 12:51 PM, ulli_123 said: When I call the clean_ai_items.lua comes only <integer> 0 Hi, That basically means it found no results from the keys lookup, check your EpochServer.ini and see what is your InstanceID, you may need to modify the keys lookup pattern to match. eg.. where it has 1 change it to your instanceid local valuelist = redis.call('keys', 'AI_ITEMS:1:*') local valuelist = redis.call('keys', 'AI_ITEMS:MyInstanceID:*') You can check the keys look up is working by doing below replace the below parameters to suit your environment and then run the below in the command prompt. 1. Connect to DB using redis-cli redis-cli -h 127.0.0.1 -p 2456 -a mypass -n 0 2. List keys using a pattern 127.0.0.1:2456> keys AI_ITEMS:MyInstanceID:* 1) "AI_ITEMS:MyInstanceID:87" 2) "AI_ITEMS:MyInstanceID:26" etc..... if all else fails try to connect using http://redisdesktop.com/ Link to comment Share on other sites More sharing options...
ulli_123 Posted February 11, 2015 Report Share Posted February 11, 2015 Yes, that was my fault, now it works. thx Link to comment Share on other sites More sharing options...
Tophi Posted February 11, 2015 Report Share Posted February 11, 2015 On 2/10/2015 at 2:08 PM, Brunz said: Hi, That basically means it found no results from the keys lookup, check your EpochServer.ini and see what is your InstanceID, you may need to modify the keys lookup pattern to match. eg.. where it has 1 change it to your instanceid local valuelist = redis.call('keys', 'AI_ITEMS:1:*') local valuelist = redis.call('keys', 'AI_ITEMS:MyInstanceID:*') You can check the keys look up is working by doing below replace the below parameters to suit your environment and then run the below in the command prompt. 1. Connect to DB using redis-cli redis-cli -h 127.0.0.1 -p 2456 -a mypass -n 0 2. List keys using a pattern 127.0.0.1:2456> keys AI_ITEMS:MyInstanceID:* 1) "AI_ITEMS:MyInstanceID:87" 2) "AI_ITEMS:MyInstanceID:26" etc..... if all else fails try to connect using http://redisdesktop.com/ i'm connected with redisdesktop, and i'm connected to my database but not clue how to enter the code in it.... any advice Link to comment Share on other sites More sharing options...
Brunz Posted February 12, 2015 Author Report Share Posted February 12, 2015 @Tophi Redis Desktop currently can only update one value at a time manually. if you want to do a bulk update please read the first post carefully and use redis-cli.exe with the lua script Tophi 1 Link to comment Share on other sites More sharing options...
Tophi Posted February 12, 2015 Report Share Posted February 12, 2015 On 2/12/2015 at 3:08 AM, Brunz said: @Tophi Redis Desktop currently can only update one value at a time manually. if you want to do a bulk update please read the first post carefully and use redis-cli.exe with the lua script thank you. i will try it Link to comment Share on other sites More sharing options...
Brunz Posted February 15, 2015 Author Report Share Posted February 15, 2015 Hi,an update has been added to the original post.Instead of cleaning the whole trader of all items i have added a script which will replace only those vehicles you specify with a item of your choosing.See - clean_sold_vehicles_only.lua Link to comment Share on other sites More sharing options...
ReMuS Posted April 7, 2015 Report Share Posted April 7, 2015 can you write a lua for trader fill items and vehicles Link to comment Share on other sites More sharing options...
Talchi Posted April 7, 2015 Report Share Posted April 7, 2015 Brunz, I ran the clean script, removing all vendor items, and I added 'start up' items for the vendors. When I look in RedisDesktop, I see the items and amounts, however, in game, I do not see them, the vendors have nothing. Is there something I am missing? Thanks Tal Link to comment Share on other sites More sharing options...
Talchi Posted April 7, 2015 Report Share Posted April 7, 2015 I rebooted the server, and it worked. Don't know why it didn't the first time. I had the DB running, ran the script, checked the data, then started the Arma server, and nothing was changed. I closed the Arma server, ran the script again, and started the Arma server and it showed the change. I am assuming you can set this to run at say server shutdown, or start up. I am new to Arma coding and our admins were looking at a way to have the vendors restock each reboot, and to clear out items so they don't get clunky. Thanks Link to comment Share on other sites More sharing options...
ReMuS Posted April 23, 2015 Report Share Posted April 23, 2015 Hi can anybody say me what i need for delete the DB 0 on redis?? Link to comment Share on other sites More sharing options...
snafu0185 Posted April 30, 2015 Report Share Posted April 30, 2015 when trying this im getting (error) ERR unknown command '--eval' Link to comment Share on other sites More sharing options...
Kenobi Posted May 2, 2015 Report Share Posted May 2, 2015 Brunz: Very usefull, thank you. But small issue. Replaced item EpochRadio0 is not possible to buy from trader back. Is possible only to delete vehicles without replacing? Link to comment Share on other sites More sharing options...
ReDBaroN Posted May 10, 2015 Report Share Posted May 10, 2015 On 2/10/2015 at 2:08 PM, Brunz said: Hi, That basically means it found no results from the keys lookup, check your EpochServer.ini and see what is your InstanceID, you may need to modify the keys lookup pattern to match. eg.. where it has 1 change it to your instanceid local valuelist = redis.call('keys', 'AI_ITEMS:1:*') local valuelist = redis.call('keys', 'AI_ITEMS:MyInstanceID:*') You can check the keys look up is working by doing below replace the below parameters to suit your environment and then run the below in the command prompt. 1. Connect to DB using redis-cli redis-cli -h 127.0.0.1 -p 2456 -a mypass -n 0 2. List keys using a pattern 127.0.0.1:2456> keys AI_ITEMS:MyInstanceID:* 1) "AI_ITEMS:MyInstanceID:87" 2) "AI_ITEMS:MyInstanceID:26" etc..... if all else fails try to connect using http://redisdesktop.com/ Hi Brunz, I have the same problem with <integer> 0 When I followed your instructions above changing my DB instance ID to 0 which is what I have against DB in my EpochServer.ini file, I get this: <empty list or set> Can't work out what I'm doing wrong, any ideas? Thanks Link to comment Share on other sites More sharing options...
ReDBaroN Posted May 10, 2015 Report Share Posted May 10, 2015 Hi Brunz, have you seen that before? <empty list or set> Can't see to get past this.. Thanks for any help. Link to comment Share on other sites More sharing options...
Brian Soanes Posted May 10, 2015 Report Share Posted May 10, 2015 isn't expiresAIdata in epochconfig.hpp meant to auto clean AI trader inventories? :rolleyes: // expiration date in seconds for NPC Trader inventory Link to comment Share on other sites More sharing options...
ReDBaroN Posted May 10, 2015 Report Share Posted May 10, 2015 Yes but I only want to clean vehicles out as they use up the spawn count when they're in the traders stock.... :-P Link to comment Share on other sites More sharing options...
Kenobi Posted May 14, 2015 Report Share Posted May 14, 2015 On 5/10/2015 at 12:07 AM, ReDBaroN said: Hi Brunz, I have the same problem with <integer> 0 When I followed your instructions above changing my DB instance ID to 0 which is what I have against DB in my EpochServer.ini file, I get this: <empty list or set> Can't work out what I'm doing wrong, any ideas? Thanks Hello, DB = 0 from epochserver.ini is wrong. U must change to NA123, which is default if you not change it. Look for InstanceID in epochserver.ini local valuelist = redis.call('keys', 'AI_ITEMS:NA123:*') is what u need :-) ReDBaroN 1 Link to comment Share on other sites More sharing options...
ReDBaroN Posted May 16, 2015 Report Share Posted May 16, 2015 On 5/14/2015 at 11:29 AM, Kenobi said: Hello, DB = 0 from epochserver.ini is wrong. U must change to NA123, which is default if you not change it. Look for InstanceID in epochserver.ini local valuelist = redis.call('keys', 'AI_ITEMS:NA123:*') is what u need :-) Thanks dude. Can't believe I didn't spot that and was trying to use the DB number instead of instance... :mellow: Link to comment Share on other sites More sharing options...
Kenobi Posted May 18, 2015 Report Share Posted May 18, 2015 On 5/16/2015 at 7:17 PM, ReDBaroN said: Thanks dude. Can't believe I didn't spot that and was trying to use the DB number instead of instance... :mellow: You are welcome. I am glad to help you :-) ReDBaroN 1 Link to comment Share on other sites More sharing options...
snafu0185 Posted May 21, 2015 Report Share Posted May 21, 2015 On 4/30/2015 at 7:55 AM, snafu0185 said: when trying this im getting (error) ERR unknown command '--eval' any ideas how to fix? Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now