AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get classname from aiming (https://forums.alliedmods.net/showthread.php?t=245225)

KneeGrow 07-29-2014 22:56

Get classname from aiming
 
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

HamletEagle 07-30-2014 02:34

Re: Get classname from aiming
 
PHP Code:

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


Sth like this?

KneeGrow 07-30-2014 12:38

Re: Get classname from aiming
 
yeah, that worked
is there a way to play a sound locally?

baneado 07-30-2014 12:44

Re: Get classname from aiming
 
emit_sound

KneeGrow 07-30-2014 13:03

Re: Get classname from aiming
 
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

baneado 07-30-2014 13:09

Re: Get classname from aiming
 
where did you put it?

KneeGrow 07-30-2014 13:11

Re: Get classname from aiming
 
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;



baneado 07-30-2014 13:16

Re: Get classname from aiming
 
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

KneeGrow 07-30-2014 13:25

Re: Get classname from aiming
 
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 07-30-2014 13:45

Re: Get classname from aiming
 
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


All times are GMT -4. The time now is 13:06.

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