Mafia 3 ScriptHook

Mods chevron_right chevron_right Mafia 3 ScriptHook
  • description Description

    Script Hook

    Lua and Library Scripthook for Mafia 3 allowing you to run your own code in Mafia 3. Simply create a lua script or use the ExampleDLL to create your plugin and start creating yor mod. The Library Scripthook features a hooking library to find pattern, patch function calls/jumps with your own, overwriting opcodes/functions etc.

    List of all available commands follows in the next few hours, meanwhile you can tryout Mafia2's scripting commands (which can be found here), as they don't have really changed.

    Mafia 3 Script Hook is completly open source and can be found at https://github.com/MartinJK/Mafia3ScriptHook

    If you want to reload Lua scripts while being in the game, simply press F1 and all Lua scripts in side the scripts/ folder will reload.

    Scripting Documentation

    A list of functions; parameters; strings can be found here: https://mega.nz/#F!VscigCQQ!yl3PBpGpZ075v6K5x6PICA

    If you need help or are experiencing troubles, don't hesitate to ask for help: https://mafiamods.com/forums/topic/mafia-3-modding-mega-thread/

    ScriptHook implemented functions:

    printToLog("YourLogfile", "String"); // e.g. printToLog("Test.log", "Test");
    bindKey("k", "ContentToExecute") // e.g. bindKey("k", "printToLog('Test.log', 'test')");
    unbindKey("k"); // (removes all bindings of key "k", even in other scripts)
    setTimeout("5000", "ContentToExecute") // e.g.  setTimeout("5000",  "printToLog('Test.log', 'test')"); (5000 = 5000ms)
    
    An example file for scripting can be found here: https://github.com/MartinJK/Mafia3ScriptHook/blob/master/files/scripts/dev.lua
    
    NOTE
    Please be careful with pressing keys, spaming keys / executing the same things too often in a short time period can cause the game to crash!
    
    
    
  • speaker_notes Installation

    1. Download .ZIP

    2. Extract the .ZIP content into Mafia III directory so the structure looks like this

    |- mafia3.exe

    |- M3ScriptHookLauncher.exe

    |- M3ScriptHook.dll

    3. Run M3ScriptHookLauncher.exe once the game has started.

  • event_note Changelog

    ScriptHook Version 1.1, supports now the following functions

    printToLog("YourLogfile", "String"); // e.g. printToLog("Test.log", "Test");
    bindKey("k", "ContentToExecute") // e.g. bindKey("k", "printToLog('Test.log', 'test')");
    unbindKey("k");
    setTimeout("5000", "ContentToExecute") // e.g.  setTimeout("5000",  "printToLog('Test.log', 'test')");
    
    -Implementation of Lua error logs (placed in ScriptHook.log)
    
    Example:
    Error loading Lua code into buffer. Error -100
    scripts/dev.lua:11: = expected near 'setVehicleData'
    stack traceback:
     [C]: in function 'assert'
     test:1: in function 'dofile'
     test:1: in function '(main chunk)'
    -Overall stability improved
  • Report
  • Twitter