Доступ к готовым решениям

Переход в группу "Пользователь"

300.00
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

Мануал Выкинуть/поднять оружие

Статус
В этой теме нельзя размещать новые ответы.

Botan()

Начинающий
Регистрация
14 Июн 2014
Сообщения
39
Лучшие ответы
0
Репутация
31
Здравствуйте!
Данный мануал поможет Вам добавить в свой мод систему выбрасывания оружия командой /drop, и поднятие оружия командой /take.​

К define:

PHP:
#define MAX_GUNS 500
К enum:

PHP:
enum DGUN_INFO
{
	dID, // ID
	Float:dPos[3], // Позиция
	dWeapon, // Оружие
	dAmmo, // Патроны
	dVirtualWorld, // Виртуальный мир
	dInterior, // Интерьер
	Text3D:dLabel // 3D текст
};
new Dgun[MAX_GUNS][DGUN_INFO];
К new:

PHP:
new GunObjects[47] =
{
	0, 331, 333, 334, 335, 336, 337, 338, 339, 341, 321, 322, 323, 324, 325, 326,
	342, 343, 344, 0, 0, 0, 346, 347, 348, 349, 350, 351, 352, 353, 355, 356, 372,
	357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 368, 371
};
Добавим stock:

PHP:
stock B_RemovePlayerWeapon(playerid, b_weapon)
{
	new b_weaponammo[13][2];
    for(new s; s != 13; s++) GetPlayerWeaponData(playerid, s, b_weaponammo[s][0], b_weaponammo[s][1]);
    ResetPlayerWeapons(playerid);
    for(new g; g != 13; g++)
    {
        if(b_weaponammo[g][0] == b_weapon || b_weaponammo[g][1] <= 0) continue;
		GivePlayerWeapon(playerid, b_weaponammo[g][0], b_weaponammo[g][1]);
		break;
    }
    return true;
}
Добавим команды:

PHP:
CMD:drop(playerid, params[])
{
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, 0xAFAFAFAA, "[!] Вы находитесь в транспорте.");
    if(GetPlayerWeapon(playerid) <= 0 && GetPlayerAmmo(playerid) <= 0) return SendClientMessage(playerid, 0xAFAFAFAA, "[!] Вы не имеете при себе оружие.");
    for(new g; g != MAX_GUNS; g++)
    {
        if(g > MAX_GUNS) return SendClientMessage(playerid, 0xAFAFAFAA, "[!] Вы не можете выбросить оружие. Превышен максимальный лимит.");
        B_RemovePlayerWeapon(playerid, GetPlayerWeapon(playerid));
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
        GetPlayerPos(playerid, Dgun[g][dPos][0], Dgun[g][dPos][1], Dgun[g][dPos][2]);
        Dgun[g][dWeapon] = GetPlayerWeapon(playerid);
        Dgun[g][dAmmo] = GetPlayerAmmo(playerid);
        Dgun[g][dVirtualWorld] = GetPlayerVirtualWorld(playerid);
        Dgun[g][dInterior] = GetPlayerInterior(playerid);
        Dgun[g][dID] = CreateDynamicObject(GunObjects[Dgun[g][dWeapon]], Dgun[g][dPos][0], Dgun[g][dPos][1], Dgun[g][dPos][2]-1, 93.7, 120.0, 120.0, Dgun[g][dVirtualWorld], Dgun[g][dInterior], -1, 300.0);
        GetWeaponName(Dgun[g][dWeapon], m_string, sizeof(m_string));
        format(f_string, sizeof(f_string), "Оружие %s и %d патронов.\n{00A86B}Введите: /take", m_string, Dgun[g][dAmmo]);
        Dgun[g][dLabel] = CreateDynamic3DTextLabel(f_string, 0xFFFF00AA, Dgun[g][dPos][0], Dgun[g][dPos][1], Dgun[g][dPos][2], 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, Dgun[g][dVirtualWorld], Dgun[g][dInterior], -1, 100.0);
        format(f_string, sizeof(f_string), "Вы выбросили оружие %s и %d патронов.", m_string, Dgun[g][dAmmo]);
        SendClientMessage(playerid, 0xFFA500AA, f_string);
        format(f_string, sizeof(f_string), "Выбросил оружие %s и %d патронов", m_string, Dgun[g][dAmmo]);
        SetPlayerChatBubble(playerid, f_string, 0xFF9900AA, 5.0, 3000);
        break;
    }
    return true;
}

CMD:take(playerid, params[])
{
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, 0xAFAFAFAA, "[!] Вы находитесь в транспорте.");
    for(new g; g != MAX_GUNS; g++)
	{
        if(!IsPlayerInRangeOfPoint(playerid, 1.0, Dgun[g][dPos][0], Dgun[g][dPos][1], Dgun[g][dPos][2])) continue;
        if(g > MAX_GUNS) return SendClientMessage(playerid, 0xAFAFAFAA, "[!] Вы не можете подобрать оружие. Превышен максимальный лимит.");
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
        DestroyDynamicObject(Dgun[g][dID]);
        DestroyDynamic3DTextLabel(Dgun[g][dLabel]);
        GivePlayerWeapon(playerid, Dgun[g][dWeapon], Dgun[g][dAmmo]);
        GetWeaponName(Dgun[g][dWeapon], m_string, sizeof(m_string));
        format(f_string, sizeof(f_string), "Вы подобрали оружие %s и %d патронов.", m_string, Dgun[g][dAmmo]);
        SendClientMessage(playerid, 0xFFA500AA, f_string);
        format(f_string, sizeof(f_string), "Подобрал оружие %s и %d патронов", m_string, Dgun[g][dAmmo]);
        SetPlayerChatBubble(playerid, f_string, 0xFF9900AA, 5.0, 3000);
        Dgun[g][dID] = -1;
        Dgun[g][dPos][0] = 0.0;
        Dgun[g][dPos][1] = 0.0;
        Dgun[g][dPos][2] = 0.0;
        Dgun[g][dWeapon] = -1;
        Dgun[g][dAmmo] = -1;
        Dgun[g][dVirtualWorld] = -1;
        Dgun[g][dInterior] = -1;
        break;
    }
    return true;
}
Внимание!
Чтобы редактировать количество объектов, измените число MAX_GUNS.

Автор: Botan().
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу