• Просьба не публиковать сообщения с предложениями продажи модов или сборок!

    Мы против использования и перепродажи слитых модов и переделок на их основе. Остальное также сложно верифицировать, поэтому в целом пока что запрещаем эту тему на сайте.

Серверные команды для RageMP

Рикардо

Junior Developer
Сообщения
29
Незнаю на сколько это будет актуальным, но все же =)

JavaScript:
//Восстановление жизни
mp.events.addCommand('hp', (player, _, target, hp) => {
    if (target == undefined || hp == undefined) return player.outputChatBox('/hp [player] [hp]');
    var p = mp.players.at(target);
    if (p == null) return player.notify('~r~ID игрока не найден!');
    p.health = parseInt(hp);
})

//Восстановление брони
mp.events.addCommand('arm', (player, _, target, arm) => {
    if (target == undefined || arm == undefined) return player.outputChatBox('/arm [player] [armour]');
    var p = mp.players.at(target);
    if (p == null) return player.notify('~r~ID игрока не найден!');
    p.armour = parseInt(arm);
})

//Спавн машины
mp.events.addCommand('veh', (player, _, id, veh, color1, color2) => {
    if (id == undefined || veh == undefined) return player.outputChatBox('/veh [id] [model] [color1] [color2]');
    let target = mp.players.at(id);
    if (target == null) return player.notify('~r~ID игрока не найден!');
    let pos;
    pos = target.position;
    var adminVeh = mp.vehicles.new(mp.joaat(veh), new mp.Vector3(pos.x + 2, pos.y, pos.z));
    adminVeh.setColor(parseInt(color1), parseInt(color2));
    player.dim = player.id;
    setTimeout(() => {
        target.putIntoVehicle(adminVeh, 0) // Спавн за водительское место
    }, 150)
})

//Восстановление транспорта
mp.events.addCommand('fixcar', (player, _, id) => {
    if (id == undefined) {
        if (!player.vehicle) return player.notify('~r~Вы не в транспорте!');
        player.vehicle.repair();
    } else {
        let target = mp.players.at(id);
        if (target == null) return player.notify('~r~ID игрока не найден!');
        target.vehicle.repair();
    }
})

//Координаты игрока
mp.events.addCommand('pos', (player) => {
    let pos;
    pos = player.position;
    rot = player.heading;
    player.outputChatBox(`X: ${pos.x.toFixed(4)} Y: ${pos.y.toFixed(4)} Z: ${pos.z.toFixed(4)}`);
    player.outputChatBox(`Head rotate: ${rot.toFixed(4)}`);
    console.log(`X: ${pos.x.toFixed(2)} Y: ${pos.y.toFixed(2)} Z: ${pos.z.toFixed(2)}`);
})

//Телепорт по координатам
mp.events.addCommand('tpc', (player, _, x, y, z) => {
    if (x == undefined || y == undefined || z == undefined) return player.outputChatBox('/tpc [x] [y] [z]');
    player.position = new mp.Vector3(parseFloat(x), parseFloat(y), parseFloat(z));
})

//Погода
mp.events.addCommand('setw', (player, _, weather) => {
    if (weather == undefined) return player.outputChatBox('/setw [weather]');
    mp.world.weather = weather;
})

//Телепортиртация игрока
mp.events.addCommand('metp', (player, _, id) => {
    if (id == undefined) return player.outputChatBox('/metp [id]');
    let target = mp.players.at(id);
    if (target == null) return player.notify('~r~ID игрока не найден!');
    target.dimension = player.dimension;
    target.position = player.position;
    player.notify(`~g~ Вы телепортировали ~y~${target.id} ~g~ID`);
})

//Телепортироваться к игроку
mp.events.addCommand('goto', (player, _, id) => {
    if (id == undefined) return player.outputChatBox('/goto [id]');
    let target = mp.players.at(id);
    if (target == null) return player.notify('~r~ID игрока не найден!');
    player.dimension = target.dimension;
    player.position = target.position;
    player.notify(`~g~ Вы телепортировались к ~y~${target.id} ~g~ID`);
})

//Смена дименшина
mp.events.addCommand('setdim', (player, _, id, dim) => {
    if (id == undefined || dim == undefined) return player.outputChatBox('/setdim [id] [dim]');
    let target = mp.players.at(id);
    if (target == null) return player.notify('~r~ID игрока не найден!');
    target.dimension = parseInt(dim);
    player.notify(`~g~ Переход в~y~ ${target.dimension} ~g~дименшин`);
})

//Спавним оружие в руках
mp.events.addCommand('gun', (player, _, id, weapon, ammo) => {
    if (id == undefined || weapon == undefined || ammo == undefined) return player.outputChatBox('/gun [id] [weapon] [ammo]');
    let target = mp.players.at(id);
    target.giveWeapon(mp.joaat(`weapon_${weapon}`), parseInt(ammo));
})

// Проверка дименшина
mp.events.addCommand('dim', (player) => {
    player.notify(`Вы в ~r~${player.dimension} ~w~дименшине.`);
})

// Бан по железу
mp.events.addCommand('banhd', (player, _, id, reason) => {
    if (id == undefined || reason == undefined) return player.outputChatBox('/banhd [id] [reason]');
    let target = mp.players.at(id); // Проверка всех игроков по ID
    if (target == null) return player.notify('~r~ID игрока не найден!');
    var message =  _.replace(id, '');
    mp.server.database.query('INSERT INTO banhwid (admin,player,playerHWID,reason) VALUES (?,?,?,?)', [player.name, target.name, target.serial, message]);
    mp.players.broadcast(`[A] ${player.name} забанил по железу !{FFFF00}${target.name} !{FFF000} по причине: ${message}`);
    target.kick();
})

// Одежда
mp.events.addCommand('setcloth', (player, _, component, drawable, texture, pallete) => {
    if (component == undefined || drawable == undefined) return player.outputChatBox('/setcloth [component] [drawable] [texture? [pallete?]]');
    player.setClothes(parseInt(component), parseInt(drawable), parseInt(texture), parseInt(pallete));
})

// Удаление машин
mp.events.addCommand(`delveh`,
    (player) => {
        mp.vehicles.forEach(
            (vehicle) => {
                vehicle.destroy();
            }
        );
        mp.players.broadcast(`${player.name} Удалил все машины!`);
    }
);

// Пытаемся заспавнить колшейпы
mp.events.addCommand('clshape', (player, _, namez, red, green, blue, alpha, colradz, markidz, typez, pricez) => {
    let pos = player.position;
    var poz = JSON.stringify(pos);
    var color = {r:red, g:green, b:blue, a:alpha};
    if (namez == undefined || color == undefined || colradz == undefined || markidz == undefined || typez == undefined || pricez == undefined) return player.outputChatBox('/clshape [name] [r g b a] [colshape_radius] [marker_id] [type] [price]');
    mp.server.database.query('INSERT INTO `shop` (`name`, `coord`, `markcolor`, `colrad`, `markid`, `type`, `price`) VALUES (?, ?, ?, ?, ?, ?, ?)', [namez, poz, JSON.stringify(color), colradz, markidz, typez, pricez] , function (err, res) {
        // console.log(err);
    });
});

// Прокрут анимации
mp.events.addCommand('anim', (player, _, dict, name, speed, flag) => {
    player.outputChatBox('/anim [animDic] [animName] [duration] [flag]');
    player.playAnimation(dict, name, speed, flag);
})

// Прокрут сценарий
mp.events.addCommand('scanim', (player, _, scenario) => {
    player.outputChatBox('/scanim [scenario]');
    player.playScenario(scenario);
})
 
А в чем разница между анимациями и сценариями?
 
А в чем разница между анимациями и сценариями?
Анимация скелета игрока и компонентная анимация скелета с пропом (например: персонаж держит в руке бутылку пиво сидя)...

Список сценария: https://wiki.rage.mp/index.php?title=Scenarios

Список анимации: https://wiki.rage.mp/index.php?title=Animations
 
Ага понял. Сценарии это что-то наподобие special action которые были в samp.
 
Незнаю на сколько это будет актуальным, но все же =)

JavaScript:
//Восстановление жизни
mp.events.addCommand('hp', (player, _, target, hp) => {
    if (target == undefined || hp == undefined) return player.outputChatBox('/hp [player] [hp]');
    var p = mp.players.at(target);
    if (p == null) return player.notify('~r~ID игрока не найден!');
    p.health = parseInt(hp);
})

//Восстановление брони
mp.events.addCommand('arm', (player, _, target, arm) => {
    if (target == undefined || arm == undefined) return player.outputChatBox('/arm [player] [armour]');
    var p = mp.players.at(target);
    if (p == null) return player.notify('~r~ID игрока не найден!');
    p.armour = parseInt(arm);
})

//Спавн машины
mp.events.addCommand('veh', (player, _, id, veh, color1, color2) => {
    if (id == undefined || veh == undefined) return player.outputChatBox('/veh [id] [model] [color1] [color2]');
    let target = mp.players.at(id);
    if (target == null) return player.notify('~r~ID игрока не найден!');
    let pos;
    pos = target.position;
    var adminVeh = mp.vehicles.new(mp.joaat(veh), new mp.Vector3(pos.x + 2, pos.y, pos.z));
    adminVeh.setColor(parseInt(color1), parseInt(color2));
    player.dim = player.id;
    setTimeout(() => {
        target.putIntoVehicle(adminVeh, 0) // Спавн за водительское место
    }, 150)
})

//Восстановление транспорта
mp.events.addCommand('fixcar', (player, _, id) => {
    if (id == undefined) {
        if (!player.vehicle) return player.notify('~r~Вы не в транспорте!');
        player.vehicle.repair();
    } else {
        let target = mp.players.at(id);
        if (target == null) return player.notify('~r~ID игрока не найден!');
        target.vehicle.repair();
    }
})

//Координаты игрока
mp.events.addCommand('pos', (player) => {
    let pos;
    pos = player.position;
    rot = player.heading;
    player.outputChatBox(`X: ${pos.x.toFixed(4)} Y: ${pos.y.toFixed(4)} Z: ${pos.z.toFixed(4)}`);
    player.outputChatBox(`Head rotate: ${rot.toFixed(4)}`);
    console.log(`X: ${pos.x.toFixed(2)} Y: ${pos.y.toFixed(2)} Z: ${pos.z.toFixed(2)}`);
})

//Телепорт по координатам
mp.events.addCommand('tpc', (player, _, x, y, z) => {
    if (x == undefined || y == undefined || z == undefined) return player.outputChatBox('/tpc [x] [y] [z]');
    player.position = new mp.Vector3(parseFloat(x), parseFloat(y), parseFloat(z));
})

//Погода
mp.events.addCommand('setw', (player, _, weather) => {
    if (weather == undefined) return player.outputChatBox('/setw [weather]');
    mp.world.weather = weather;
})

//Телепортиртация игрока
mp.events.addCommand('metp', (player, _, id) => {
    if (id == undefined) return player.outputChatBox('/metp [id]');
    let target = mp.players.at(id);
    if (target == null) return player.notify('~r~ID игрока не найден!');
    target.dimension = player.dimension;
    target.position = player.position;
    player.notify(`~g~ Вы телепортировали ~y~${target.id} ~g~ID`);
})

//Телепортироваться к игроку
mp.events.addCommand('goto', (player, _, id) => {
    if (id == undefined) return player.outputChatBox('/goto [id]');
    let target = mp.players.at(id);
    if (target == null) return player.notify('~r~ID игрока не найден!');
    player.dimension = target.dimension;
    player.position = target.position;
    player.notify(`~g~ Вы телепортировались к ~y~${target.id} ~g~ID`);
})

//Смена дименшина
mp.events.addCommand('setdim', (player, _, id, dim) => {
    if (id == undefined || dim == undefined) return player.outputChatBox('/setdim [id] [dim]');
    let target = mp.players.at(id);
    if (target == null) return player.notify('~r~ID игрока не найден!');
    target.dimension = parseInt(dim);
    player.notify(`~g~ Переход в~y~ ${target.dimension} ~g~дименшин`);
})

//Спавним оружие в руках
mp.events.addCommand('gun', (player, _, id, weapon, ammo) => {
    if (id == undefined || weapon == undefined || ammo == undefined) return player.outputChatBox('/gun [id] [weapon] [ammo]');
    let target = mp.players.at(id);
    target.giveWeapon(mp.joaat(`weapon_${weapon}`), parseInt(ammo));
})

// Проверка дименшина
mp.events.addCommand('dim', (player) => {
    player.notify(`Вы в ~r~${player.dimension} ~w~дименшине.`);
})

// Бан по железу
mp.events.addCommand('banhd', (player, _, id, reason) => {
    if (id == undefined || reason == undefined) return player.outputChatBox('/banhd [id] [reason]');
    let target = mp.players.at(id); // Проверка всех игроков по ID
    if (target == null) return player.notify('~r~ID игрока не найден!');
    var message =  _.replace(id, '');
    mp.server.database.query('INSERT INTO banhwid (admin,player,playerHWID,reason) VALUES (?,?,?,?)', [player.name, target.name, target.serial, message]);
    mp.players.broadcast(`[A] ${player.name} забанил по железу !{FFFF00}${target.name} !{FFF000} по причине: ${message}`);
    target.kick();
})

// Одежда
mp.events.addCommand('setcloth', (player, _, component, drawable, texture, pallete) => {
    if (component == undefined || drawable == undefined) return player.outputChatBox('/setcloth [component] [drawable] [texture? [pallete?]]');
    player.setClothes(parseInt(component), parseInt(drawable), parseInt(texture), parseInt(pallete));
})

// Удаление машин
mp.events.addCommand(`delveh`,
    (player) => {
        mp.vehicles.forEach(
            (vehicle) => {
                vehicle.destroy();
            }
        );
        mp.players.broadcast(`${player.name} Удалил все машины!`);
    }
);

// Пытаемся заспавнить колшейпы
mp.events.addCommand('clshape', (player, _, namez, red, green, blue, alpha, colradz, markidz, typez, pricez) => {
    let pos = player.position;
    var poz = JSON.stringify(pos);
    var color = {r:red, g:green, b:blue, a:alpha};
    if (namez == undefined || color == undefined || colradz == undefined || markidz == undefined || typez == undefined || pricez == undefined) return player.outputChatBox('/clshape [name] [r g b a] [colshape_radius] [marker_id] [type] [price]');
    mp.server.database.query('INSERT INTO `shop` (`name`, `coord`, `markcolor`, `colrad`, `markid`, `type`, `price`) VALUES (?, ?, ?, ?, ?, ?, ?)', [namez, poz, JSON.stringify(color), colradz, markidz, typez, pricez] , function (err, res) {
        // console.log(err);
    });
});

// Прокрут анимации
mp.events.addCommand('anim', (player, _, dict, name, speed, flag) => {
    player.outputChatBox('/anim [animDic] [animName] [duration] [flag]');
    player.playAnimation(dict, name, speed, flag);
})

// Прокрут сценарий
mp.events.addCommand('scanim', (player, _, scenario) => {
    player.outputChatBox('/scanim [scenario]');
    player.playScenario(scenario);
})
mp.events.addCommand('veh', (player, _, id, veh, color1, color2) => {
if (id == undefined || veh == undefined) return player.outputChatBox('/veh [id] [model] [color1] [color2]');
let target = mp.players.at(id);
if (target == null) return player.notify('~r~ID игрока не найден!');
let pos;
pos = target.position;
var adminVeh = mp.vehicles.new(mp.joaat(veh), new mp.Vector3(pos.x + 2, pos.y, pos.z));
adminVeh.setColor(parseInt(color1), parseInt(color2));
player.dim = player.id;
setTimeout(() => {
target.putIntoVehicle(adminVeh, 0) // Спавн за водительское место
}, 150)

})
setTimeout тут и не нужнен, можно и без него задить за водительское место. Он нужен только в том случае, если вы хотите после спавна автомобиля, садить игрока через какое то время.
 
Знатоки, подскажите пожалуйста. Новую тему плодить не стал.
Позаимствовал код
Код:
//Координаты игрока
mp.events.addCommand('pos', (player) => {
    let pos;
    pos = player.position;
    rot = player.heading;
    player.outputChatBox(`X: ${pos.x.toFixed(4)} Y: ${pos.y.toFixed(4)} Z: ${pos.z.toFixed(4)}`);
    player.outputChatBox(`Head rotate: ${rot.toFixed(4)}`);
    console.log(`X: ${pos.x.toFixed(2)} Y: ${pos.y.toFixed(2)} Z: ${pos.z.toFixed(2)}`);
})

Очень простая, но крутая фича. Так вот она ещё выдает параметр Head Rotate. Я полагаю что это куда повёрнут перс.
Решил я через серверную часть спавнить машины. Отлично, здорово, но хочется чтобы они стояли ровно и красиво.
С помощью кода выше я вычислил координаты, но одно не могу понять и найти, как прописать чтобы авто спавнилась как я хочу)
Код:
mp.vehicles.new(mp.joaat("ambulance"), new mp.Vector3(-409.63, 1199.04, 326),
    {
        numberPlate: "LS911FD",
        heading:  0.0004
    });

Возможно я не правильно понял, но есть синтаксис heading: heading, который указан в примере как
  • heading: Number [-180:180]
Можно пример, как он работает? Спасибо всем)
 
Знатоки, подскажите пожалуйста. Новую тему плодить не стал.
Позаимствовал код
Код:
//Координаты игрока
mp.events.addCommand('pos', (player) => {
    let pos;
    pos = player.position;
    rot = player.heading;
    player.outputChatBox(`X: ${pos.x.toFixed(4)} Y: ${pos.y.toFixed(4)} Z: ${pos.z.toFixed(4)}`);
    player.outputChatBox(`Head rotate: ${rot.toFixed(4)}`);
    console.log(`X: ${pos.x.toFixed(2)} Y: ${pos.y.toFixed(2)} Z: ${pos.z.toFixed(2)}`);
})

Очень простая, но крутая фича. Так вот она ещё выдает параметр Head Rotate. Я полагаю что это куда повёрнут перс.
Решил я через серверную часть спавнить машины. Отлично, здорово, но хочется чтобы они стояли ровно и красиво.
С помощью кода выше я вычислил координаты, но одно не могу понять и найти, как прописать чтобы авто спавнилась как я хочу)
Код:
mp.vehicles.new(mp.joaat("ambulance"), new mp.Vector3(-409.63, 1199.04, 326),
    {
        numberPlate: "LS911FD",
        heading:  0.0004
    });

Возможно я не правильно понял, но есть синтаксис heading: heading, который указан в примере как
  • heading: Number [-180:180]
Можно пример, как он работает? Спасибо всем)
heading - угол поворота машины, что именно нужно обьяснить?
 
heading - угол поворота машины, что именно нужно обьяснить?
Угол поворота в градусах?
Интересует правильный синтаксис.

Пробовал:
Код:
heading: [-120]
Авто по вертикали переворачивает на крышу.

Пробовал:
Код:
heading: 0.0004
Ничего не происходит вообще.

Мне нужно авто развернуть на 180 градусов по горизонтали.
 
Угол поворота в градусах?
Интересует правильный синтаксис.

Пробовал:
Код:
heading: [-120]
Авто по вертикали переворачивает на крышу.

Пробовал:
Код:
heading: 0.0004
Ничего не происходит вообще.

Мне нужно авто развернуть на 180 градусов по горизонтали.
Да в градусах, допустим:
JavaScript:
mp.vehicles.new(mp.joaat("ambulance"), new mp.Vector3(-409.63, 1199.04, 326),
    {
        numberPlate: "LS911FD",
        heading:  70.0 // машина будет повернута на 70 градусов
    });
 
привет всем, я не сильно разбераюсь в этом, кто может скинуть команду /hp /revive /armor это чтобы выдовать определенный процент всего, только я пишу на с# , кто-то может скинуть для с#?
 
Назад
Верх