Raised This Month: $ Target: $400
 0% 

Get classname from aiming


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KneeGrow
Junior Member
Join Date: Mar 2014
Old 07-29-2014 , 22:56   Get classname from aiming
Reply With Quote #1

I'm trying to help a friend make a doorbell plugin
Part of the plugin I want to add, but I don't know how to put it in to code
is verifying if what the player is looking at is a func_door_rotating

I've looked around for examples of how this type of thing could be used but I found nothing

Last edited by KneeGrow; 07-29-2014 at 22:56.
KneeGrow is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-30-2014 , 02:34   Re: Get classname from aiming
Reply With Quote #2

PHP Code:
new targetbodyszClassName32 ];
get_user_aiming(idtargetbody100);
pev(targetpev_classnameszClassNamecharsmax(szClassName));
if(
equal(szClassName"func_door_rotating"))
{
    
//do stuff

Sth like this?
HamletEagle is offline
KneeGrow
Junior Member
Join Date: Mar 2014
Old 07-30-2014 , 12:38   Re: Get classname from aiming
Reply With Quote #3

yeah, that worked
is there a way to play a sound locally?
KneeGrow is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 07-30-2014 , 12:44   Re: Get classname from aiming
Reply With Quote #4

emit_sound
baneado is offline
KneeGrow
Junior Member
Join Date: Mar 2014
Old 07-30-2014 , 13:03   Re: Get classname from aiming
Reply With Quote #5

i just took a swing at emit_sound, didn't work for me
maybe you guys can see what i did wrong
PHP Code:
new const doorbell[] = "sound/misc/doorbell.wav"

public plugin_precache(){
    
precache_sound(doorbell);
}
//public plugin_init stuff
//other class....
    
emit_sound(id,CHAN_AUTO,doorbell,VOL_NORM,ATTN_NORM,0,PITCH_NORM); 
i hear nothing when this code is executed
KneeGrow is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 07-30-2014 , 13:09   Re: Get classname from aiming
Reply With Quote #6

where did you put it?
baneado is offline
KneeGrow
Junior Member
Join Date: Mar 2014
Old 07-30-2014 , 13:11   Re: Get classname from aiming
Reply With Quote #7

after it checks if the player is looking at a door
then returns plugin handled

just in case, here is the whole thing

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

new const doorbell[] = "sound/misc/doorbell.wav"

public plugin_precache(){
    
precache_sound(doorbell);
}

public 
plugin_init(){

    
register_plugin("Doorbell","1.0","urAdingdong");
    
register_clcmd("say /doorbell","dingdong");

}

public 
dingdong(id){

    new 
targetbodyszClassName32 ]; 
    
get_user_aiming(idtargetbody100); 
    
pev(targetpev_classnameszClassNamecharsmax(szClassName)); 

    if(
equal(szClassName"func_door_rotating")) 
    { 
        
emit_sound(id,CHAN_AUTO,doorbell,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
        return 
PLUGIN_HANDLED;
    }

    
client_print(id,print_chat,"You must be near a door");
    return 
PLUGIN_HANDLED;


Last edited by KneeGrow; 07-30-2014 at 13:12.
KneeGrow is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 07-30-2014 , 13:16   Re: Get classname from aiming
Reply With Quote #8

you should check if player is alive to execute the function

the print isn't well, it must says: You must be aiming a door

put a print just before emit_sound to test if it's being called
baneado is offline
KneeGrow
Junior Member
Join Date: Mar 2014
Old 07-30-2014 , 13:25   Re: Get classname from aiming
Reply With Quote #9

Has been changed but I don't know what's with emit_sound
chat is printed but sound unheard
PHP Code:
if(is_user_alive(id))
    {
        if(
equal(szClassName"func_door_rotating")) 
        { 
            
emit_sound(id,CHAN_AUTO,doorbell,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
            
client_cmd(id,"say /me rings doorbell");
            return 
PLUGIN_HANDLED;
        }
        
client_print(id,print_chat,"[ARP] You must be looking at a door");
        return 
PLUGIN_HANDLED;
    }
    
client_print(id,print_chat,"You must be alive to do this");
    return 
PLUGIN_HANDLED
KneeGrow is offline
KneeGrow
Junior Member
Join Date: Mar 2014
Old 07-30-2014 , 13:45   Re: Get classname from aiming
Reply With Quote #10

I'm not sure if this means much
but I found this in console:

Unable to open sound/sound/misc/doorbell.wav for transfer

That occurs every time I load a map

Found the problem
and that console error DID mean much
I got the address wrong for the sound file :s

It's always those little things q.q

Last edited by KneeGrow; 07-30-2014 at 13:59.
KneeGrow 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 13:05.


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