Author Topic: how do i make it where when i join it makes a sound  (Read 2104 times)

I'm A-Spec here and I want to know how to make it where when i join it makes a sound

What sound? Like, a song? Or a default sound (like when an admin joins)?

I'm going to asume you want it to play a sound server sided when you join
Code: [Select]
package joinSound
{
function gameConnection::autoAdminCheck(%this)
{
if(%this.bl_id == 666)
{
ServerPlay2D(SoundName);
}
return parent::autoAdminCheck(%this);
}
};
ActivatePackage(joinSound);
first off you need to package the function autoAdminCheck (which is called on connection of anyone) so that it doesn't overwrite the original, next your gonna want to check if the player's blid is equal to yours, in this case im assuming you just want it for yourself, so replace "666" with your bl_id then your going to want to play a sound to the whole server, which you will have to specify, afterwards return parent, so as not to overwrite the original function
and for reasons I'm not actually sure of you need to return the parent on autoAdminCheck or a crash will eventually occur, probably due to a memory fragmentation

I'm going to asume you want it to play a sound server sided when you join
Code: [Select]
package joinSound
{
function gameConnection::autoAdminCheck(%this)
{
if(%this.bl_id == 666)
{
ServerPlay2D(SoundName);
}
return parent::autoAdminCheck(%this);
}
};
ActivatePackage(joinSound);
first off you need to package the function autoAdminCheck (which is called on connection of anyone) so that it doesn't overwrite the original, next your gonna want to check if the player's blid is equal to yours, in this case im assuming you just want it for yourself, so replace "666" with your bl_id then your going to want to play a sound to the whole server, which you will have to specify, afterwards return parent, so as not to overwrite the original function
and for reasons I'm not actually sure of you need to return the parent on autoAdminCheck or a crash will eventually occur, probably due to a memory fragmentation
You shouldn't return a parent iirc. Doesn't work.

You shouldn't return a parent iirc. Doesn't work.

...yes it does.

function three() { return 3; }
package alsoThree
{ function three() { return Parent::three(); } };
activatePackage("alsoThree");

You shouldn't return a parent iirc. Doesn't work.
You usually have to. It'll break things if you don't, for example if you parented mAbs but never returned the parent, mAbs would always return "".

You usually have to. It'll break things if you don't, for example if you parented mAbs but never returned the parent, mAbs would always return "".
However someone said somewhere that torque (and possibly C++) always returns the last line of a function, although I haven't confirmed it.  If so, then a large amount of packages where the parent isn't returned would still work fine.

However someone said somewhere that torque (and possibly C++) always returns the last line of a function, although I haven't confirmed it.  If so, then a large amount of packages where the parent isn't returned would still work fine.
This is partially correct. Torque defined functions are autoreturned. So, for example, this would work just fine:

function fcbn(%name) { findClientByName(%name); }

However, this would not work:

function av(%num) { mAbs(%num); }

I'm not really sure what causes this discrepancy, it can probably just be attributed to Torque's stufftiness.

Anyway, you're right that parent calls will get returned. In other scenarios, however, where you want to call the parent prior to your modification, the return value must be stored and later returned.