[Free] Simple anti ALT + F4 [Standalone]

Hello,

Here’s a stupid simple script/snippet to stop or prevent people from using ALT + F4 to instantly stop their vehicles

Credits

My version does not kick players but rather makes them irritated.

Preview:(WARNING - I suggest turning down your volume since i added somewhat irritating screamer for my players)

Also, all 3D drawtexts are synced between players

Download from Github

14 Likes

Lmao. I got scared by the video. Time to troll my friend when testing.

3 Likes

legend for ear rape

3 Likes

Well, in my defense i did warn D:

1 Like

Nice one

1 Like

havent tested with players, works well for me

@Service()
export class VehicleService {
  private ped: number;
  private currentVehicle: number;
  private prevSpeed = 0;

  private altF4 = new Tick(() => {
    if (
      IsWarningMessageActive() &&
      GetWarningMessageTitleHash() === 1246147334 &&
      GetPedInVehicleSeat(this.currentVehicle, VehicleSeat.Driver) === this.ped
    ) {
       return SetVehicleForwardSpeed(this.currentVehicle, this.prevSpeed);
    }
    this.prevSpeed = GetEntitySpeed(this.currentVehicle);
  });

  @Event('vertex:enteredVehicle')
  private enteredVehicle(veh: number): void {
    this.altF4.start();
    this.prevSpeed = 0;
    this.currentVehicle = veh;
  }

  @Event('vertex:leftVehicle')
  private leftVehicle(): void {
    this.altF4.stop();
    this.prevSpeed = 0;
    delete this.currentVehicle;
  }
}

note: its my custom TS framework, but the logic is clean

Damn bro, this shouldnt even be legal, you will scare the actual sh*t out of everyone.
I am glad I always F8 quit haha. Nice script though, I dont think I will use it though.

3 Likes

The script I’ve did was actually for education purposes that’s why I’ve just put a kick function if the player ALT + F4. I don’t think it was actually stupid as you said.

Oh, I never referred your snippet / script as stupid, no no. I meant that it was stupid simple thing (meaning how easy and simple way to prevent). By no means was I trying to bash your original version, I simply stated that in my version player won’t get kicked and merely replaced it with other functions :grinning_face_with_smiling_eyes:

1 Like

Sorry for the missunderstanding, then. That was a nice release, anyways, because it will be helpful for people that can’t evolve my very simple version. :+1:

does it work?

im scared dude.

here is a fixed version of the code as it wouldn’t display and it translated to english

cl.lua

local canDraw = false
local canDraw2 = false

Citizen.CreateThread(function()
    while true do
        local waitTime = IsPedInAnyVehicle(PlayerPedId(), false) and 100 or 1000
        
        if IsWarningMessageActive() and tonumber(GetWarningMessageTitleHash()) == 1246147334 then
            ClearPedTasksImmediately(PlayerPedId())
            RemoveWarningMessageListItems(1246147334)
            TriggerServerEvent("InteractSound_SV:PlayOnSource", "yoursoundhere", 1.0)
            Scaleforms()
        end
        
        Citizen.Wait(waitTime)
    end
end)

RegisterNetEvent('s_alt:sync', function(nekruc, violator)
    canDraw2 = 4000
    
    while canDraw2 > 0 do
        local koords = GetEntityCoords(PlayerPedId())
        local dist = #(koords - nekruc)
        
        if dist <= 40 then
            Draw3DText(nekruc.x, nekruc.y, nekruc.z + 1.23, '~r~ALT F4~s~ [ID: ' ..violator.. ']')
        end
        
        if canDraw2 then
            canDraw2 = canDraw2 - 10
        end
        
        Wait(4)
    end
end)

function Scaleforms()
    local scaleform = RequestScaleformMovie("MP_BIG_MESSAGE_FREEMODE")
    
    while not HasScaleformMovieLoaded(scaleform) do
        Citizen.Wait(10)
    end
    
    local coords = GetEntityCoords(PlayerPedId())
    local pedid = GetPlayerServerId(PlayerId())
    TriggerServerEvent('s_alt:sync', coords, pedid)
    canDraw = 5000
    
    BeginScaleformMovieMethod(scaleform, "SHOW_WEAPON_PURCHASED")
    PushScaleformMovieMethodParameterString("~r~ALT F4?~s~")
    PushScaleformMovieMethodParameterString("~g~Your activity has been logged, and staff is aware of your activity. (Glitch / Bug abuse)")
    ScaleformMovieMethodAddParamInt(5)
    EndScaleformMovieMethod()
    
    while canDraw > 0 do
        DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
        
        if canDraw then
            canDraw = canDraw - 10
        end
        
        Wait(5)
    end
end

function Draw3DText(x, y, z, text)
    local onScreen, _x, _y = World3dToScreen2d(x, y, z)
    local px, py, pz = table.unpack(GetGameplayCamCoords())
    
    SetTextScale(0.35, 0.35)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 255)
    SetTextEntry("STRING")
    SetTextCentre(1)
    AddTextComponentString(text)
    DrawText(_x, _y)
    
    local factor = (string.len(text)) / 370
    DrawRect(_x, _y + 0.0125, 0.015 + factor, 0.03, 0, 0, 0, 159)
end

sv.lua

RegisterServerEvent('s_alt:sync',function(coords, pid)
    TriggerClientEvent('s_alt:sync', -1, coords, pid)
end)