b1rbert Posted June 30, 2024 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 47 Reputation: 3 Joined: 05/04/14 Last Seen: 38 minutes ago Share Posted June 30, 2024 Hey, wanted to ask for a script that randomly chooses between 5 options of playBGM whenever OnPCLoadMapEvent happens. tried around a bit myself but I'm not really getting it at the moment, maybe someone can whip up something simple real quick. huge thanks in advance Quote Link to comment Share on other sites More sharing options...
1 WhiteEagle Posted June 30, 2024 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 3 hours ago Share Posted June 30, 2024 switch(rand(1,5)) { case 1: playBGM "<BGM filename>"; end; case 2: playBGM "<BGM filename>"; end; case 3: playBGM "<BGM filename>"; end; case 4: playBGM "<BGM filename>"; end; case 5: playBGM "<BGM filename>"; end; } 1 Quote Link to comment Share on other sites More sharing options...
1 Poring King Posted July 1, 2024 Group: Members Topic Count: 63 Topics Per Day: 0.02 Content Count: 1016 Reputation: 191 Joined: 11/27/14 Last Seen: February 15 Share Posted July 1, 2024 Try this let me know if it works . But i read some other comments and i think you already found what you need . I just want to put my entry - script RandomBGM -1,{ OnInit: // Define the map where the BGM should be randomized set .map$, "prontera"; // Define the list of BGMs setarray .bgms$[0], "BGM/01.mp3", "BGM/02.mp3", "BGM/03.mp3", "BGM/04.mp3"; // Initialize an array to track played BGMs set .played[0], 0, 0, 0, 0; set .totalPlayed, 0; // Define a global label to set BGM on map load OnPCLoadMapEvent: // Check if the player has loaded the specific map if (strcharinfo(3) == .map$) { // Check if all BGMs have been played if (.totalPlayed >= getarraysize(.bgms$)) { // Reset the played array set .totalPlayed, 0; for (set .i, 0; .i < getarraysize(.bgms$); set .i, .i + 1) { set .played[.i], 0; } } // Find a BGM that hasn't been played yet do { set .randomIndex, rand(getarraysize(.bgms$)); } while (.played[.randomIndex]); // Mark the BGM as played set .played[.randomIndex], 1; set .totalPlayed, .totalPlayed + 1; // Play the random BGM playbgm .bgms$[.randomIndex]; } end; } // Define the map to trigger the OnPCLoadMapEvent label prontera mapflag loadevent; 1 Quote Link to comment Share on other sites More sharing options...
0 b1rbert Posted June 30, 2024 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 47 Reputation: 3 Joined: 05/04/14 Last Seen: 38 minutes ago Author Share Posted June 30, 2024 29 minutes ago, WhiteEagle said: switch(rand(1,5)) { case 1: playBGM "<BGM filename>"; end; case 2: playBGM "<BGM filename>"; end; case 3: playBGM "<BGM filename>"; end; case 4: playBGM "<BGM filename>"; end; case 5: playBGM "<BGM filename>"; end; } Thanks a lot. Works like a charm. I actually tried something similiar like your script before with the examples you can find in different scripts but what I had put together didnt work. Quote Link to comment Share on other sites More sharing options...
0 WhiteEagle Posted June 30, 2024 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 3 hours ago Share Posted June 30, 2024 This system would be interesting when one BGM is over, another BGM is randomly selected. Quote Link to comment Share on other sites More sharing options...
0 b1rbert Posted June 30, 2024 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 47 Reputation: 3 Joined: 05/04/14 Last Seen: 38 minutes ago Author Share Posted June 30, 2024 What I found out so far is that once the BGM it selects is over, the normal BGM that usually plays starts. Could be avoided by making the BGMs a lot longer but it will still reach the end eventually. Currently have the NPC standing in Prontera, as soon as the Payon BGM I choose in the script ended, it started the Prontera theme even though it wasn't in the list. Could probably work around that with some sort of loop script but haven't look at it yet Quote Link to comment Share on other sites More sharing options...
0 luizinhomt Posted July 17, 2024 Group: Members Topic Count: 36 Topics Per Day: 0.01 Content Count: 111 Reputation: 1 Joined: 01/05/13 Last Seen: Yesterday at 01:43 AM Share Posted July 17, 2024 On 30/06/2024 at 22:30, Poring King said: Tente isso, deixe-me saber se funciona. Mas eu li alguns outros comentários e acho que você já encontrou o que precisa. Eu só quero colocar minha entrada Good evening, when I try to run this script I get player error [Error]: buildin_strcharinfo: fatal error ! player not attached! [Debug]: Function: strcharinfo (1 parameter): Quote Link to comment Share on other sites More sharing options...
Question
b1rbert
Hey,
wanted to ask for a script that randomly chooses between 5 options of playBGM whenever OnPCLoadMapEvent happens.
tried around a bit myself but I'm not really getting it at the moment, maybe someone can whip up something simple real quick.
huge thanks in advance
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.