Whoose the weapon (it SPAM)

Coding Help/Re-API Supported
Post Reply
User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

Whoose the weapon (it SPAM)

#1

Post by ArminC » 6 years ago

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;
}

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 6 years ago

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;
}
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#3

Post by ArminC » 6 years ago

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?

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#4

Post by Raheem » 6 years ago

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.
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#5

Post by ArminC » 6 years ago

I got it. Thanks :) but I'am still thinking betwen the methods.. everyone has a down-side and I can't decide..

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#6

Post by Raheem » 6 years ago

What you mean?
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#7

Post by ArminC » 6 years ago

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..

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#8

Post by Raheem » 6 years ago

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.
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#9

Post by ArminC » 6 years ago

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?

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#10

Post by Raheem » 6 years ago

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?
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#11

Post by ArminC » 6 years ago

I don't know.. I ask your opinon.. it's better in this way..? with aim at weapon?

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#12

Post by Raheem » 6 years ago

On pickup maybe better? And a Center chat message will be good, or randomly colored HUD text message.
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#13

Post by ArminC » 6 years ago

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

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#14

Post by ArminC » 6 years ago

Raheem wrote: 6 years ago On pickup maybe better? And a Center chat message will be good, or randomly colored HUD text message.
Bump?

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 10 guests