I can’t seem to get this working, ExecuteScript("playlevelupsound", oPC);
nor does variation of OBJECT_
etc etc. The scripts separately both function as intended.
I want to be able to trigger a small script that plays a short sound once a specific operation is done in another script. For example, the script I’m working with handles player skill leveling, and once they level up, and interface appears notifying the player that they have reached a certain level.
I would also like a specific audio file to play when this occurs, and I currently have that configured to play via ExecuteScript("playlevelupsound", oPC);
, except the script won’t fire. I am open to alternative methods, but the “play sound” function wouldn’t work either, so I opted to spawn an object near the Player and have that play the sound then destroy itself. It works when the script is ran from an interface, specifically in this case I have been testing it by making the close button on the level-up notification interface execute the script that plays the sound.
Here is a snippet from the script where I have attempted to make this work
void UpdateCraftLevel(object oPC, int nSKILL, string sPROF, int nTOTXP, int nBASE, int nOVER)
{
int nNEW = nBASE; //this little bit here just places the level-up notification inside the chat-box.
string sTEXT0 = "Congratulations, you just advanced a " + sPROF + " level.";
string sTEXT1 = "Your " + sPROF + " level is now " + IntToString(nNEW) +".";
if (nOVER == TRUE)
{
while (GetSkillXPNeeded(nNEW) > nTOTXP)
{
SetBaseSkillRank(oPC, nSKILL, nNEW - 1, FALSE);
nNEW = nNEW - 1;
}
}
if ((nNEW <= MAX_SKILL_LEVEL)&&(nNEW == nBASE)) //Max Level
{
while (GetSkillXPNeeded(nNEW + 1) <= nTOTXP)
{
SetBaseSkillRank(oPC, nSKILL, nNEW + 1, FALSE);
nNEW = nNEW + 1;
}
}
if (nNEW != nBASE)//this is where the level-up notification GUI is triggered
{
ExecuteScript("playlevelupsound", oPC); //This is SUPPOSED to trigger the script "playlevelupsound" that plays the 'level-up jingle', but it won't work!
DisplayGuiScreen(oPC, "LEVELUPBACKGROUND", FALSE, "levelupbackgroundgui.xml");
SetGUIObjectText(oPC, "LEVELUPBACKGROUND", "LEVELUP_TEXT0", -1, sTEXT0);
SetGUIObjectText(oPC, "LEVELUPBACKGROUND", "LEVELUP_TEXT1", -1, sTEXT1);
SetGUITexture(oPC, "LEVELUPBACKGROUND", "SKILL_ICON", "levelupbackground.tga");
}
switch (nSKILL)//each skill has a case, this is done so that each skill can have its own graphics appear on the level-up notification GUI
{
case SKILL_THIEVING: SetGUITexture(oPC, "LEVELUPBACKGROUND", "SKILL_ICON", "thievinglvlup.tga"); break; //Thieving Skill
case SKILL_WOODCUTTING: SetGUITexture(oPC, "LEVELUPBACKGROUND", "SKILL_ICON", "woodcuttinglvlup.tga"); break;//Woodcuting Skill
}
}