Skip to content

Commit

Permalink
Changed fxmanifest version to cerulean
Browse files Browse the repository at this point in the history
If player isnt close to the music it will reset position to -90000x,y,z
Removed function "isMuted" because few people experienced bugs with it.
  • Loading branch information
Xogy committed Apr 22, 2021
1 parent ce9cfe3 commit 151ccc3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 28 deletions.
5 changes: 3 additions & 2 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ CreateThread(function()
z = pos.z
})
else
Wait(500)
SendNUIMessage({ status = "position", x = -900000, y = -900000, z = -900000 })
Wait(1000)
end
end
end)
Expand All @@ -46,7 +47,7 @@ CreateThread(function()
local ped = PlayerPedId()
local playerPos = GetEntityCoords(ped)
while true do
Wait(200)
Wait(500)
ped = PlayerPedId()
playerPos = GetEntityCoords(ped)
isPlayerCloseToMusic = false
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fx_version 'adamant'
fx_version 'cerulean'
games { 'gta5' }

client_scripts {
Expand Down
35 changes: 23 additions & 12 deletions html/scripts/SoundPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,32 @@ class SoundPlayer
this.volume = result;
if(this.max_volume == -1) this.max_volume = result;
if(this.max_volume > (this.volume - 0.01)) this.volume = this.max_volume;
if(!this.isYoutube)
{
if(this.audioPlayer != null) this.audioPlayer.volume(result);
}
else
{
if(this.yPlayer && this.youtubeIsReady){
this.yPlayer.setVolume(result * 100);
}
}
if(this.isMuted_){
if(!this.isYoutube)
{
if(this.audioPlayer != null) this.audioPlayer.volume(0);
}
else
{
if(this.yPlayer && this.youtubeIsReady){this.yPlayer.setVolume(0);}
}
}
else
{
if(!this.isYoutube)
{
if(this.audioPlayer != null) this.audioPlayer.volume(result);
}
else
{
if(this.yPlayer && this.youtubeIsReady){this.yPlayer.setVolume(result * 100);}
}
}
}

create()
{
$.post('http://xsound/events', JSON.stringify(
$.post('https://xsound/events', JSON.stringify(
{
type: "onLoading",
id: this.getName(),
Expand All @@ -90,7 +101,7 @@ class SoundPlayer
loop: false,
html5: true,
autoplay: false,
volume: 0.0,
volume: 0.00,
format: ['mp3'],
onend: function(event){
ended(null);
Expand Down
25 changes: 13 additions & 12 deletions html/scripts/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function isReady(divId, howler){
if(sound.loaded() == false){

sound.setLoaded(true);
$.post('http://xsound/events', JSON.stringify(
$.post('https://xsound/events', JSON.stringify(
{
type: "onPlay",
id: sound.getName(),
Expand All @@ -31,7 +31,7 @@ function isReady(divId, howler){
if(sound.getAudioPlayer() != null){time = sound.getAudioPlayer()._duration;}
if(sound.isDynamic()) sound.setVolume(0);

$.post('http://xsound/data_status', JSON.stringify(
$.post('https://xsound/data_status', JSON.stringify(
{
time: time,
type: "maxDuration",
Expand All @@ -46,17 +46,18 @@ function isReady(divId, howler){
{
var sound = soundList[soundName];
if(sound.getDivId() === divId){
$.post('http://xsound/events', JSON.stringify(
$.post('https://xsound/events', JSON.stringify(
{
type: "onPlay",
id: sound.getName(),
}));

var time = 0;
if(sound.getYoutubePlayer() != null){time = sound.getYoutubePlayer().getDuration();}
if(sound.isDynamic()) sound.setVolume(0);
sound.setLoaded(true);

$.post('http://xsound/data_status', JSON.stringify(
$.post('https://xsound/data_status', JSON.stringify(
{
time: time,
type: "maxDuration",
Expand All @@ -78,8 +79,8 @@ function isLooped(divId){
sound.setTimeStamp(0);
sound.play();

$.post('http://xsound/data_status', JSON.stringify({ type: "finished",id: soundName }));
$.post('http://xsound/events', JSON.stringify(
$.post('https://xsound/data_status', JSON.stringify({ type: "finished",id: soundName }));
$.post('https://xsound/events', JSON.stringify(
{
type: "onEnd",
id: sound.getName(),
Expand All @@ -88,7 +89,7 @@ function isLooped(divId){
var time = 0;
if(sound.getAudioPlayer() != null){time = sound.getAudioPlayer()._duration;}
if(sound.getYoutubePlayer() != null){time = sound.getYoutubePlayer().getDuration();}
$.post('http://xsound/events', JSON.stringify(
$.post('https://xsound/events', JSON.stringify(
{
type: "resetTimeStamp",
id: sound.getName(),
Expand All @@ -107,8 +108,8 @@ function ended(divId){
var sound = soundList[soundName];
if(!sound.isPlaying())
{
$.post('http://xsound/data_status', JSON.stringify({ type: "finished",id: soundName }));
$.post('http://xsound/events', JSON.stringify(
$.post('https://xsound/data_status', JSON.stringify({ type: "finished",id: soundName }));
$.post('https://xsound/events', JSON.stringify(
{
type: "onEnd",
id: sound.getName(),
Expand All @@ -117,7 +118,7 @@ function ended(divId){
var time = 0;
if(sound.getAudioPlayer() != null){time = sound.getAudioPlayer()._duration;}
if(sound.getYoutubePlayer() != null){time = sound.getYoutubePlayer().getDuration();}
$.post('http://xsound/events', JSON.stringify(
$.post('https://xsound/events', JSON.stringify(
{
type: "resetTimeStamp",
id: sound.getName(),
Expand All @@ -137,8 +138,8 @@ function ended(divId){
{
var sound = soundList[soundName];
if(sound.getDivId() === divId && !sound.isLoop()){
$.post('http://xsound/data_status', JSON.stringify({ type: "finished",id: soundName }));
$.post('http://xsound/events', JSON.stringify(
$.post('https://xsound/data_status', JSON.stringify({ type: "finished",id: soundName }));
$.post('https://xsound/events', JSON.stringify(
{
type: "onEnd",
id: sound.getName(),
Expand Down
2 changes: 1 addition & 1 deletion html/scripts/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function addToCache()
}
else
{
if(!sound.isMuted() && sound.loaded()) {
if(sound.loaded()) {
sound.mute();
}
}
Expand Down

0 comments on commit 151ccc3

Please sign in to comment.