Custom Hack
On this page, I'll give you snippets on how to add custom hack to Hacker V.
Config (shared/cfg.lua)
In this file, find the following lines and uncomment them. You can use this in every custom hack you add.
These lines, add a new option to hack interactions. This table should be under cfg['interactions']
. You can change orderly,
Which objects you want to be hacked
UI attach offset
UI label
UI icon
Event and type to be triggered
Can interact function
Hack cooldown
Required count of botnets.
Custom hack (client/custom_hack.lua
)
client/custom_hack.lua
)In this file, you can create event for custom hack you added. I will explain it to you with an example case for you to understand the logic.
When an event is triggered, the event function written to cfg comes with two parameters.
type
andentity
. Type is hack type, entity is local entity ID.We are creating a new thread so that it does not affect other loops in the script. (
Citizen.CreateThread
)We check the cooldown of the action and the required count of botnets for the player. (
triggerCallback
)We are disable the object for other players. (Other players will see "Already Hacked." text. (
hackermod:server:sync', 'interactableObject'
)We set this variable to 'true' so that the phone stays on your hand for the duration of the action. (
keepAnimTask
)We create a 5 second wait for action. (
DrawBusySpinner()
)We create minigame for action. (
Minigame()
)If the minigame is completed successfully, the event that will give money to the player will be triggered, otherwise the object will be active again so that other players can hack it. (
if-else block
)At the end of the action, we take the phone out of the player's view. (
keepAnimTask
)
Last updated