Page 1 of 1

Whoose the weapon (it SPAM)

Posted: 31 Jan 2018, 21:00
by ArminC
Can you format this plugin in order to not to spam the chat everytime: You picked weapon x of player y trough.. moving it like under the crosshair (as no radio flood from below) or make a delay.. or choose yourself whatever is best..

Code: Select all

#include <amxmodx>
#include <reapi>

#if !defined client_print_color || !defined MAX_NAME_LENGTH
    #error NOTSUPPORT AMXX < 1.8.3!
#endif

#define _GetItemInfo_iId(%1)    rg_get_iteminfo(%1, ItemInfo_iId)
#define _SetItemInfo_iId(%1,%2)    rg_set_iteminfo(%1, ItemInfo_iId, %2)

const UNQUEID = 32; //minimum 32, because of there are max. 32 item ids.

public plugin_init()
{
    register_plugin("Whose The Weapon", "2.1", "Yek'-ta");
    RegisterHookChain(RG_CBasePlayer_AddPlayerItem, "CBasePlayer_AddPlayerItem", .post = true);
}

public CBasePlayer_AddPlayerItem(pPlayer, pItem)
{
    if(_GetItemInfo_iId(pItem) < UNQUEID){
        _SetItemInfo_iId(pItem, get_user_userid(pPlayer) + UNQUEID);
        return;
    }

    static piId, szName[MAX_NAME_LENGTH], szItemName[16];
    piId = _GetItemInfo_iId(pItem) - UNQUEID;

    if(get_user_userid(pPlayer)==piId){
        rg_get_iteminfo(pItem, ItemInfo_pszName, szItemName, charsmax(szItemName));

        client_print_color(pPlayer, pPlayer, "^1You picked up the weapon ^4%s ^1of ^3your own", 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));
            rg_get_iteminfo(pItem, ItemInfo_pszName, szItemName, charsmax(szItemName));

            client_print_color(pPlayer, i, "^1You picked up the weapon ^4%s ^1of player ^3%s", szItemName[7], szName);
            return;
        }
    }
    return;
}

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 12:58
by Raheem
Try:

Code: Select all

#include <amxmodx>
#include <reapi>

#if !defined client_print_color || !defined MAX_NAME_LENGTH
    #error NOTSUPPORT AMXX < 1.8.3!
#endif

#define _GetItemInfo_iId(%1)    rg_get_iteminfo(%1, ItemInfo_iId)
#define _SetItemInfo_iId(%1,%2)    rg_set_iteminfo(%1, ItemInfo_iId, %2)

const UNQUEID = 32; //minimum 32, because of there are max. 32 item ids.

new Float:g_flLastShown[33], g_pCvarFloodTime

public plugin_init()
{
    register_plugin("Whose The Weapon", "2.1", "Yek'-ta");
    RegisterHookChain(RG_CBasePlayer_AddPlayerItem, "CBasePlayer_AddPlayerItem", .post = true);
	
	g_pCvarFloodTime = register_cvar("wpu_flood_time", "0.1")
}

public CBasePlayer_AddPlayerItem(pPlayer, pItem)
{
    if(_GetItemInfo_iId(pItem) < UNQUEID){
        _SetItemInfo_iId(pItem, get_user_userid(pPlayer) + UNQUEID);
        return;
    }

    static piId, szName[MAX_NAME_LENGTH], szItemName[16];
    piId = _GetItemInfo_iId(pItem) - UNQUEID;

    if(get_user_userid(pPlayer)==piId){
		
        rg_get_iteminfo(pItem, ItemInfo_pszName, szItemName, charsmax(szItemName));
		
		if ((get_gametime() - g_flLastShown[pPlayer]) > get_pcvar_float(pCvarFloodTime))
		{
			client_print_color(pPlayer, pPlayer, "^1You picked up the weapon ^4%s ^1of ^3your own", szItemName[7]);
			g_flLastUsed[pPlayer] = get_gametime()
		}
		
        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));
            rg_get_iteminfo(pItem, ItemInfo_pszName, szItemName, charsmax(szItemName));
			
			if ((get_gametime() - g_flLastShown[pPlayer]) > get_pcvar_float(pCvarFloodTime))
			{
				client_print_color(pPlayer, i, "^1You picked up the weapon ^4%s ^1of player ^3%s", szItemName[7], szName);
				g_flLastUsed[pPlayer] = get_gametime()
			}

            return;
        }
    }
    return;
}

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 13:00
by ArminC
Thanks, can u explain shortly what it does? 0.1 delay isn't effect-less? Or.. I get it wrong?

And it's even possible a method like Hud Message when you aim the weapon? (Like you aim your teammate) and will this eat more from cpu?

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 13:03
by Raheem
Set delay in this CVAR: wpu_flood_time 0.01 or any value, One chat message only will be displayed and the second one will need to wait the delay you made to be displayed. This maybe fix the flood just make good value for the delay and it's OK.

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 13:05
by ArminC
I got it. Thanks :) but I'am still thinking betwen the methods.. everyone has a down-side and I can't decide..

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 13:08
by Raheem
What you mean?

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 13:14
by ArminC
I don't finished my message.. I forgot in in the other tab.. :lol: Let's continue:

1) Chat message (With flood management) - Nice colored message but if you pick fast another weapon it can cancel the message.. and it still flood the chat somehow if I put minimal value
2) Print message under crosshair.. -Non colored message.. maybe good? but it can de-focus your vision.. because is under crosshair
3) Hud Messaage - When you aim at a gun.. to show the player's gun name.. like you aim at your teammate and says his name but.. in my opinion is the best one but ..it's odd.. I don't know.. + more resource eat??
4) Other that I still didn't think of? like putting a small name right to the clock or.. ffff..

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 13:20
by Raheem
You confused me, What the code you published does? What i make is just a delay.

Best thing for this is to use Center Chat Message or HUD Text Message.

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 13:23
by ArminC
What does? It says who's the weapon that I picked.

And I said that I don't know wich variant is better :(

Did you get what I meant by saying to aim at weapon and show in a hud last weapon's player? it's a good ideea or a bad ideea?

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 13:45
by Raheem
What i understand is that this need a delay and i added. I don't test the plugin, So now you need to add to it if you aim at weapon while it's on ground to tells you who was it's owner?

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 14:31
by ArminC
I don't know.. I ask your opinon.. it's better in this way..? with aim at weapon?

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 18:09
by Raheem
On pickup maybe better? And a Center chat message will be good, or randomly colored HUD text message.

Re: Whoose the weapon (it SPAM)

Posted: 07 Feb 2018, 18:37
by ArminC
Yeah, make as you think.. :)

- Something to don't flood .. like the chat should be more clear.. because I can lose some players.. messages.
- Something that don't "skip" some pickup like flood time.. but in same time avoid the "flood"
- Something that don't "defocus" you from the gameplay

Re: Whoose the weapon (it SPAM)

Posted: 26 Feb 2018, 15:32
by ArminC
Raheem wrote: 6 years ago On pickup maybe better? And a Center chat message will be good, or randomly colored HUD text message.
Bump?