I tried the following code but it crashed HLDS
PHP Code:
new shield_entity;
if ( cs_get_user_shield ( id ) )
{
engclient_cmd ( id, "drop", "weapon_shield" );
shield_entity = find_ent_by_owner ( -1, "weapon_shield", id );
}
client_print ( id, print_chat, "SHIELD DETACHED" );
/*engclient_cmd ( id, "drop", "weapon_<pistol>" )*/
if ( is_valid_ent ( shield_entity ) && ExecuteHamB ( Ham_AddPlayerItem, id, shield_entity ) )
ExecuteHamB ( Ham_Item_AttachToPlayer, shield_entity, id );
client_print ( id, print_chat, "SHIELD ATTACHED" );
Also tried using fake_touch ( id, hasShield ), ExecuteHam ( Ham_Touch, id, hasShield ) - No Result.
Basically my main aim is to drop the pistol attached to the player rather than the shield on engclient_cmd ( id, "drop", "weapon_<pistol>" ). so i am using engclient_cmd ( id, "drop", "weapon_shield" ) and then engclient_cmd ( id, "drop", "weapon_<pistol>" ) to detach the pistol and then I wish to reattach the shield. I am able to get the entity index of the shield but I don't know how to attach it back.