New function for promodlive
-
Hi, I added a line to change the mode to promodlive, the data is taken from a separate table "usedrmods" in the database. Where is the "promod_mode" command sent to the server specified?
/server/index.pug
.row if ( typeof results.rcon_extra.enable_map_change !== 'undefined' && results.rcon_extra.enable_map_change ) if (user.local.user_role >= results.rcon_extra.minimum_power_for_map_change) .col-md-6.m-b-15.m-t-15 .col-md-12 form(method='post', action='/rconcmd/'+results.server._id+'/changemod') input(type='hidden', name='rcon_cmd', value="mod") .col-md-6 .fg-line .select select.form-control(name='mod_name', required) option(value="") #{t('-Режим промода-')} each row in results.usermods option(value=row.mod_name) #{row.display_mod_name} .col-md-6 input(type='hidden', name='_csrf', value=csrfToken) button.btn.bgm-lightblue.waves-effect(type='submit') | #{t('frontpages:server.server_btn_go')}
dbseed.js
var mods = [ new UserMod({ mod_name : 'match_mr12', display_map_name: 'MATCH MR12' }), new UserMod({ mod_name : 'strat', display_map_name: 'STRAT' }) ];
/routes/rconcmd.js
app.post('/:id/changemod', isLoggedIn, rconcmd.RconChangeMod);
/locales/en/rcon_commands.json
"RconChangeMod": { "mod_changed_to_modname": "Режим успешно изменен на {{get_ModName}}!" },
/controllers/rconcmd/index.js
RconChangeMod: function(req, res, next) { BluebirdPromise.props({ requiredpower: ExtraRcon.findOne({'name': 'extra_rcon'}).execAsync(), mods: Mods.findOne({'mod_name': req.body.mod_name}).execAsync(), getserver: Servers.findOne({'admins_on_server':req.user._id, '_id':req.params.id, 'rcon_password': { $exists: true }}).execAsync(), }).then(function(results) { if (results.getserver){ if ( results.requiredpower.enable_map_change !== 'undefined' && results.requiredpower.enable_map_change){ if (req.user.local.user_role >= results.requiredpower.minimum_power_for_map_change){ var cmd = req.body.rcon_cmd+' '+req.body.mod_name; var rcon = require('srcds-rcon')({address:results.getserver.ip+':'+results.getserver.port,password: results.getserver.rcon_password}); rcon.connect() .then(function(connected){ return rcon.command(cmd); }).then(function(getresult){ req.flash('rconconsole_messages', req.t('rcon_commands:RconChangeMod.mod_changed_to_modname', { get_ModName: results.mods.display_mod_name })); }).then(function(disconnect){ rcon.disconnect(); res.redirect('back'); }).catch(function(err) { req.flash('rconconsole_messages', err.stack); res.redirect('back'); }); }else{ req.flash('error_messages', req.t('rcon_commands:general.general_no_permission')); res.redirect('back'); } }else{ req.flash('error_messages', req.t('rcon_commands:general.general_command_disabled_by_admin')); res.redirect('back'); } }else{ req.flash('error_messages', req.t('rcon_commands:general.general_no_admin_rights_on_server')); res.redirect('back'); } }).catch(function(err) { req.flash('error_messages', req.t('rcon_commands:general.general_there_was_an_error', { get_error: err })); console.log("There was an error: " +err); res.redirect('back'); }); },
-
I solved the problem, it's not relevant.
-
I want to try to record statistics every 2 minutes, what do you think?
-
I need time to look at changes what you have made, right now I have a lot of work so it will have to wait.