user.loadUser = function(player, name, spawn = 'Стандарт') {
methods.debug('user.loadUser');
if (!mp.players.exists(player))
return false;
/* old shit
let selectSql = 'id';
enums.userData.forEach(function(element) {
selectSql += `, ${element}`;
});
*/
let userId = 0;
if (user.isLogin(player))
userId = user.getId(player);
/* old shit
mysql.executeQuery(`SELECT ${selectSql} FROM users WHERE name = ? LIMIT 1`, name, function (err, rows, fields) {
*/
mysql.executeQuery(`SELECT * FROM users WHERE name = ? LIMIT 1`, name, function (err, rows, fields) {
enums.userData.forEach(function(element) {
user.set(player, element, rows[0][element]);
});
setTimeout(function() {
//user.updateCharacterFace(player);
//user.updateCharacterCloth(player);
if (!mp.players.exists(player))
return false;
try {
JSON.parse(user.get(player, 'skin'), function(k, v) {
user.set(player, k, v);
});
}
catch (e) {
methods.saveFile('customError', `${player.socialClub}: ${e} | ${user.get(player, 'skin')}`);
user.resetAll(player);
//user.showCustomNotify(player, 'Аккаунт забанен до: ' + methods.unixTimeStampToDateTime(user.get(player, 'date_ban')), 1);
user.showCustomNotify(player, 'Произошла ошибка ', 1);
user.kick(player, 'У Вас произошла магическая ошибка, логи отправлены разработчикам, просто перезайдите');
return;
}
if (user.get(player, 'date_ban') > methods.getTimeStamp()) {
user.resetAll(player);
//user.showCustomNotify(player, 'Аккаунт забанен до: ' + methods.unixTimeStampToDateTime(user.get(player, 'date_ban')), 1, 5, 60000);
user.showCustomNotify(player, 'Вы забанены, подробности смотреть на сайте: state-99.com/banlist', 1, 5, 60000);
user.kick(player, 'Вы забанены');
return;
}
if (user.get(player, 'is_online') == 1 && !mysql.isTestServer()) {
user.resetAll(player);
user.showCustomNotify(player, 'Аккаунт уже авторизован', 1);
user.kick(player, 'Вы были кикнуты');
return;
}
user.set(player, 'ping', player.ping);
user.set(player, 'is_online', 1);
try {
user.set(player, 'login_date', methods.getTimeStamp());
user.set(player, 'login_ip', player.ip);
} catch (e) {
methods.debug(e);
}
setTimeout(function () {
if (userId > 0)
mysql.executeQuery('UPDATE users SET is_online=\'0\' WHERE id = \'' + userId + '\'');
if (!mp.players.exists(player))
return false;
try {
if (user.get(player, 'SKIN_SEX') === 1)
player.model = mp.joaat('mp_f_freemode_01');
else
player.model = mp.joaat('mp_m_freemode_01');
}
catch (e) {
}
user.updateCharacterFace(player);
setTimeout(function () {
user.updateCharacterCloth(player);
}, 200);
user.updateClientCache(player);
player.setVariable('idLabel', user.get(player, 'id'));
player.setVariable('name', user.get(player, 'name'));
player.setVariable('walkie', user.get(player, 'walkie_' + (user.get(player, 'walkie_current') + 1)));
player.setVariable('walkieBuy', user.get(player, 'walkie_buy'));
player.setVariable('status_media', user.get(player, 'status_media'));
player.dimension = 0;
user.setFractionId(player, user.get(player, 'fraction_id'));
user.setFractionId2(player, user.get(player, 'fraction_id2'));
user.setFamilyId(player, user.get(player, 'family_id'));
//user.setDatingName(player, user.get(player, 'name_dating'));
player.setVariable('work_lvl', user.getWorkLvl(player));
methods.loadDeleteObject(player);
if (!user.hasById(user.getId(player), 'dailyAchiv')) {
let list = [];
let listAllow = [];
for (let i = 0; i < 18; i++)
list.push(0);
for (let i = 0; i < 5; i++)
listAllow.push(methods.getRandomInt(0, 18));
user.setById(user.getId(player), 'dailyAchiv', JSON.stringify(list));
user.setById(user.getId(player), 'dailyAchivAllow', JSON.stringify(listAllow));
}
inventory.updateItemsEquipByItemId(252, user.getId(player), 1, 0);
//user.setArmour(player, user.get(player, 'ap'));
user.setHealth(player, user.get(player, 'hp'));
setTimeout(function () {
try {
//user.setArmour(player, user.get(player, 'ap'));
user.setHealth(player, user.get(player, 'hp'));
user.setClipset(player, user.get(player, 'clipset'));
user.setClipsetW(player, user.get(player, 'clipset_w'));
}
catch (e) {
}
}, 2000);
if (user.get(player, 'vip_time') > 0 && user.get(player, 'vip_time') < methods.getTimeStamp()) {
player.outputChatBox(`!{#f44336}Срок действия вашего VIP статуса подошел к концу`);
user.set(player, 'vip_time', 0);
user.set(player, 'vip_type', 0);
}
userId = user.getId(player);
mysql.executeQuery(`SELECT * FROM user_dating WHERE user_owner = '${userId}'`, function (err, rowsD, fields) {
let list = [];
rowsD.forEach(rowD => {
list.push({ uId: rowD['user_id'], uName: rowD['user_name'] });
});
player.call('client:user:updateDating', [JSON.stringify(list)]);
});
mysql.executeQuery('UPDATE users SET is_online=\'1\' WHERE id = \'' + user.getId(player) + '\'');
vehicles.loadAllUserVehicles(userId);
if (!user.get(player, 'is_custom'))
player.call('client:events:loginUser:finalCreate');
else {
user.spawnByName(player, spawn);
}
setTimeout(function () {
try {
mp.players.forEach(p => {
try {
if (user.isLogin(p)) {
if (p.getVariable('idLabel') === player.getVariable('idLabel') && p.id !== player.id) {
user.kickAntiCheat(p, 'Buguse');
user.kickAntiCheat(player, 'Buguse');
}
}
}
catch (e) {
}
});
}
catch (e) {
}
}, methods.getRandomInt(1000, 3000));
methods.saveLog('log_connect',
['type', 'social', 'serial', 'address', 'game_id', 'account_id'],
['LOGIN', player.socialClub, player.serial, player.ip, player.id, userId]
);
player.call('client:events:loginUser:success');
player.call('client:addGangZoneBlip', [JSON.stringify(gangWar.getZoneList())]);
player.call('client:addCanabisZoneBlip', [JSON.stringify(canabisWar.getZoneList())]);
//user.setOnlineStatus(player, 1);
}, 600);
//if (user.get(player, 'walkietalkie_num') && methods.parseInt(user.get(player, 'walkietalkie_num')) != 0)
// mp.events.call('voice.server.initRadio', player, user.get(player, 'walkietalkie_num'));
}, methods.getRandomInt(1000, 3000));
});
};