31
Modification Help / How to require sound downloading.
« on: February 16, 2016, 03:45:00 AM »
You could do the same thing with textures (I assume) with <bitmap> and a center print, if anyone wants to have a go at that.
Music can be done in a similar fashion.
If you use this, please change the filename and datablock name.
I decided against posting this in the Addons forum as this does require modification to achieve its purpose. Think of it as a library.
https://www.youtube.com/watch?v=vMdq1o-AkkY&t=0m27s
https://www.dropbox.com/s/g2coa2ldffecpcy/Server_RequireSounds.zip?dl=1
I can add more onto it if need be, this is moreso a proof of concept.
Music can be done in a similar fashion.
If you use this, please change the filename and datablock name.
I decided against posting this in the Addons forum as this does require modification to achieve its purpose. Think of it as a library.
Code: [Select]
$ServerSoundRequirementMsg = "I have heard this audio clip.";
function normalizeString(%str) {
return strLwr(stripChars(%str, "!@#$%^&*()_+-=[]{}\\|;':\",./<>?”“–"));
}
datablock AudioProfile(UniqueSound6iJu4)
{
filename = "./unique_sound_6iJu4.wav";
description = AudioClosest3d;
preload = true;
};
function GameConnection::loopSoundRequirementMessage(%this) {
cancel(%this.LSRMSched);
if(!%this.hasDownloadedSounds) {
%this.LSRMSched = %this.schedule(6000, loopSoundRequirementMessage);
}
%this.play2D(UniqueSound6iJu4);
}
package requireSoundsPackage {
function GameConnection::spawnPlayer(%this) {
if(!%this.hasDownloadedSounds) {
%this.loopSoundRequirementMessage();
return;
}
return parent::spawnPlayer(%this);
}
function serverCmdMessageSent(%this, %msg) {
if(!%this.hasDownloadedSounds) {
%normalized["req"] = normalizeString($ServerSoundRequirementMsg);
%normalized["msg"] = normalizeString(%msg);
if(%normalized["req"] $= %normalized["msg"]) {
%this.hasDownloadedSounds = 1;
%this.spawnPlayer();
cancel(%this.LSRMSched);
return;
}
}
return parent::serverCmdMessageSent(%this, %msg);
}
};
activatePackage(requireSoundsPackage);
https://www.youtube.com/watch?v=vMdq1o-AkkY&t=0m27s
https://www.dropbox.com/s/g2coa2ldffecpcy/Server_RequireSounds.zip?dl=1
I can add more onto it if need be, this is moreso a proof of concept.