[Release] Simple Hacking Minigame


#1

This is my first release of a bunch of some scripts I wrote. More will come after I deem them ready enough.

The hacking minigame is inspired by the Hacking Minigame of Alpha Protocol, notoriously known for being horrible to play. You need to find two constant hex code blocks in a fast enough changing table of hexcode. It is purely a visual minigame. In the screen below you will see the left block hovering directly above a solution – need to move it one down and press space to be accepted as a correct solution.

Sample Implementation

function mycb(success, timeremaining)
	if success then
		print('Success with '..timeremaining..'s remaining.')
		TriggerEvent('mhacking:hide')
	else
		print('Failure')
		TriggerEvent('mhacking:hide')
	end
end


Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    if IsControlJustReleased(1,213) then -- Home key
	  TriggerEvent("mhacking:show")
	  TriggerEvent("mhacking:start",7,35,mycb)
    end
  end
end)

How to use the Resource

After loading the resource, you can call several events to control the minigame.

  • For your own implementation call mhacking:show to show the app and mhacking:hide to hide it.
  • Call mhacking:setmessage, while the app is not running, but you called mhacking:show prior to display a custom message, which is the parameter of the aforementioned event.
  • Call mhacking:start, to start the minigame. The event has the parameters: solution-size, time and a callback function which gets passed true or false, depending on whether the client has successfully solved the minigame or was timed out. Furthermore the remainingtime in ms is passed as a second parameter.
  • mhacking:seqstart is a wrapper for mhacking:start, mhacking:show, and mhacking:hide and has the same parameters as mhacking:start; but it can be passed tables instead. Depending on if tables have been passed or not the behaviour of the minigame slightly changes. e.g. calling TriggerEvent("mhacking:seqstart",{7,6,5,4},90,mycb) would trigger 4 minigames in series for which the player has 90s of time available in total to solve them, with decreasing solution-size. The callback gets called after every successful or failed game with a 3rd boolean parameter, indicating if this was the last hack after which the application is closed. e.g. function mycb(success, remainingtime, finish) end

The difficulty itself can be easily adjusted by the available time and solution-size; smaller codeblocks are more difficult to spot with less time, it becomes even more difficult. Very easy is usually about solution-size of 7, and 35s - 45s of time to find the correct spots, while I would deem hard or very hard something like solution-size of 3 and 10s - 12s time.
Missing a solution once will reduce the time by 5s, missing it twice by 10s, etc.

Download from GitHub: https://github.com/GHMatti/FiveM-Scripts/tree/master/mhacking

Changelog
  • 20171225: Initial Release
  • 20180102: Fixed mhacking not reseting mistakes
  • 20180110: Added time remaining in ms as a second parameter for the callback function; if the player dies, the script now sets the remaining time to 0, and fails the player. Added mhacking:setmessage to set messages while waiting for feedback and sequentialhack.lua to handle sequentialhacks without everyone needing to program their own implementation, which can be removed from the __resource.lua if one does not need it.

If someone has suggestions for improvements, especially a better idea for displaying the help to play this Minigame I am all ears.


[Release][Dunko vRP V6.7 - FX Server] UPDATED 18/04/2018 - Supports 15 languages - Zap Hosting 10% DISCOUNT!
#2

This is pretty neat! Nice job!


#3

Will be using this for a stealing mission I’m working at, thanks for sharing.


#4

awesome, dood! thanks for sharing your work :wink:


#5

Fixed an issue, where I forgot to set the number of mistakes made to 0.

Literally just added mistakes = 0; to resetGameState().


#6
  • Added time remaining in ms as a second parameter for the callback function;
  • If the player dies, the script now sets the remaining time to 0, and fails the player.
  • Added mhacking:setmessage to set messages while waiting for feedback
  • Added sequentialhack.lua to handle sequentialhacks without everyone needing to program their own implementation, which can be removed from the __resource.lua if one does not need it.

#7

Where I can change the timecondown, to have more time to play and check it, please?


#8

There. The 35 are the 35s you have. Reading the first post would have helped


#9

thanx for that fast sirius answer!


#10

Hi. Can someone help me with adding this minigame before startnig a robbery and when “hacking” was successfull then start robbery but when someone failed hacking then prevent robbery and make shop or bank on cooldown