Raised This Month: $ Target: $400
 0% 

emit_sound and stop with task


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mr.Bot
Member
Join Date: Mar 2007
Old 06-24-2007 , 14:29   emit_sound and stop with task
Reply With Quote #1

Hello i whant to add a task to play a sound for all player in the game and when i get out of my fenwick i whant the sound off.
I do this but it dosn't work can you help me plz thx

Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>

#define PLUGIN "Fenmaster"
#define VERSION "1.0"
#define AUTHOR "PsYcOpAtHe"

new aiment[33];
new oldmodel[33][33]
new allow[33]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("voiture","make_aiment");
    register_clcmd("supvoiture","delete_aiment");
    register_touch("player","player","crash")
}

public plugin_precache()
{
    precache_model("models/fenwick.mdl");
}

public make_aiment(id)
{
    if(!(get_user_flags(id) & ADMIN_KICK))
    {
        client_print(id,print_chat,"Tu n'a pas acces a cela n'esseye même pas !");
        return PLUGIN_HANDLED;
    }
    set_view(id, CAMERA_3RDPERSON)
    aiment[id] = create_entity("info_target");
    entity_set_model(aiment[id],"models/fenwick.mdl");
    entity_set_int(aiment[id],EV_INT_movetype,MOVETYPE_FOLLOW);
    entity_set_edict(aiment[id],EV_ENT_aiment,id);
    entity_set_int(aiment[id],EV_INT_sequence,1);
    entity_set_float(aiment[id],EV_FL_animtime,20.0);
    entity_set_float(aiment[id],EV_FL_framerate,1.0);
    allow[id] = 0
    
    set_task(3.0,"play_sound", id+34,"",0, "b")
    
    return PLUGIN_HANDLED
}

public crash(entid, id)
{
    if(allow[entid] == 1 || allow[id] == 1) 
        return PLUGIN_HANDLED
    
    if(aiment[id] && aiment[entid]) {
        new hp = get_user_health(entid)
        new hp2 = get_user_health(id)
        set_user_health(entid,(hp - 200))
        set_user_health(id,(hp2 - 200))
        set_user_info(id,"model",oldmodel[id])
        return PLUGIN_HANDLED
    }
    if(aiment[id]) {
        new hp = get_user_health(id)
        set_user_health(id,(hp - 10))
        return PLUGIN_HANDLED
    }
    if(aiment[entid]) {
        set_user_health(id,0)
        return PLUGIN_HANDLED
    }
    return PLUGIN_HANDLED
}

public delete_aiment(id)
{
    remove_entity(aiment[id])
    set_view(id, CAMERA_NONE)
    allow[id] = 1
    
    if(task_exists(id+34))
    {
        remove_task(id+34)
    }
}

public play_sound(taskid)
{
    new id = taskid - 34
    
    emit_sound(aiment[id], CHAN_VOICE, "apache/ap_rotor2.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
}
__________________


Mr.Bot is offline
potatis_invalido
BANNED
Join Date: Jul 2007
Location: 0 (world)
Old 08-01-2007 , 15:04   Re: emit_sound and stop with task
Reply With Quote #2

Quote:
Originally Posted by regalis View Post
I don't know if there is a better way, but in entity-think you can play the sound and set the next think at the end of the time the sound needs to play!?

Or in emit_sound there is a stop-flag (1<<5) maybe there is a flag for loop the sound!?
PHP Code:
#define SND_STOP (1<<5) 
PHP Code:
emit_sound(g_recharge_id[r], CHAN_WEAPON"HealthArmor-Stations/ArmorRecharge.wav"1.0ATTN_NORMSND_STOPPITCH_NORM); 
I needed this flag because this sound i used loop indefinitely...

greetz regalis

Last edited by potatis_invalido; 08-01-2007 at 15:07.
potatis_invalido 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 21:24.


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