Whoose the weapon (it SPAM)

Coding Help/Re-API Supported
User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

Whoose the weapon (it SPAM)

#1

Post by ArminC » 1 Year 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
Egypt
Posts: 1866
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 98 times
Age: 21
Contact:

#2

Post by Raheem » 1 Year 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;
}
You don't know? Learn and you will know.

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#3

Post by ArminC » 1 Year 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
Egypt
Posts: 1866
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 98 times
Age: 21
Contact:

#4

Post by Raheem » 1 Year 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.
You don't know? Learn and you will know.

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#5

Post by ArminC » 1 Year 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
Egypt
Posts: 1866
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 98 times
Age: 21
Contact:

#6

Post by Raheem » 1 Year Ago

What you mean?
You don't know? Learn and you will know.

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#7

Post by ArminC » 1 Year 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
Egypt
Posts: 1866
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 98 times
Age: 21
Contact:

#8

Post by Raheem » 1 Year 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.
You don't know? Learn and you will know.

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#9

Post by ArminC » 1 Year 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
Egypt
Posts: 1866
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 98 times
Age: 21
Contact:

#10

Post by Raheem » 1 Year 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?
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests