Forum: Grand Theft Auto Series Modding - Our GTA Modding Team is the best around. Tutorials & Topics related to modding your GTA games, trophies, and save files! Discuss GTA game modding with the knowledgeable members of PSX-Scene and the Official GTA IV Mod Team.


The above video goes away if you are a member and logged in, so log in now!




 
Would you like to get all the new info from
PSX-Scene in your email each day?




Want to learn more about the team keeping you up to date with the latest scene news?

Read about them now!

Check out our Developer bios, too!

 


User Tag List

Like Tree11Likes
  • 11 Post By JDMAlex

Thread: [TUT] Debugging a freezing script (my method)
  

Results 1 to 8 of 8
  1. #1 [TUT] Debugging a freezing script (my method) 
    JDMAlex's Avatar
    JDMAlex is offline & developer
    Join Date
    Nov 2010
    Posts
    723
    Downloads
    5
    Uploads
    1
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    190
    Likes Received
    442
    My method to finding why your script freezes if there is a better method than this I would like to know! but this one seems pretty good for now

    what you need:
    below is the code I use currently that displays a message "break" for every line I put it on and also displays a message to press X to continue the loading process.

    Code:
    #define DEBUG // If you have this at the top it will allow debug message to show , if you remove it they will be hidden/non function.
    
    void DebugBreak(char *sMessage){
    #ifdef DEBUG
    	PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", sMessage , 5000, 1);
    	WAIT(800);
    	PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", "DEBUG BREAK , PRESS X TO CONT" , 5000, 1);
    	while(!IS_BUTTON_JUST_PRESSED(0,X)) WAIT(0);
    #endif
    }
    Now what I do is in every line from top to bottom (when I get a freeze) I insert DebugBreak("Name_To_display"); on top of the native or code being executed
    like this:

    Code:
    example
    
    void CheckPlayer(void){
    DebugBreak("DOES_CHAR_EXIST");
    	if(DOES_CHAR_EXIST(GetPlayerPed())){
    DebugBreak("IS_CHAR_DEAD");
    		if (IS_CHAR_DEAD(GetPlayerPed())){
                    DebugBreak("DOES_CHAR_EXIST  ");
    			if(DOES_CHAR_EXIST(GamePed)){
                                  DebugBreak("etc  ");
    				EXPLODE_CHAR_HEAD(GamePed);
                                  DebugBreak("etc  ");
    				TASK_DIE(GamePed);
                                  DebugBreak("etc  ");
    				if(DOES_BLIP_EXIST(GamePedBlip))     DebugBreak("etc  ");REMOVE_BLIP(GamePedBlip);
    				if(DOES_BLIP_EXIST(Base))     DebugBreak("etc  ");REMOVE_BLIP(Base);
    				GameSwitch = 0;
    			}
    		}
    	}
    }

    thats pretty much it , compile it / run it / press x when it says and pay attention to the key words you picked to pinpoint you to the exact moments you freeze!
    Last edited by JDMAlex; 10-11-2012 at 05:11 PM.
    Reply With Quote  

  2. #2  
    Colt's Avatar
    Colt is offline Developer
    Join Date
    Jun 2012
    Posts
    737
    Downloads
    0
    Uploads
    0
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    729
    Likes Received
    215
    I'm amazed I didn't think of this before! Nice JDM.
    Mod Videos: http://www.youtube.com/DontGetAngryBro
    Reply With Quote  

  3. #3  
    zorg93's Avatar
    zorg93 is offline Developer
    Join Date
    Jun 2012
    Posts
    254
    Downloads
    0
    Uploads
    0
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    50
    Likes Received
    142
    there is an opcode for catching errors in the game(opcode 73), but im guessing scocl hadnt been designed with that feature in mind

    but thats a nice bit of code you have there anyway.
    what i usually did was just use print("1"); print(2); etc before each statement i thought would cause me to freeze out, but this definitely looks a more professional way of doing it
    Reply With Quote  

  4. #4  
    JDMAlex's Avatar
    JDMAlex is offline & developer
    Join Date
    Nov 2010
    Posts
    723
    Downloads
    5
    Uploads
    1
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    190
    Likes Received
    442
    yeh , I also did it that way but sometimes I would forget to pay attention to the number but that opcode sounds better
    Reply With Quote  

  5. #5  
    MaxSpeed's Avatar
    MaxSpeed is offline Member
    Join Date
    Jun 2012
    Location
    MI, USA
    Posts
    57
    Downloads
    0
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    29
    Likes Received
    18
    This is pretty much how I did it. Nice tut
    Se7enSins: Muskelprotze
    Current Project: Stash v2 (Using MenuLib)
    Reply With Quote  

  6. #6  
    JDMAlex's Avatar
    JDMAlex is offline & developer
    Join Date
    Nov 2010
    Posts
    723
    Downloads
    5
    Uploads
    1
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    190
    Likes Received
    442
    thanks , I hope others can get passed there issues by using this
    Reply With Quote  

  7. #7  
    keredor's Avatar
    keredor is offline Developer
    Join Date
    Mar 2012
    Posts
    180
    Downloads
    0
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    136
    Likes Received
    123
    Thanks alex, very cool. That will come in real handy.
    Reply With Quote  

  8. #8  
    HuN's Avatar
    HuN
    HuN is offline Moderator
    Join Date
    Feb 2012
    Posts
    463
    Downloads
    2
    Uploads
    0
    Mentioned
    22 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    436
    Likes Received
    402
    *bump*
    Reply With Quote  

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •