forked from Simnation/Main
91 lines
3 KiB
JavaScript
91 lines
3 KiB
JavaScript
// Loading tips
|
||
const tips = [
|
||
"Willkommen auf Evolution State Life RP – Deinem ultimativen RP-Erlebnis",
|
||
"Konto leer? Entdecke unsere einzigartigen Jobs",
|
||
"Bleibe in deiner Rolle und verbesser das RP-Erlebnis aller",
|
||
"Keine Lust zu laufen? Besuche unsere Fahrzeughändler in der ganzen Stadt",
|
||
"Entdecke unsere einzigartigen Funktionen und Aktivitäten",
|
||
"Sei respektvoll gegenüber anderen Spielern und dem Team",
|
||
"Join our community events for special rewards",
|
||
"Denke daran, alle Fehler oder Probleme zu melden",
|
||
"Lies vor dem Spielen unbedingt unsere Serverregeln",
|
||
"Du brauchst Hilfe? Schau dich im Discord um"
|
||
];
|
||
|
||
// Initialize variables
|
||
let currentTip = 0;
|
||
let progress = 0;
|
||
const music = document.getElementById('backgroundMusic');
|
||
const musicBtn = document.getElementById('toggleMusic');
|
||
let musicPlaying = true;
|
||
|
||
// Function to update the loading tip
|
||
function updateTip() {
|
||
const tipElement = document.querySelector('.loading-tip');
|
||
tipElement.style.opacity = '0';
|
||
|
||
setTimeout(() => {
|
||
tipElement.textContent = tips[currentTip];
|
||
tipElement.style.opacity = '1';
|
||
currentTip = (currentTip + 1) % tips.length;
|
||
}, 500);
|
||
}
|
||
|
||
// Function to update progress bar
|
||
function updateProgress() {
|
||
const progressBar = document.querySelector('.progress');
|
||
if (progress < 100) {
|
||
progress += Math.random() * 2;
|
||
if (progress > 100) progress = 100;
|
||
progressBar.style.width = `${progress}%`;
|
||
|
||
// Update loading text based on progress
|
||
const loadingText = document.querySelector('.loading-text');
|
||
if (progress < 30) {
|
||
loadingText.textContent = 'Hier könnte Ihre Werbung stehen.';
|
||
} else if (progress < 60) {
|
||
loadingText.textContent = 'Wenn du das lesen kannst, ist es noch nicht fertig.';
|
||
} else if (progress < 90) {
|
||
loadingText.textContent = 'Server wird liebevoll gestreichelt.';
|
||
} else {
|
||
loadingText.textContent = 'Fast fertig... oder auch nicht?';
|
||
}
|
||
}
|
||
}
|
||
|
||
// Toggle music function
|
||
function toggleMusic() {
|
||
if (musicPlaying) {
|
||
music.pause();
|
||
musicBtn.querySelector('.music-text').textContent = 'Musik aus';
|
||
musicBtn.style.background = 'rgba(185, 55, 55, 0.1)';
|
||
} else {
|
||
music.play();
|
||
musicBtn.querySelector('.music-text').textContent = 'Musik an';
|
||
musicBtn.style.background = 'rgba(15, 247, 255, 0.2)';
|
||
}
|
||
musicPlaying = !musicPlaying;
|
||
}
|
||
|
||
// Event listeners
|
||
document.addEventListener('DOMContentLoaded', () => {
|
||
// Start with first tip
|
||
updateTip();
|
||
|
||
// Change tip every 5 seconds
|
||
setInterval(updateTip, 5000);
|
||
|
||
// Update progress bar
|
||
setInterval(updateProgress, 100);
|
||
|
||
// Music button click handler
|
||
musicBtn.addEventListener('click', toggleMusic);
|
||
});
|
||
|
||
// Handle loading events from the game
|
||
window.addEventListener('message', function(e) {
|
||
if (e.data.eventName === 'loadProgress') {
|
||
progress = e.data.loadFraction * 100;
|
||
updateProgress();
|
||
}
|
||
});
|