Raised This Month: $51 Target: $400
 12% 

Return entity of func_button


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pride95
Senior Member
Join Date: Aug 2015
Old 01-20-2018 , 06:46   Return entity of func_button
Reply With Quote #1

When you press a button, you move/destroy/rotate an entity. I need to get that entity which is destroyed, rotated etc.

something like this
PHP Code:
public void Event_PlayerButton(char[] outputint callerint activatorfloat any)
{
    
int iTarget GetKeyValue(caller"target");
    
LogMessage("%i"iTarget);

pride95 is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-20-2018 , 08:24   Re: Return entity of func_button
Reply With Quote #2

Maybe something like this could work:

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnPluginStart()
{
    
FindAndHookButtons();
}

public 
OnMapStart()
{
    
FindAndHookButtons();
}

public 
FindAndHookButtons()
{
    for(new 
entity MaxClients;entity GetMaxEntities();entity++)
    {
        if(
IsValidEntity(entity) && IsValidEdict(entity))
        {
            
decl String:className[128];
            
GetEntityClassname(entityclassNamesizeof(className));
            
            if(
StrEqual(className"func_button"false) || StrEqual(className"func_rot_button"false) || StrEqual(className"func_weight_button"false) || StrEqual(className"momentary_rot_button"false))
            {
                
SDKHook(entitySDKHook_UseUseButton);
            }
        }
    }
}

public 
UseButton(buttonclient

    
PrintToChatAll("%N used button %i"clientbutton);

Note: it's untested
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
pride95
Senior Member
Join Date: Aug 2015
Old 01-20-2018 , 09:09   Re: Return entity of func_button
Reply With Quote #3

this returns the button itself as an entity. i need the target of the button.
pride95 is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-20-2018 , 09:14   Re: Return entity of func_button
Reply With Quote #4

Quote:
Originally Posted by pride95 View Post
this returns the button itself as an entity. i need the target of the button.
Awh well depending on the entity it can have a series of outputs to other entities. Not sure how you'd track the internal scripting languages outputs
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
pride95
Senior Member
Join Date: Aug 2015
Old 01-20-2018 , 10:55   Re: Return entity of func_button
Reply With Quote #5

Quote:
Originally Posted by 1337norway View Post
Awh well depending on the entity it can have a series of outputs to other entities. Not sure how you'd track the internal scripting languages outputs
maybe i should hook in onentitycreated the entity which has a parent func_button?
pride95 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-22-2018 , 16:09   Re: Return entity of func_button
Reply With Quote #6

You need to read the outputs of the given entity. Unfortunately Sourcepawn doesnt have a way to acheive this that im aware of.

If you check out the Stripper extension you could potentially see how it hooks in.
__________________
Neuro Toxin 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 20:22.


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