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 andmhacking:hide
to hide it. - Call
mhacking:setmessage
, while the app is not running, but you calledmhacking: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 formhacking:start
,mhacking:show
, andmhacking:hide
and has the same parameters asmhacking: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. callingTriggerEvent("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 andsequentialhack.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.