Password Cracker
Password Cracker runs on the client. Your script starts it with a five-letter word, and the player has to put the shuffled letters back in order before the attempts or the time run out. The player can’t move while the hack is on screen.
Install
- Get the files. Owner: under Granted Assets in your Cfx.re Portal. Developer: the download link in the Tebex email.
- Put the
passwordcrackerfolder in your server resources. - Add this line to your
server.cfgand restart:
ensure passwordcracker
It has no dependencies.
Start it
Password Cracker starts with an event, from a client script. It has no export.
TriggerEvent('passwordhack:robbery_computer', 'major', 120000, 5, function(result, reason)
-- your code
end)
The result comes back through that function, and a function can’t travel from the server to the client. To start it from the server, send your own event to the player and trigger this one there. The example at the end does exactly that.
Options
| Option | What it is | Default |
|---|---|---|
word |
The password, exactly 5 letters. Required | — |
time |
Time for the whole hack, in milliseconds | 120000 (2 minutes) |
attempts |
Tries the player gets, from 1 to 5 | 5 |
Results
result |
When |
|---|---|
1 |
The player found the word |
2 |
Time ran out |
0 |
The hack failed |
-1 |
Error, for example a word that isn’t 5 letters long |
Give the reward on the server
A cheater can fire myheist:hackDone from a mod menu without playing, so the server only pays for a hack it started itself, that took a possible time, and only once:
-- client.lua
RegisterNetEvent('myheist:startHack', function(token)
TriggerEvent('passwordhack:robbery_computer', 'major', 120000, 5, function(result)
TriggerServerEvent('myheist:hackDone', token, result == 1)
end)
end)
-- server.lua
local MAX_TIME = 120 + 10 -- seconds: your time limit plus slack for loading and the network
local MIN_TIME = 5 -- seconds: time a fast run on your server and raise it
local hacks = {}
-- Call this from your heist when the player may hack (at the terminal, not on cooldown).
local function startHack(src)
local token = ('%08x%08x'):format(math.random(0, 0x7fffffff), math.random(0, 0x7fffffff))
hacks[src] = { token = token, startedAt = os.time() }
TriggerClientEvent('myheist:startHack', src, token)
end
RegisterNetEvent('myheist:hackDone', function(token, success)
local src = source
local hack = hacks[src]
hacks[src] = nil -- one use: a second report finds nothing
if not hack or hack.token ~= token or not success then return end
local took = os.time() - hack.startedAt
if took < MIN_TIME or took > MAX_TIME then return end
-- Give the reward here.
end)
AddEventHandler('playerDropped', function()
hacks[source] = nil
end)