1. Want to help spread the Se7ensins cheer throughout the PC gaming community? Check out a little project one of our staff members is working on for CS:GO! More information concerning this can be found by clicking here.

[TUT] Script modding for GTA IV/EFLC on XBOX360/PS3

Discussion in 'Grand Theft Auto IV Modding' started by MuFiiNzHD, Mar 24, 2012 with 57 replies and 32,245 views.

  1. iModMuch

    iModMuch Power Of The Mind

    Messages:
    1,110
    Likes Received:
    185
    What tools you will need:

    - Scocl from:GTAForums.com -> [GTA IV|EFLC|REL] Scocl
    - SCOToolbox from: GTAForums.com -> [IV/EFLC|REL] SCO ToolBox
    - openiv from:OpenIV – RAGE Research project
    or just:
    - Files pack.rar from:download
    - Offline Trainer Source Code Pack: Get it now!
    CREDITS FOR FILES PACK: cathering , PUN1SHM3NT , alexander blade , open iv team , sco toolbox flitskikker and the guy who developed rar program I used..

    - Latest trainer Src code: credits EvilB for helping and above ^ and Skorpro for gta2 overhead cam Download

    (does not contain GTAIV.EXE therefore you will need to find it somewhere ie: your game directory and place it in Scotoolbox folder / openiv folder)
    - A Code Editor: DevC++ / Text editor or something that can edit text for programming

    What are they:

    - Scocl Is a source code compiler for GTA IV/ EFLC that compiles C++ code into sco format similar to R*'s

    - SCOToolbox is designed for decoding, encoding and low level editing of SCO files.

    - Openiv A tool for opening R* compressed img / rpf's to allow editing (kinda like zip files)

    - File pack: A pack of files collected that will help you on your journey (more info below)

    - Code editor: A tool to edit C++ code

    What I am trying to do:

    I hope to teach all that are interested in developing there own script mods so they can share with the community. I will go threw the entire process from start to end and hopefully it will help you to do the same or better.

    Questions:

    Here I will add questions and the answers to them as I receive them because im sure there will be some..


    Process In Steps:

    Step 1: Installing files and setup basically Files pack.rar has all you need in it so use a Rar extraction pogrom like winrar. Once files are extracted you should have folders like: (without it looking like a mac)
    [​IMG]


    Start by installing GTAIVModdingTools\setup.msi
    Install ScoCompiler (SCOCL) by Placing it in C:\ eg: C:\ScoCompiler\ScoCompiler\ once finished
    install SCOToolBox by placing it on desktop or anywhere
    and google DevC++ and download and install it or use Notepad

    For this tutorial I will declare Myscript.c as your script..

    Step2: Go to C:\ScoCompiler\ScoCompiler\ open up C:\ScoCompiler\ScoCompiler\files.txt and put in the location of your script..
    eg C:\ScoCompiler\ScoCompiler\Sources\Myscript.c ..
    what this does it tells "compile.bat" where to locate your script to compile.. it will compile and place the name you set in files.txt in C:\ScoCompiler\ScoCompiler\Output\ folder in "SCO" file format

    Step3: Use your script editor and open C:\ScoCompiler\ScoCompiler\Sources\Stripped\main.c
    this is the "superman" script (from Scocl) witch gives you god mode etc..( I use this for my "base" in all testing )
    Make any changes that you want and then save your script in C:\ScoCompiler\ScoCompiler\Sources\ as what ever name you set in "files.txt" eg: Myscript.c
    and now select "compile.bat" it will open a Command window and run the compiler as long as your script name matches the one in "Files.txt"
    If all goes will it will say finished and you can simply close this window.
    If all goes wrong it will tell you the reason the compiler couldn't work and usually a line in your script where its at fault..

    So once your all done with this you should see your "sco" file in C:\ScoCompiler\ScoCompiler\Output\ "Myscript.c"

    Step4: Now that you have a compiled Myscript.sco from Myscript.c there is a bit more to be done.. Since AlexanderBlade the Author for Scocl wrote his program to compile .sco with New natives ver 1.7.0 only and our game consoles with Gtaiv only function with scripts with natives from 1.4.0 we need to convert our sco to an older format because if we don't our new script wont work…
    In order to convert we need to use SCOToolBox.exe so locate your scotoolbox folder and select SCOtoolbox.exe and open it.
    [​IMG]


    Select "open" (step1)
    ENSURE natives mode is set to "NEW" (step2)
    Select "open code editor" (step3)



    Now you have this window:
    [​IMG]


    as you can see the steps I will make it more clear:
    S1: you MUST convert new natives to old
    S2: Save your sco to eg: Sixaxistutorial.sco or loadthis.sco make sure its saved Encoded
    S3: Double check for any natives that were not changed.. select magnifying glass and search for "callnatve 0x
    S4: If found …like in the example you have "CallNative 0x234de45ff" you need to do now is google that hash value and find what it is in WORDS what exactly that native is eg 0x234de45ff = SOME_COOL_FUNCTION
    copy the word and replace the hex value with it. then save file as encoded and repeat till all is replaced.

    Step5: Grab a fresh "script.img" from your backup gtaiv game and place it somewhere you can get to eg desktop now open OpenIV by going to START>ALL PROGRAMS>GTA IV MODING TOOLS> OpenIV and select it…
    then go to file>open select script.img and then select open
    It will then ask you "open an archive in the editing mode?" select yes

    Find sixaxistutorial.sco and delete it from your original script.img
    take your sixaxistutorial.sco and drag and drop it in the window and check to see if it is there. once finished select File>rebuild and completely rebuild the script.img


    once done that place in USBHDD/GAMES/BLUSXXXX/PS3_GAME/USRDIR/common/data/


    NOW TEST!… thats it some work some don't but if it wont work its usually your C script


    Note: if your on PC/XBOX360 the examples in the files pack.... eg "modscript.c"will work online Not sure if they go in Network_script.img im sure someone will figure it out.

    By: Alex of PSX-Scene

    NEW: Here is one of my latest scripts ready to go , Try it yourself.. I challenge anyone to try to compile it / change it / adjust it / make it better

    Code:
    Code (Text):

     
     
    #include <natives.h>
    #include <common.h>
    #include <strings.h>
    #include <types.h>
    #include <consts.h>
     
     
    //############### Define Xbox Controller  ################################//
    #define BUTTON_BACK  0xD
    #define BUTTON_START  0xC
    #define BUTTON_X  0xE
    #define BUTTON_Y  0xF
    #define BUTTON_A  0x10
    #define BUTTON_B  0x11
    #define BUTTON_DPAD_UP  0x8
    #define BUTTON_DPAD_DOWN  0x9
    #define BUTTON_DPAD_LEFT  0xA
    #define BUTTON_DPAD_RIGHT  0xB
    #define BUTTON_LB  0x5
    #define BUTTON_RB  0x7
    #define BUTTON_LT  0x4
    #define BUTTON_RT  0x6
    #define BUTTON_STICK_LEFT  0x12
    #define BUTTON_STICK_RIGHT  0x13
    //####################################################################//
     
     
     
     
     
     
    void Superman(void)
    {
        uint pid = GET_PLAYER_ID();
        if (pid >= 0)
            if (IS_PLAYER_PLAYING(pid))
                if (PLAYER_HAS_CHAR(pid))
                {
                    Ped ped;
                    GET_PLAYER_CHAR(pid, &ped);
                    if (ped > 0)
                    {
                        SET_PLAYER_INVINCIBLE(pid, TRUE);
                        SET_PLAYER_NEVER_GETS_TIRED(pid, TRUE);
                        SET_PLAYER_FAST_RELOAD(pid, TRUE);
                        ENABLE_MAX_AMMO_CAP(FALSE);
                        UpdateWeaponOfPed(ped, WEAPON_KNIFE);
                        UpdateWeaponOfPed(ped, WEAPON_MOLOTOV);
                        UpdateWeaponOfPed(ped, WEAPON_DEAGLE);
                        UpdateWeaponOfPed(ped, WEAPON_SHOTGUN);
                        UpdateWeaponOfPed(ped, WEAPON_MP5);
                        UpdateWeaponOfPed(ped, WEAPON_AK47);                
                    }
                }
    }
     
    //###################################################################################//
    //#############################BUTTON FUNCTIONS START################################//
    //###################################################################################//
     
    void SetGodMode(void)
    {
        if ((IS_BUTTON_PRESSED(0, BUTTON_STICK_LEFT)) && (IS_BUTTON_PRESSED(0, BUTTON_STICK_RIGHT)) ) //Button Combo
        {
            Superman();
            PRINT_STRING_WITH_LITERAL_STRING_NOW("string", "GodMode Enabled", 1000, 1);
        }
     
    }
     
    //###################################################################################//
    //#############################BUTTON FUNCTIONS END##################################//
    //###################################################################################//
     
    void SpawnVehicle(uint hash)
    {
        REQUEST_MODEL(hash);
        while (!HAS_MODEL_LOADED(hash)) WAIT(100);
        float x, y, z;
        GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS(GetPlayerPed(), 0, 5.5, 0, &x, &y, &z);
        Car c;
        CREATE_CAR(hash, x, y, z, &c, TRUE);
        SET_CAR_CAN_BE_DAMAGED(hash, FALSE);
        SET_CAR_CAN_BE_VISIBLY_DAMAGED(hash, FALSE);
        SET_CAN_BURST_CAR_TYRES(hash, FALSE);
        MARK_MODEL_AS_NO_LONGER_NEEDED(hash);
    }
     
    void InitThisScript(void)
    {
        int randint;
        GENERATE_RANDOM_INT(&randint);
        SET_RANDOM_SEED(randint);
     
        THIS_SCRIPT_SHOULD_BE_SAVED();
        SET_THIS_SCRIPT_CAN_REMOVE_BLIPS_CREATED_BY_ANY_SCRIPT(TRUE);
    }
     
     
    void InitPlayer(void)
    {
        SET_PLAYER_CONTROL(GetPlayerIndex(), TRUE);
        SET_CHAR_COORDINATES(GetPlayerPed(), 2242.19,  727.24,  5.91); //airport
        SET_POLICE_IGNORE_PLAYER(GetPlayerIndex(), FALSE);
        SET_CHAR_RELATIONSHIP_GROUP(GetPlayerPed(), 0);
     
    }
     
    void HideLoadingScreen(int time)
    {
        FORCE_LOADING_SCREEN(FALSE);
        DO_SCREEN_FADE_IN_UNHACKED(time);
    }
     
    void InitVisual(void)
    {
        RELEASE_WEATHER();
        RELEASE_TIME_OF_DAY();
    }
     
    void main(void)
    {
        InitThisScript();
        InitPlayer();
        InitVisual();
     
        Superman();
     
     
        WAIT(2000);
        HideLoadingScreen(4000);
     
        while (TRUE)
        {
            WAIT(0);
     
                SetGodMode();
     
        }
     
    }
     
  2. ap ii intense

    ap ii intense Crescent Fresh

    Messages:
    611
    Likes Received:
    399
    so do you have to have gta 4 on steam to get the gta4.exe?
     
  3. Cathering

    Cathering Seasoned Member

    Messages:
    1,112
    Likes Received:
    555
    It's not C++, it's C. They're less similar than you think. I'm being picky I know, but just to correct something...
     
    BlakeHar likes this.
  4. iModMuch

    iModMuch Power Of The Mind

    Messages:
    1,110
    Likes Received:
    185
    oh okayy
     
  5. 15xv

    15xv Enthusiast

    Messages:
    141
    Likes Received:
    10
    am i the only person that doesnt understand this tut?
     
    Under_Magic_11 likes this.
  6. iModMuch

    iModMuch Power Of The Mind

    Messages:
    1,110
    Likes Received:
    185
    me ??
     
  7. Xx Qc 420 xX

    Xx Qc 420 xX Real Life Mods 2.0

    Messages:
    1,250
    Likes Received:
    268
    hey when i try to compile its says that the they cant find the path but the thing i have put the exact path ... any suggestion ?
     
    Xxchr0m3kingxX likes this.
  8. iModMuch

    iModMuch Power Of The Mind

    Messages:
    1,110
    Likes Received:
    185
    ermm ill get back with you on that one
     
  9. Xx Qc 420 xX

    Xx Qc 420 xX Real Life Mods 2.0

    Messages:
    1,250
    Likes Received:
    268
    got it to work with some research it appear that the compiler is not good here

    whats i edited
    @ECHO OFF
    :loop
    CLS
    FOR /F %%G IN (Files.txt) DO Compiler\scocl.exe GTAIV "%%G" "C:\ScoCompiler\ScoCompiler\Output\"
    @ECHO Compiling Completed.
    @ECHO Press Enter To Recompile.
    PAUSE
    goto loop
     
    Xxchr0m3kingxX likes this.
  10. Mr J Smallwood

    Mr J Smallwood Enthusiast

    Messages:
    183
    Likes Received:
    93
    Well your just right to be picky and correct him as C++ code is structured differently to C.
     
  11. Cathering

    Cathering Seasoned Member

    Messages:
    1,112
    Likes Received:
    555
    No. Not structured differently, syntacically (they way the language is structured) they are the same, but C++ has more features such as object orientation, generics, inheirtance and many other features that make it a different to original C.

    The "++" of "C++" is derived from the increment (to up something up by 1) symbol in programming. It effectively means "version 2 of C" according to an article I read. So by that logic, C++ would have more features than C.
     
    xDeagleModz likes this.
  12. TLE MagicDrift

    TLE MagicDrift GTA IV PC Drifter

    Messages:
    1,206
    Likes Received:
    54
    you got this from deluxe from heavenmods ive seen this before nothing special takes alot of time to make scripts and all but basically the game is ruined! :frown: but on bright side atleast we can have more fun then before
     
  13. Mr J Smallwood

    Mr J Smallwood Enthusiast

    Messages:
    183
    Likes Received:
    93
    Opps. I said structured differently as thats what my Tutor told me but obviously he was wrong so i will take him up on that.
     
  14. Liquid44

    Liquid44 Banned

    Messages:
    1,085
    Likes Received:
    524
    Can we use c++ to write the scripts and the compiler will accept it? or does it have to be c
     
  15. NoGreed

    NoGreed Enthusiast

    Messages:
    12
    Likes Received:
    0
    Jeeeeeeeeeeeez controller binds are so garbage
     
  16. uncledaniel12

    uncledaniel12 Newbie

    Messages:
    32
    Likes Received:
    0
    Where do I get the GTAIV.exe file? I'm modding for Xbox 360.
     
  17. SalvatoreLeone

    SalvatoreLeone Enthusiast

    Messages:
    377
    Likes Received:
    27
    Thanks for tut, any chance of a quick tut on how to use c++ i.e. making basic scripts
     
  18. The_Unkwn898

    The_Unkwn898 Banned

    Messages:
    56
    Likes Received:
    2
    Really, how to use C++ to make scripts, it's not C++ I will explain below.

    C++ used C as a starting point, but now those 2 languages are rather different.

    C is standardized as ISO 9899. C++ is standardized as ISO 14882. Those 2 texts contain the most correct definitions of each language. If you write a code that fully complies to those definitions, it will run on any operating system (Windows/Mac/Linux/iOS/Android/PS3/Xbox360/PSP/etc.) without modifications if that system implements compliant compiler.

    Scocl took basic syntax of C, stripped down it's standard library (which is about a half of the language) and provided a framework to call GTA native functions.

    So really learn C syntax, and you will be fine. http://en.wikipedia.org/wiki/C_syntax

    Scroll down to Array Paramters, this is the code below:

    Looks similar to what Scocl needs for the code to compile into "code" which will run on GTA IV right? Except Scocl makes you enter at a tiny bit higher level than C Syntax, which Scocl is written in, they tried to hide the source the OpenIV Dev team have by using Delphi as they think you wont get the source, well from ASM format I can re-write there whole OpenIV program into C++, honestly I dont think they are bright people at all, and you can all tell them that, and they can read this. I will whenever I am not working on things I will post up on how to create simple scripts for GTA IV nothing really long, just so people will understand.
     
  19. Exploitable SQL

    Exploitable SQL Modding Bring's Games to Life

    Messages:
    539
    Likes Received:
    121
    Can someone come on TW and help me set up the Compiler PM Me Thanks
     
  20. SalvatoreLeone

    SalvatoreLeone Enthusiast

    Messages:
    377
    Likes Received:
    27
    ummm thanks ? lol