Bug Report: if I exchange identical items with a bot, then the exchange can be done as much as you like (while the weapon changes to the main one with each exchange), but for example, exchanging a grenade for a Molotov will lead to the fact that I cannot exchange the received Molotov with any of the bots . It is required to go to idle and back in order to have a second opportunity to exchange.
I will clarify that items from other slots can still be tried to be exchanged until they also bug. An already bugged item cannot
P.S. I found that for me, as client 1, Event_WeaponDrop is called first, then OnWeaponEquip twice and again Event_WeaponDrop, which apparently resets the values in the cells g_iClientItem, g_iClientType. I still do not understand what the second Event_WeaponDrop calls, it is called before line 1481: if( IsFakeClient(target) ), but after line 1469: if( IsFakeClient(client) ). Here is the output of test PrintToChatAll:
PHP Code:
Zheldorg : 123
TransferItem step
TransferItem item 357
TransferItem item_ref -2065071771
TransferItem type 3
TransferItem type 3
TransferItem step 1
TransferItem step 2
TransferItem step IG
GiveItem step
Zheldorg обменял бомбу у Coach
Coach отдал желчь толстяка Zheldorg
Event_WeaponDrop step client 1
OnDrop step client 1
OnWeaponEquip client 1 weapon 514
OnWeaponEquip classname weapon_vomitjar
OnWeaponEquip ClientItem -2074799614
OnWeaponEquip ClientType 5
OnWeaponEquip client 1 weapon 514
OnWeaponEquip classname weapon_vomitjar
OnWeaponEquip ClientItem -2074799614
OnWeaponEquip ClientType 5
Event_WeaponDrop step client 1
OnDrop step client 1
OnWeaponEquip client 4 weapon 357
OnWeaponEquip classname weapon_pipe_bomb
OnWeaponEquip ClientItem -2065071771
OnWeaponEquip ClientType 4
TransferItem step finish
TransferItem client 1, ID0, Item 0, Type 0
TransferItem client 1, ID1, Item -2095976014, Type 6
TransferItem client 1, ID2, Item -2068115104, Type 1
P.S.S line 1556: int CreateAndEquip(int client, int type), on the left for different types, on the right exchange of identical objects. It can be seen that in the second option, OnWeaponEquip and Event_WeaponDrop for GivePlayerItem() are not called, but a new entity is created because it is clear that the if( entity != INVALID_ENT_REFERENCE ) condition is triggered
PHP Code:
CreateAndEquip step client 1 CreateAndEquip step client 1
Event_WeaponDrop step client 1
OnDrop step client 1
OnWeaponEquip client 1 weapon 357
OnWeaponEquip classname weapon_molotov
OnWeaponEquip ClientItem -2065071771
OnWeaponEquip ClientType 3
CreateAndEquip GivePlayerItem step client 1 CreateAndEquip GivePlayerItem step client 1
OnWeaponEquip client 1 weapon 357 OnWeaponEquip client 1 weapon 357
OnWeaponEquip classname weapon_molotov OnWeaponEquip classname weapon_molotov
OnWeaponEquip ClientItem -2065071771 OnWeaponEquip ClientItem -2065047195
OnWeaponEquip ClientType 3 OnWeaponEquip ClientType 3
Event_WeaponDrop step client 1 Event_WeaponDrop step client 1
OnDrop step client 1 OnDrop step client 1
CreateAndEquip EquipPlayerWeapon step client 1 CreateAndEquip EquipPlayerWeapon step client 1
GiveItem IsFakeClient Finish step client 1 GiveItem IsFakeClient Finish step client 1
GiveItem Front IsFakeClient step client 1 GiveItem Front IsFakeClient step client 1
OnWeaponEquip client 2 weapon 517 OnWeaponEquip client 2 weapon 484
OnWeaponEquip classname weapon_vomitjar OnWeaponEquip classname weapon_molotov
OnWeaponEquip ClientItem -2065845755 OnWeaponEquip ClientItem -2104466972
OnWeaponEquip ClientType 5 OnWeaponEquip ClientType 3
GiveItem Front IsFakeClient step target 2 GiveItem Front IsFakeClient step target 2
TransferItem step finish TransferItem step finish
TransferItem client 1, ID0, Item 0, Type 0 TransferItem client 1, ID0, Item -2065047195, Type 3
TransferItem client 1, ID1, Item -2137743001, Type 6 TransferItem client 1, ID1, Item -2137743001, Type 6
TransferItem client 1, ID2, Item -2033082097, Type 1 TransferItem client 1, ID2, Item -2033082097, Type 1
P.S.S.S void OnDrop(int client, int item), found out that the right case never passes if( item == g_iClientItem[client][i] )
P.S.S.S.S Everything looks like this: in "void GiveItem()" the client is a live player, the target is a bot, "if( transferType == METHOD_SWAP )" fires as "true", if( IsFakeClient(client) ) goes to "else ", detach the item from the bot RemovePlayerItem(target, ent_t) and destroy RemoveEdict(ent_t), call CreateAndEquip(client, type_t - 1), in the called one, create an object identical to the type that we destroyed earlier int entity = GivePlayerItem(client, classname), and here oddities arise , GivePlayerItem raises the event void Event_WeaponDrop in it, it tries to drop the object we have (this is clear from the comparison of int item = event.GetInt("propid") with g_iClientItem[client][' current slot']) since we did not untie our object beforehand (RemovePlayerItem(client, ent_c) will be called much later), then GivePlayerItem calls OnWeaponEquip to bind the newly created item to us, then EquipPlayerWeapon(client, entity) re-attaches the newly created item by calling OnWeaponEquip and then generates an event "Event_WeaponDrop", trying to drop an entity , although the item will not actually be dropped, in the OnDrop() function called next, the g_iClientItem and g_iClientType for the current item will be reset to zero, which will not allow the item to be exchanged again.
If the exchange is identical items, another nuance arises, int entity = GivePlayerItem(client, classname) will create an item, but will not call either Event_WeaponDrop or OnWeaponEquip. As a result, since the entity is correct, after if( entity != INVALID_ENT_REFERENCE ) EquipPlayerWeapon(client, entity) will be called, it will already call OnWeaponEquip for the newly created item, as well as Event_WeaponDrop but for the old non-detached item, in the OnDrop() function in the line if( item == g_iClientItem[client][i] ) will not match and g_iClientItem and g_iClientType will not be set to null. In general, all // TRANSFER code looks problematic from these shoving items.
OUTCOME
One line comment and a few line breaks seem to solve the problem. Attach l4d_gear_transfer.sp