void main() {
int counter = getlocalvar("counter"); // Retrieve the counter variable
if (openborvariant("in_menuscreen")) { // Check if the game is in menu screen
setlocalvar("counter", 0); // Reset the counter
}
if (openborvariant("in_titlescreen") && (counter != 1)) { // Check if in title screen and avoid double spawn
void subent;
setlocalvar("counter", 1); // Set the counter to block new spawns
// Load the entity model and sound
loadmodel("bfx");
int SFX1 = loadsample("data/sounds/heros.wav");
// Prepare and spawn the entity
clearspawnentry();
setspawnentry("name", "bfx"); // Define entity name
setspawnentry("coords", 0, 490, 0); // Set spawn position
subent = spawn(); // Spawn the entity
// Set entity properties (if needed)
changeentityproperty(subent, "position", 0, 490, 0); // Optional redundancy for safety
changeentityproperty(subent, "direction", 1); // Ensure direction is set
// Play the sound effect
playsample(SFX1, 0, 120, 120, 100, 0); // Play the loaded sound
}
}