#include <amxmodx>
#include <reapi>
const UNQUEID = 32; //minimum 32, because of there are max. 32 item ids.
public plugin_init()
{
register_plugin("Whose the weapon?", "2.1", "Indian Guy");
RegisterHookChain(RG_CBasePlayer_AddPlayerItem, "CBasePlayer_AddPlayerItem", .post = true);
register_dictionary("WhoseTheWeapon.txt");
}
public CBasePlayer_AddPlayerItem(pPlayer, pItem)
{
if (!GetHookChainReturn(ATYPE_INTEGER))
return;
new dontKnowWhat = get_entvar(pItem, var_iuser1);
if(dontKnowWhat < UNQUEID){
set_entvar(pItem, var_iuser1, get_user_userid(pPlayer) + UNQUEID);
return;
}
static piId, szName[MAX_NAME_LENGTH], szItemName[16];
piId = dontKnowWhat - UNQUEID;
if(get_user_userid(pPlayer)==piId){
get_entvar(pItem, var_classname, szItemName, charsmax(szItemName));
client_print_color(pPlayer, pPlayer, "%L", LANG_PLAYER, "WHOY", szItemName[7]);
return;
}
for (new i = 1; i <= MAX_CLIENTS; i++){
if(get_user_userid(i)==piId && is_user_connected(i)){
get_user_name(i, szName, charsmax(szName));
get_entvar(pItem, var_classname, szItemName, charsmax(szItemName));
client_print_color(pPlayer, i, "%L", LANG_PLAYER, "WHOM", szItemName[7], szName);
return;
}
}
}