Raised This Month: $ Target: $400
 0% 

Multi-Plugin Support


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 07-16-2014 , 02:59   Multi-Plugin Support
Reply With Quote #1

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.
ReFlexPoison is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 07-16-2014 , 04:52   Re: Multi-Plugin Support
Reply With Quote #2

use your own forward
__________________
Taking private C++/PHP/SourcePawn requests, PM me.
Zephyrus is offline
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 07-16-2014 , 05:34   Re: Multi-Plugin Support
Reply With Quote #3

Quote:
Originally Posted by Zephyrus View Post
use your own forward
What do you mean?
ReFlexPoison is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 07-17-2014 , 13:52   Re: Multi-Plugin Support
Reply With Quote #4

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
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 07-17-2014 at 13:56.
friagram is offline
Requiesta
Senior Member
Join Date: May 2012
Location: Texas
Old 07-17-2014 , 23:39   Re: Multi-Plugin Support
Reply With Quote #5

-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?
__________________
YouTuber, Modder, Accountant, and somehow I still enjoy programming after all that.

Check out my YouTube Channel.

Last edited by Requiesta; 07-19-2014 at 12:47.
Requiesta is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 07-20-2014 , 08:57   Re: Multi-Plugin Support
Reply With Quote #6

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
__________________
Taking private C++/PHP/SourcePawn requests, PM me.
Zephyrus is offline
rswallen
SourceMod Donor
Join Date: Jun 2013
Location: 127.0.0.1
Old 07-20-2014 , 09:14   Re: Multi-Plugin Support
Reply With Quote #7

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)
__________________
rswallen is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:05.


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