About emit sound command in my plugin

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
109
Реакции
79
Помог
1 раз(а)
Ошибка
sound ending when you move away
ОС
Windows
Amx Mod X
AMX Mod X 1.8.3-dev+5151 (http://www.amxmodx.org)
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Dec 8 2017 15:24:08
Built from: https://github.com/alliedmodders/amxmodx/commit/7b3646a
Build ID: 5151:7b3646a
Core mode: JIT+ASM32
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.4.0.658-dev
Build date: 15:04:52 Aug 11 2018 (1582)
Build from: https://github.com/dreamstalker/rehlds/commit/0ce0af7
ReGamedll
ReGameDLL version: 5.7.0.312-dev
Build date: 07:53:34 May 31 2018
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/26db32e
Версия Metamod
Metamod-r v1.3.0.116, API (5:13)
Metamod-r build: 22:13:56 Feb 16 2018
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/cdefc71
Список метамодулей
[ 1] AMX Mod X     RUN   -    amxmodx_mm.dll         v1.8.3-dev+5151  ini  Start ANY
[ 2] Reunion RUN - reunion_mm.dll v0.1.0.92 ini Start Never
[ 3] FakeMeta RUN - fakemeta_amxx.dll v1.8.3-dev+5151 pl1 ANY ANY
[ 4] CStrike RUN - cstrike_amxx.dll v1.8.3-dev+5151 pl1 ANY ANY
[ 5] ReAPI RUN - reapi_amxx.dll v5.6.0.157-dev pl1 ANY Never
[ 6] Engine RUN - engine_amxx.dll v1.8.3-dev+5151 pl1 ANY ANY
6 plugins, 6 running
Список плагинов
[  1] Admin Base              1.8.3-dev+  AMXX Dev Team     admin.amxx       running
[ 2] Admin Commands 1.8.3-dev+ AMXX Dev Team admincmd.amxx running
[ 3] Admin Help 1.8.3-dev+ AMXX Dev Team adminhelp.amxx running
[ 4] Slots Reservation 1.8.3-dev+ AMXX Dev Team adminslots.amxx running
[ 5] Multi-Lingual System 1.8.3-dev+ AMXX Dev Team multilingual.am running
[ 6] Menus Front-End 1.8.3-dev+ AMXX Dev Team menufront.amxx running
[ 7] Commands Menu 1.8.3-dev+ AMXX Dev Team cmdmenu.amxx running
[ 8] Players Menu 1.8.3-dev+ AMXX Dev Team plmenu.amxx running
[ 9] Teleport Menu 1.8.3-dev+ AMXX Dev Team telemenu.amxx running
[ 10] Maps Menu 1.8.3-dev+ AMXX Dev Team mapsmenu.amxx running
[ 11] Plugin Menu 1.8.3-dev+ AMXX Dev Team pluginmenu.amxx running
[ 12] Admin Chat 1.8.3-dev+ AMXX Dev Team adminchat.amxx running
[ 13] Anti Flood 1.8.3-dev+ AMXX Dev Team antiflood.amxx running
[ 14] Scrolling Message 1.8.3-dev+ AMXX Dev Team scrollmsg.amxx running
[ 15] Info. Messages 1.8.3-dev+ AMXX Dev Team imessage.amxx running
[ 16] Admin Votes 1.8.3-dev+ AMXX Dev Team adminvote.amxx running
[ 17] NextMap 1.8.3-dev+ AMXX Dev Team nextmap.amxx running
[ 18] Nextmap Chooser 1.8.3-dev+ AMXX Dev Team mapchooser.amxx running
[ 19] TimeLeft 1.8.3-dev+ AMXX Dev Team timeleft.amxx running
[ 20] Pause Plugins 1.8.3-dev+ AMXX Dev Team pausecfg.amxx running
[ 21] Stats Configuration 1.8.3-dev+ AMXX Dev Team statscfg.amxx running
[ 22] Combo Sprite 1.2 Yek'-ta csd_combosprite running
[ 23] Camera Changer 1.0 XunTric camera.amxx running
[ 24] CSO Emotion 2.3 Dias+Yek'ta mr_emotion-2018 running
[ 25] Muzik Kutusu 1.0 Yek'-ta denemeeklenti9. debug
25 plugins, 25 running
Автор плагина
Yek'-ta
Версия плагина
1.0
Исходный код
#include <amxmodx>
#include <reapi>
#include <engine>
#include <fakemeta>
#include <xs>

new const SINIF[] = "MuzikKutusu";
#define SESDOSYASI "muslumgurseskimbilirkimler.wav"
#define SESSEVIYESI 0.7 // 0.1 yaparsanız farkı çok rahat anlarsınız.
#define KOYULDUSESI "buttons/latchunlocked2.wav"
new const KIMEDUYULACAK = 0; // 0 Müzik Kutusuna E basınca herkeste çalar, 1 sadece kullananda çalar.
#define SESEOLANUZAKLIK 0.9 //Değer ne kadar yüksek olursa, o kadar yakın olunmalı.
#define CALISIRKENGLOW 0.0, 0.0 , 255.0

new g_MapFile[64];
new bool: caldir
new yetkiliobjesi[33];
public plugin_init()
{
register_plugin("Muzik Kutusu", "1.0", "Yek'-ta")
set_task(5.0,"ObjeleriYukle")

register_clcmd( "csd_muzikkutusu", "MuzikKutusuMenu")
register_forward(FM_PlayerPreThink,"fw_prethink");
}
public fw_prethink(id)
{
if(!caldir){
if((pev(id, pev_button) & IN_USE))
{
static temp, target;
get_user_aiming(id, target, temp);

if(!pev_valid(target))
{
return FMRES_IGNORED;
}

new ents = 0
while((ents = find_ent_by_class(ents, SINIF)))
{
if(pev_valid(ents))
{
static classname[32];
pev(ents, pev_classname, classname, sizeof classname - 1);
if(equali(classname, SINIF) )
{
new uzaklik = get_entity_distance(id, ents)
if(uzaklik <= 60.0)
{
caldir=true;

if(get_entvar(ents, var_button) == 0){
new Float:originaldegistir[3];
get_entvar(ents, var_origin, originaldegistir)
rh_emit_sound2(ents, KIMEDUYULACAK == 0 ? 0 : id, CHAN_ITEM, SESDOSYASI, SESSEVIYESI, SESEOLANUZAKLIK, 0, PITCH_NORM, SND_SPAWNING, originaldegistir)
glowluobje(ents)
}
else {
rh_emit_sound2(ents, KIMEDUYULACAK == 0 ? 0 : id, CHAN_ITEM, SESDOSYASI, 0.0, SESEOLANUZAKLIK)
DestroyEntity(get_entvar(ents, var_button));
set_entvar(ents, var_button, 0)
}
set_task(1.5,"gerial")
}
}
}
}
}
}
return FMRES_IGNORED;
}
public gerial(){
caldir=false
}
public MuzikKutusuMenu(oyuncu){
if(get_user_flags(oyuncu) & ADMIN_RCON){
new menu, Menuz[512]

formatex(Menuz, charsmax(Menuz), "\y [ \rMuzik Kutusu\y]");

menu = menu_create(Menuz, "menu_devam")

formatex(Menuz, charsmax(Menuz), "\wMuzik Kutusu %s", yetkiliobjesi[oyuncu] == 0 ? "Olustur" : "Kaydet");
menu_additem(menu, Menuz, "1")

formatex(Menuz, charsmax(Menuz), "\w%s", yetkiliobjesi[oyuncu] == 0 ? "Yakinindaki Muzik Kutusunu Kaldir" : "Muzik Kutusunu Sag Cevir");
menu_additem(menu, Menuz, "3")

formatex(Menuz, charsmax(Menuz), "\w%s", yetkiliobjesi[oyuncu] == 0 ? "Muzik Kutularini Kaydet" : "Muzik Kutusunu Kaldir");
menu_additem(menu, Menuz, "2")


menu_display(oyuncu, menu, 0)
}

return PLUGIN_HANDLED
}
public efektver(obje){
new Float:originaldegistir[3];
get_entvar(obje, var_angles, originaldegistir)
if(originaldegistir[2] != 0){
originaldegistir[2] = originaldegistir[2]-15.0
set_entvar(obje, var_angles, originaldegistir);
set_task(0.01,"efektver",obje);
}
else {
rh_emit_sound2(obje, 0, CHAN_BODY, KOYULDUSESI)

}
}
public menu_devam(oyuncu, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)

return PLUGIN_HANDLED;
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)

new key = str_to_num(data)
if(!is_user_alive(oyuncu)){
client_print_color(oyuncu, print_team_blue, "^3Bu komut icin canli olmaniz gerekmektedir.")
}
switch(key)
{
case 1:
{
if(yetkiliobjesi[oyuncu] == 0){
ObjeleriOlustur(GetUser3Origin(oyuncu), 1, oyuncu, GetUser3Origin(oyuncu));
new Float:originaldegistir[3], Float:originaldegistir_oyuncu[3];
get_entvar(yetkiliobjesi[oyuncu], var_angles, originaldegistir)
get_entvar(oyuncu, var_angles, originaldegistir_oyuncu)

originaldegistir[1] = originaldegistir_oyuncu[1] - 90.0
originaldegistir[2] = originaldegistir[2] + 90.0
set_entvar(yetkiliobjesi[oyuncu], var_angles, originaldegistir);

efektver(yetkiliobjesi[oyuncu])
MuzikKutusuMenu(oyuncu)
}
else {
yetkiliobjesi[oyuncu] = 0
MuzikKutusuMenu(oyuncu)
}
}

case 2:
{
if(yetkiliobjesi[oyuncu] == 0){
save_allobject()
client_print_color(oyuncu, oyuncu, "^3Muzik Kutulari Kaydedildi.")
}
else {
client_print_color(oyuncu, oyuncu, "^3Muzik Kutusunu Kaldirdin.")
DestroyEntity(yetkiliobjesi[oyuncu])
yetkiliobjesi[oyuncu] = 0
MuzikKutusuMenu(oyuncu)
}

}
case 3:
{
if(yetkiliobjesi[oyuncu] == 0){
new ents = 0
while((ents = find_ent_by_class(ents, SINIF)))
{
if(pev_valid(ents))
{
static classname[32];
pev(ents, pev_classname, classname, sizeof classname - 1);
if(equali(classname, SINIF) )
{
new uzaklik = get_entity_distance(oyuncu, ents)
if(uzaklik <= 100.0)
{
DestroyEntity(ents)
client_print_color(oyuncu, oyuncu, "^3Yakinindaki Muzik Kutusu Kaldirildi.")
}
}
}
}
MuzikKutusuMenu(oyuncu)
}
else {
new Float:originaldegistir[3];
get_entvar(yetkiliobjesi[oyuncu], var_angles, originaldegistir)
originaldegistir[1] = originaldegistir[1] + 15.0
set_entvar(yetkiliobjesi[oyuncu], var_angles, originaldegistir);
MuzikKutusuMenu(oyuncu)
}
}
}
return PLUGIN_HANDLED;
}

public DestroyEntity(ent) {
if (is_entity(ent))
set_entvar(ent, var_flags, get_entvar(ent, var_flags) | FL_KILLME);
}

stock Float:GetUser3Origin(id)
{
new Float:originf[3]
get_entvar(id, var_origin, originf);
originf[2] = originf[2]-35.0
return originf;
}

public ObjeleriYukle(){
new map[32]
get_mapname(map, 31)
format(g_MapFile, sizeof(g_MapFile), "maps/%s.mkutu.cfg", map)
if (file_exists(g_MapFile)) {
new data[124], len
new line = 0
new coord[5][8]
new Float:origin[3]
new Float:originaldegistir[3];
while((line = read_file(g_MapFile , line , data , 123 , len)))
{
if (len < 2 || data[0] == ';' || data[0] == '/')
continue;
parse(data, coord[0], 7, coord[1], 7, coord[2], 7, coord[3], 7)
origin[0] = (str_to_float(coord[0]))
origin[1] = (str_to_float(coord[1]))
origin[2] = (str_to_float(coord[2]))
originaldegistir[1] = (str_to_float(coord[3]))
originaldegistir[0] = 0.0
originaldegistir[2] = 0.0
ObjeleriOlustur(origin, 0, 0, originaldegistir)
}
}
}
public save_allobject() {
delete_file(g_MapFile)
new ent = NULLENT
new Float:fOrigin[3], line[64]
new Float:originaldegistir[3];
while ((ent = rg_find_ent_by_class(ent, SINIF))) {
get_entvar(ent, var_origin, fOrigin)
get_entvar(ent, var_angles, originaldegistir)
formatex(line, sizeof(line), "%0.3f %0.3f %0.3f %0.3f", fOrigin[0], fOrigin[1], fOrigin[2], originaldegistir[1])
write_file(g_MapFile, line)
}
}
stock glowluobje(obje)
{
new pEntity = rg_create_entity("info_target");
if(!pEntity)
return 1;

new Float:originaldegistir[3];
get_entvar(obje, var_origin, originaldegistir)
set_entvar(pEntity, var_classname, "GLOWLUSINIF");
set_entvar(pEntity, var_origin, originaldegistir);
entity_set_model(pEntity, "models/csd_muzikkutusu.mdl");

set_entvar(pEntity, var_body, 1);
get_entvar(obje, var_angles, originaldegistir)
set_entvar(pEntity, var_angles, originaldegistir);
new Float:mins[3] = { -26.67,-62.04,-24.68 }
set_entvar(pEntity, var_mins, mins)

new Float:maxs[3] = { 2.54,19.69,25.82 }
set_entvar(pEntity, var_maxs, maxs)
new Float:size[3]
math_mins_maxs(mins, maxs, size)
set_entvar(pEntity, var_size, size)

set_entvar(pEntity,var_movetype,MOVETYPE_TOSS)
set_entvar(pEntity,var_solid,SOLID_BBOX)


drop_to_floor(pEntity)
set_entvar(pEntity, var_renderfx, kRenderFxGlowShell);
set_entvar(pEntity, var_rendercolor, Float:{CALISIRKENGLOW});

set_entvar(obje, var_button, pEntity)

return pEntity;
}
stock ObjeleriOlustur(Float:fOrigin[3], skin,oyuncu, Float:originaldegistir[3])
{
new pEntity = rg_create_entity("info_target");
if(!pEntity)
return 1;
set_entvar(pEntity, var_classname, SINIF);
set_entvar(pEntity, var_origin, fOrigin);
entity_set_model(pEntity, "models/csd_muzikkutusu.mdl");

set_entvar(pEntity, var_skin, skin);
if(skin == 0){
set_entvar(pEntity, var_angles, originaldegistir);
new Float:mins[3] = { -26.67,-62.04,-24.68 }
set_entvar(pEntity, var_mins, mins)

new Float:maxs[3] = { 2.54,19.69,25.82 }
set_entvar(pEntity, var_maxs, maxs)
new Float:size[3]
math_mins_maxs(mins, maxs, size)
set_entvar(pEntity, var_size, size)

set_entvar(pEntity,var_movetype,MOVETYPE_TOSS)
set_entvar(pEntity,var_solid,SOLID_BBOX)
set_entvar(pEntity, var_button, 0)
}
else{
set_entvar(pEntity,var_movetype,MOVETYPE_NONE)
yetkiliobjesi[oyuncu] = pEntity
}

drop_to_floor(pEntity)
return pEntity;
}
math_mins_maxs(const Float:mins[3], const Float:maxs[3], Float:size[3])
{
size[0] = (xs_fsign(mins[0]) * mins[0]) + maxs[0]
size[1] = (xs_fsign(mins[1]) * mins[1]) + maxs[1]
size[2] = (xs_fsign(mins[2]) * mins[2]) + maxs[2]
}
public plugin_precache()
{
precache_model("models/csd_muzikkutusu.mdl");
precache_sound(SESDOSYASI)
precache_sound(KOYULDUSESI)
}
Hi, I am writing new plugin and I have a problem about emit sound command. This is a jukebox plugin. My problem is, if you move away from jukebox, the sound ends. And when you move back to jukebox you don't hear sound. I did everything my knowing, but I didn't. :dntknw:

How can I do?
And sorry for my code. When I write I am writing in Turkish.
The sound in line 56.
Код:
rh_emit_sound2(ents, KIMEDUYULACAK == 0 ? 0 : id, CHAN_ITEM, SESDOSYASI, SESSEVIYESI, SESEOLANUZAKLIK, 0, PITCH_NORM, SND_SPAWNING, originaldegistir)
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
1,420
Реакции
2,511
Помог
58 раз(а)
Yek'-ta, because you cannot send an audio to an ent. You need to send the audio to the players.
 
Сообщения
109
Реакции
79
Помог
1 раз(а)
But I want to decrease sound step by step when players move away from entity. Please watch my video and You will understand my saying.
 
Сообщения
109
Реакции
79
Помог
1 раз(а)
I found the problem, problem is sound file. When I use Opera.wav (cs_italy), there is no problem. Ok.
But has another problem. Sometimes it isn't stop when use again button. So, I had break this plugin.
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу