AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   TF2Items (https://forums.alliedmods.net/forumdisplay.php?f=146)
-   -   Multi-Plugin Support (https://forums.alliedmods.net/showthread.php?t=244265)

ReFlexPoison 07-16-2014 02:59

Multi-Plugin Support
 
I talked to Voided about using the OnGiveNamedItem to edit a weapon's attributes through multiple plugins. I got it to work, then I ran into some complications. Sadly, since I have to take into consideration that handles don't close themselves, the code has to be adjusted properly to get it to work.

At the moment I have this:
PHP Code:

public Action:TF2Items_OnGiveNamedItem(iClientString:strClassname[], iIndex, &Handle:hItem)
{
    static 
Handle:hNewItem INVALID_HANDLE;
    if(
hNewItem != INVALID_HANDLE)
    {
        
CloseHandle(hNewItem);
        
hNewItem INVALID_HANDLE;
    }

    if(
hItem == INVALID_HANDLE)
    {
        
hItem TF2Items_CreateItem(OVERRIDE_ATTRIBUTES PRESERVE_ATTRIBUTES);
        
hNewItem hItem;
    }

    
TF2Items_SetAttribute(hItemiAttributeiAttributeIndexiAttributeValue);
    return 
Plugin_Changed;
}

public 
Action:TF2Items_OnGiveNamedItem(iClientString:strClassname[], iIndex, &Handle:hItem)
{
    static 
Handle:hNewItem INVALID_HANDLE;
    if(
hNewItem != INVALID_HANDLE)
    {
        
CloseHandle(hNewItem);
        
hNewItem INVALID_HANDLE;
    }

    if(
hItem == INVALID_HANDLE)
    {
        
hItem TF2Items_CreateItem(OVERRIDE_ATTRIBUTES);
        
hNewItem hItem;
    }

    
TF2Items_SetAttribute(hItemiAttributeiAttributeIndexiAttributeValue);
    return 
Plugin_Changed;


I'm looking to strip the attributes of the weapon, but include both the new attributes I'm attempting to load onto the weapon. (One uses PRESERVE_ATTRIBUTES, while the other does not) I'd appreciate any tips.

Zephyrus 07-16-2014 04:52

Re: Multi-Plugin Support
 
use your own forward

ReFlexPoison 07-16-2014 05:34

Re: Multi-Plugin Support
 
Quote:

Originally Posted by Zephyrus (Post 2168539)
use your own forward

What do you mean?

friagram 07-17-2014 13:52

Re: Multi-Plugin Support
 
What's the problem?
Static the handle to invalid in ogni as you are, the close if if it's not.
Then it's invalid, set it so (no need to check again...)
And do your stuff.

You only use one forward.
Ogni gets called each time a player gets an item, that's the point of a global forward.
https://wiki.alliedmods.net/Function...lobal_Forwards

Requiesta 07-17-2014 23:39

Re: Multi-Plugin Support
 
-snip-

-snip snip- I don't think friar's post helps either.

Right now if two plugins use OnGiveNamedItem whichever one is called last is the one that works. Is there a way to use this particular function in multiple plugins without having them lapse each other or have this phenomena occur?

Zephyrus 07-20-2014 08:57

Re: Multi-Plugin Support
 
use a single plugin that uses tf2items, have that plugin send out a new forward to every single plugin that registered to use it and merge their returns

rswallen 07-20-2014 09:14

Re: Multi-Plugin Support
 
if (hItem != INVALID_HANDLE), create a new item and merge the existing flags/attributes (get attribute count, loop through them, add the new, modify the dupes)


All times are GMT -4. The time now is 21:31.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.