DropPlayerItem

Сообщения
278
Реакции
137
Hello guys,
I am trying to block dropping a weapon. I try to use reapi instead of register_clcmd("drop"
But I see that this plugin doesn't see the name of weapon.

PHP:
RegisterHookChain(RG_CBasePlayer_DropPlayerItem, "@CBasePlayer_DropPlayerItem", .post=false);

@CBasePlayer_DropPlayerItem(const id, const itemname[])
{
    client_print_color(0, 0, itemname);
}
It shows my nickname everytime. Where is the mistake?
 

Ayk

Сообщения
763
Реакции
476
Помог
19 раз(а)
PurposeLess, item name can be empty:
Код:
// DropPlayerItem - drop the named item, or if no name, the active item.
CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName)
 
Сообщения
278
Реакции
137
Ayk, so how can i make them stop dropping a weapon?
I just want to block one weapon, not all of 'em
 

Ayk

Сообщения
763
Реакции
476
Помог
19 раз(а)
PurposeLess, if itemname[] is not empty then just use it, otherwise check active item.
 
Сообщения
2,722
Реакции
2,997
Помог
60 раз(а)
1594362492142.png
the plugin doesn't see the name of the weapon
https://github.com/s1lentq/ReGameDL...ba3d248f4cd82/regamedll/dlls/client.cpp#L3400
https://github.com/s1lentq/ReGameDL...493a8b9/regamedll/dlls/player.cpp#L7855-L7860

I just want to block one weapon, not all of 'em

GLOCK18 example (weapon will be removed after drop)
Код:
#include <amxmodx>
#include <reapi>

public plugin_init() {
    RegisterHookChain(RG_CBasePlayer_DropPlayerItem, "CBasePlayer_DropPlayerItem", .post = true);
}

public CBasePlayer_DropPlayerItem(const id, const itemname[])
{
    new pWeaponBox = GetHookChainReturn(ATYPE_INTEGER);
    if (is_nullent(pWeaponBox))
        return;

   // https://github.com/s1lentq/ReGameDLL_CS/blob/3878f46678049201fb35f00168c9f9e1f493a8b9/regamedll/dlls/player.cpp#L1282-L1283
    if (findWeaponInWeaponBox(pWeaponBox, WEAPON_GLOCK18))
        set_entvar(pWeaponBox, var_nextthink, 0.0);
}

bool: findWeaponInWeaponBox(const pWeaponBox, const WeaponIdType:weaponID) {
    for (new i = 0, weapon; i < MAX_ITEM_TYPES; i++) {
        weapon = get_member(pWeaponBox, m_WeaponBox_rgpPlayerItems, i);
        if(is_nullent(weapon))
            continue;

        new WeaponIdType:wid = get_member(weapon, m_iId);
        if (wid == weaponID)
            return true;
    }

    return false;
}
 
Последнее редактирование:
Сообщения
278
Реакции
137
The weapon has been deleted when I drop. Can't I make it not to be deleted with that command? It should work like that

PHP:
register_clcmd("drop", "drop");

public drop(id)
{
    return (get_user_weapon(id) == CSW_GLOCK18) ? 1 : 0;
}
+
PHP:
#include <amxmodx>
#include <reapi>

public plugin_init() {
    RegisterHookChain(RG_CBasePlayer_DropPlayerItem, "CBasePlayer_DropPlayerItem", .post = false);
}

public CBasePlayer_DropPlayerItem(const id, const itemname[])
{
    if(get_user_weapon(id) == CSW_GLOCK18)
    {
        SetHookChainReturn(ATYPE_INTEGER, false);
        return HC_SUPERCEDE;
    }

    return HC_CONTINUE;
}
 
Последнее редактирование:
Сообщения
192
Реакции
148
Помог
1 раз(а)
Ham_CS_Item_CanDrop


Код:
RegisterHam( Ham_CS_Item_CanDrop, "weapon_glock18", "CWeapon__CanDrop_Post", true );

public CWeapon__CanDrop_Post( const pItem )
{
    SetHamReturnInteger( 0 );
    return  HAM_SUPERCEDE;
}
 
Последнее редактирование:
Сообщения
1,182
Реакции
2,145
Помог
57 раз(а)
Ham_CS_Item_CanDrop ?
 
Сообщения
192
Реакции
148
Помог
1 раз(а)
Ayk, ну ладно HAM_OVERRIDE, разницы-то
 
Сообщения
192
Реакции
148
Помог
1 раз(а)
Ayk, мб ты попробуешь без ретурна и потом напишешь?
Можно и pre использовать
 
Последнее редактирование:

Ayk

Сообщения
763
Реакции
476
Помог
19 раз(а)
мб ты попробуешь без ретурна и потом напишешь?
Что тебе надо от меня? Сиди на своём уровне если нравится и не трогай меня.
ПОСТ функции уже не обращаются к движку. Значение ретурна им уже побоку.
 
Сообщения
2,143
Реакции
1,223
Помог
44 раз(а)
Ruby, так-то он прав. Или ты умеешь блокировать выполнение того, что уже было выполнено?! Если так, то ты ведьма и тебя нужно сжечь. ?
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу