Jump to content

Unexpected bug in a script


Krazy

Recommended Posts

Hey guys. my friend made me a script and everything is fine but when a vehicle gets explode in map, mta shuts down somehow with some bugs roster, here is the script

addEventHandler("onClientVehicleCollision", root,
  function(collider,force, bodyPart, x, y, z, nx, ny, nz)
    if ( source == getPedOccupiedVehicle(localPlayer) ) then
      if (collider) then
        fixVehicle(source)
      end
    end
  end
)

 

PS : the script is about an undamage land, it works like when you jump your car doesn't lose health

Link to comment

Crash information:

Version = 1.5.4-release-11595.8.000
Time = Mon Aug  7 05:54:44 2017
Module = E:\GTA San Andreas\gta_sa.exe
Code = 0xC0000005
Offset = 0x000F6655

EAX=00000000  EBX=00000001  ECX=0FB10048  EDX=019163E0  ESI=0FC1F200
EDI=FFFFFFFF  EBP=00000000  ESP=0177FB48  EIP=004F6655  FLG=00010287
CS=0023   DS=002B  SS=002B  ES=002B   FS=0053  GS=002B
 

Link to comment

Try this.

addEventHandler("onClientVehicleCollision", root,
	function(collider,force, bodyPart, x, y, z, nx, ny, nz)
		if (source == getPedOccupiedVehicle(localPlayer)) then
			if (collider) and not isVehicleBlown(source) then
				fixVehicle(source)
			end
		end
	end
)

 

  • Like 1
Link to comment

Yes, already removed the script and tried the vehicle explosion and everything went cool, but when i added it back the problem started to occur, i am not a professional scripter but i feel like the script don't know what to do once the vehicle explode, more like it gets bugged somehow

Edited by Krazy
Link to comment

What you can try to do is debug where the game crashes.

addEventHandler("onClientVehicleCollision", root,
	function(collider,force, bodyPart, x, y, z, nx, ny, nz)
		outputChatBox("Function called, crashed before getting player veh")
		if (source == getPedOccupiedVehicle(localPlayer)) then
			outputChatBox("Got player veh, crashed before checking if it has a collider or the veh is blown up")
			if (collider) and not isVehicleBlown(source) then
				outputChatBox("Checked if it has a collider or the veh is blown up, crashed before fixVeh")
				fixVehicle(source)
				outputChatBox("Got fixVeh and crashed")
			end
		end
	end
)

Try this one and once it crashes check your logfile.

  • Like 1
Link to comment

Still facing the bug, that's what appeared in logfile

 

23:12:36 - [DEBUG] BeginEventLog
23:12:37 - [DEBUG] DLL_PROCESS_ATTACH 00000000
23:12:37 - [DEBUG] CLocalization::CLocalization Localization set to 'en_US'
23:12:43 - [DEBUG] Loader - Finishing
23:12:45 - [DEBUG] DLL_PROCESS_DETACH 00000001
23:12:52 - [DEBUG] DLL_PROCESS_DETACH 00000001
 

Link to comment

Well, when i start the map everything goes smoothly, but when my vehicle gets explode, the game freeze and stop somehow then some error occur, Could you check if the script is well made because i feel like there is something wrong on it some line, i mean the way the script works

Edited by Krazy
Link to comment

Alright. Do me a favor. If you haven't updated your code with mine, do it now (which has the outputs in it). If you have done the update, go ahead and join your server and blow your vehicle up. After it blew up, open your console.log file and tell us whats inside it.

Edited by NeXuS™
  • Like 1
Link to comment
  • Administrators

Very strange. I have just tested this myself and nothing relevant shows up in the console.

Upon blowing the vehicle up, there is a slight freeze and the game crashes with the following information:

Version = 1.5.4-release-11595.1.000
Time = Mon Aug  7 22:12:51 2017
Module = C:\Program Files (x86)\QuickTime\QTSystem\QuickTime.qts
Code = 0xC000001D
Offset = 0x00A13A73

EAX=00863C40  EBX=00300000  ECX=0C737400  EDX=00000000  ESI=0C737400
EDI=3F800000  EBP=00080000  ESP=0028FC70  EIP=66253A73  FLG=00210246
CS=0023   DS=002B  SS=002B  ES=002B   FS=0053  GS=002B

It should be worth noting that I used this code (as collider would return nil, I was just testing at Grove Street):

addEventHandler("onClientVehicleCollision", root,
	function(collider,force, bodyPart, x, y, z, nx, ny, nz)
		if (source == getPedOccupiedVehicle(localPlayer)) then
			fixVehicle(source)
		end
	end
)

 

Using the code you provided fixed the crashing (as it never got inside the isVehicleBlown block), however I did experience the slight freeze upon respawning. I only have the default play resource loaded, and of course this script.

I suspect this is something to do with fixVehicle when used on a blown vehicle.

Edited by LopSided_
  • Like 1
Link to comment

@NeXuS™ , your code is already the same with my code, as i tested few mins ago

 

 

@LopSided_, Exactly, but it is possible though, saw it in a server before and it works fine, don't know what's wrong with my code

@NeXuS™, i tested again and the outputs appear perfectly,

 

[2017-08-07 23:12:22] [Output] : Function called, crashed before getting player veh
[2017-08-07 23:12:22] [Output] : Got player veh, crashed before checking if it has a collider or the veh is blown up
[2017-08-07 23:12:22] [Output] : Checked if it has a collider or the veh is blown up, crashed before fixVeh
[2017-08-07 23:12:22] [Output] : Got fixVeh and crashed

 

which is i reckon mean that there is no bug on it somehow !?

Edited by Krazy
Tested again
Link to comment
  • Administrators

@Krazy the issue here is using fixVehicle on a vehicle that has been blown up. In the code that NeXuS provided he solves this issue by checking isVehicleBlown, if this returns true then fixVehicle is not called.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...