Show DrawText On Bind

Hello, i try show DrawText on “G” Key, i use IsControlJustReleased, but DrawText Show on one second… after remove. Maybe it interval?

function CheckPlayerCar2() {
  if (IsControlJustReleased(0, 47)) {
    SetTextFont(4);
  SetTextProportional(1);
  SetTextScale(1.6, 0.45);
  SetTextColour(255, 255, 255, 255);
  SetTextDropshadow(0, 0, 0, 0, 255);
  SetTextEdge(1, 0, 0, 0, 255);
  SetTextDropShadow();
  SetTextOutline();
  SetTextEntry("STRING");
  AddTextComponentString("~g~Cruisecontrol");
  DrawText(0.02, 0.836);
  }
}

setInterval(CheckPlayerCar2, 0);

Hey, IsControlJustReleased (as it’s name says) checks if control is JUST pressed. If you want your code to run, while control is pressed, then use IsControlPressed. :wink:

Hi, thanks for answering! But, I’ve already tried… The code will work if you just hold down the button, and I need to press it and it won’t disappear at all

Waaait, do you want your code to show the text when the player presses the G key and when he releases it you want the text to disappear? Bc I dont understand how you want this script to work haha

No bro, i want So that after the player pressed the key, the code would not disappear

So normally the text is supposed to be shown, when the player presses G, it disappears and when he releases the key, the text shows up again?

1 Like

So that he just pressed and not clamped, and after that the code will not disappear

Yes…

Ohh okay haha, then just add ! in front of IsControlPressed, like this

if(!IsControlPressed(0, 47){
    // code for showing text
}

You got it?

Everything is the same, but just the code began to be played before pressing

Most likely you don’t understand what I mean

Yeah I guess so, this code should now show the text, but while player is pressing G key, code will hide the text. But is it what you wanted?

Look, I’ll try to say it again: Conditionally, I want to use something like IsControlJustReleased alone, after which I want DrawText to stay and not disappear anywhere else. Just clicked once and the code does not disappear

I use a translator, maybe it doesn’t explain well

Before pressing the DrawText key, there should not be

Sooo u want the text to be shown until you press G?

Yes, but only on the contrary. I Want it was not displayed until I pressed G. And so that after I release G, he does not disappear

Ohh finally I uderstand haha, here’s the code

let controlPressed = false;
function CheckPlayerCar2() {
    if(!controlPressed && IsControlJustPressed(0, 47)) controlPressed = true;
    if (controlPressed) {
        SetTextFont(4);
        SetTextProportional(1);
        SetTextScale(1.6, 0.45);
        SetTextColour(255, 255, 255, 255);
        SetTextDropshadow(0, 0, 0, 0, 255);
        SetTextEdge(1, 0, 0, 0, 255);
        SetTextDropShadow();
        SetTextOutline();
        SetTextEntry("STRING");
        AddTextComponentString("~g~Cruisecontrol");
        DrawText(0.02, 0.836);
    }
}

setInterval(CheckPlayerCar2, 0);
1 Like

Thank bro, And what would you hide by simply setting the controlPressed value to false?

Umm I dont really understand the question. But if you are asking what will happen when you would set controlPressed to false - then the code will start checking again if player pressed G key