Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
How to write a java script for specific Test attempts

I am having a java scripts for a game, but this game is like a test and if the user failed the game he will retake the test (redo the game), but I want a specific number of attempts only for the user to re do the test. now what I have, makes the user start from the beginning without any limitations even if he re do it for like 100 times, he will keep go back to the beginning.

I need in the fail massage to give another attempt (form like max 4 attempts) if failed once then the next fail massage to give him 3 tries and then 2 and then last one, and then he can't redo the test.

Script 1;

var player=GetPlayer();

var textArray = [];


for (var i = 1; i <= 15; i++) {
    textArray.push(i); 

};


var itemsLeft = textArray.length;

textArray=textArray.map(String).toString();
player.SetVar("Text_Array", textArray);

player.SetVar("Items_Left", itemsLeft);

Script 2:

//get the StoryLine player
var player=GetPlayer();

//get Storyline variable value as a string
var textArray=player.GetVar("Text_Array");

//Convert string to a numeric array
numArray=textArray.split(",").map(Number);

//Get a random number from the array and send it to StoryLine
var randNum = numArray[Math.floor(Math.random() * numArray.length)];
player.SetVar("Random",randNum);

//Remove the random number from your array and get the array's length
numArray.splice(numArray.indexOf(randNum), 1);
var itemsLeft=numArray.length;

//Convert array to a string and send it back to SL along with the array's length
textArray=numArray.map(String).toString();
player.SetVar("Items_Left", itemsLeft);
player.SetVar("Text_Array", textArray);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda