Unreal engine crashes

I have an issue I use unreal engine 4.26.2 , so when I try to compile the code and play the game everything goes well and when I press TAB and enter the right word it works but when I enter a wrong word unreal engine crashes.
this is the code.

#include "BullCowCartridge.h"

void UBullCowCartridge::BeginPlay() // When the game starts
{
    Super::BeginPlay();

    SetupGame();
    PrintLine(TEXT("The hidden word is: %s."), *Hiddenword);
    
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
    if(bGameOver)
    {
        ClearScreen();
        SetupGame();
    }
    else
    {
        if(Input == Hiddenword)

        {
            PrintLine(TEXT("You have won:)"));

            EndGame();
        }
        else
        {
            --Lives;
            
            if(Lives>0)
            {
                PrintLine(TEXT("you have lost a life"));
                if(Input.Len() != Hiddenword.Len())
                {
                    
                    PrintLine(TEXT("Sorry, try again \n you have %i lives remaining"), Lives);
                    PrintLine(TEXT("the hidden word is %s charcters long"), Hiddenword.Len());
                }


            }
            else 
            {
                PrintLine(TEXT("you have no lives left"));
                EndGame();
            }
            
           

            


        }
    }



    
    
    
    


}


void UBullCowCartridge::SetupGame()
{
     PrintLine(TEXT("Welcome to the Bull Cows game you mdafka"));
     Hiddenword = TEXT("Cake");

    Lives = Hiddenword.Len();

    bGameOver = false;

    PrintLine(TEXT("you have %i lives"), Hiddenword.Len());
     
    PrintLine(TEXT("Guess the %i letter word!"), Hiddenword.Len());
    PrintLine(TEXT("Enter words that will decide your fait"));

    
}

void UBullCowCartridge::EndGame()
{
    bGameOver = true;
    PrintLine(TEXT("press enter to play again."));
}

You’re using the wrong specifier. You need %i for an int not s

Really really thanks, I totally forgot about this and went looking for everything else.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms