Raised This Month: $ Target: $400
 0% 

Solved [HELP] Emit Sound on Coordinates


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-04-2019 , 05:55   Re: [HELP] Emit Sound on Coordinates
Reply With Quote #10

Quote:
Originally Posted by hellmonja View Post
What I intend to do is when a player fires a gun, 4 points forming a cross relative to his coordinates will be the origin of the emitted sound. Height is fixed by the way, just +100.0 of the players coord. All I did was duplicate the code four times with 4 different combinations of coordinates:
Name:  sinister0009.jpg
Views: 733
Size:  95.4 KB

So you want a sound to match muzzle blast? In other words the opposite of Bullet Whizz which is on the receiving end.

Quote:
Originally Posted by hellmonja View Post
So far emit_sound needs an entity to produce the sound from. I'm wondering if you can emit a sound in 3D space using just coordinates. Is there a separate function for this? Or module of sorts I don't know of?...
The sound doesn't need 4 more ents when you already have 1, the player there firing the weapon.

These 2 figures show what 50 looks like from the abstract from either using pev_origin or get_user_origin. Former is standing over the head while other is piggy back ride at 50.

Name:  crossfire-mdl0013.jpg
Views: 719
Size:  87.0 KB
Code:
        new Float:origin[3];         pev(id,pev_origin,origin);         new Float:mins[3], Float:maxs[3]         mins[0] = origin[0] - 15.0         mins[1] = origin[1] - 15.0         mins[2] = origin[2] + 25.0         maxs[0] = origin[0] + 15.0         maxs[1] = origin[1] + 15.0         maxs[2] = origin[2] + 2.0         message_begin(0,23);         write_byte(TE_BOX);         write_coord(floatround(mins[0]));         write_coord(floatround(mins[1]));         write_coord(floatround(mins[2]));         write_coord(floatround(maxs[0]));         write_coord(floatround(maxs[1]));         write_coord(floatround(maxs[2]));         write_short(random_num(500,1000));   //(life in 0.1's)         write_byte(random_num(50,255));     //(red)         write_byte(random_num(50,255));   //(green)         write_byte(random_num(0,255));   //(blue)         message_end();
Name:  op4ctf_dam0029.jpg
Views: 679
Size:  15.3 KB

By the way 5 sounds being fired off per round may cause performance issues. Emit already emits. Quit while you are ahead. The code you are using accomplishes the same as emit_sound but it is a while lot more complex and easier to crash sending messages instead of simply using emit_sound. You are over-complicating not using emit_sound just to reinvent the wheel with this. The sound still passes through the player just a few coordinates away. So then, it is here, instead of there. The oth dimension {0,0,0} is what you see 99.9% of the code around the world over. Just a dot. Moving outside the box is not that complicated. You have your chickens to help you do that now.

Use MSG_PAS as it will use least resources. MSG_ONE sends it to people on other side of map who can't hear it anyway as well as increase crash likelihood down the line.
__________________

Last edited by DJEarthQuake; 10-04-2019 at 05:57.
DJEarthQuake 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 02:50.


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