Raised This Month: $ Target: $400
 0% 

Entity Use (Like a button)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-18-2015 , 17:53   Entity Use (Like a button)
Reply With Quote #1

I'm trying to make a plugin that spawns entities that behave like buttons, let's say it that way.
But whenever I spawn it and try to use it, nothing happens. (Simply stand close to it, press my use key "e" like to any other button/entity, and It's supposed to print out "Button Press", but nothing)

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>

new g_Classname[] = "wboxexample";
new 
g_Model[] = "models/w_weaponbox.mdl";

public 
plugin_init()
{
    
register_plugin("Button Entity""1.0""redivcram");
   
    
RegisterHam(Ham_Use"func_button""EvUse"0);
   
    
register_clcmd("say /wb""CmdWB");
}

public 
plugin_precache()
{
    
precache_model(g_Model);
}

public 
CmdWB(id)
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
    new 
Float:origin[3];
    
fm_get_aim_origin(idorigin);
    
    
set_pev(entpev_classnameg_Classname);
    
engfunc(EngFunc_AllocString"func_button");
    
set_pev(entpev_target"weaponbox_test");
    
engfunc(EngFunc_SetModelentg_Model);
    
engfunc(EngFunc_SetSizeentFloat:{-25.0, -25.0, -25.0}, Float:{25.025.025.0});
    
set_pev(entpev_solidSOLID_BBOX);
    
engfunc(EngFunc_SetOriginentorigin);
}

public 
EvUse(entid)
{    
    if(!
is_user_alive(id))
        return 
HAM_IGNORED;
    
    new 
target[33];
    
pev(entpev_targettargetsizeof (target) - 1);

    if(
equali(target"weaponbox_test"))
    {
        
client_print(idprint_chat"Button Press");
    }
    return 
HAM_IGNORED;

redivcram is offline
 



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 22:18.


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