guix
Members-
Posts
37 -
Joined
-
Last visited
Everything posted by guix
-
All of you having problems submitting translations or requesting new languages: contact Talidan on IRC: irc://irc.multitheftauto.com/#mta
-
Obviously it was a mistake.
-
You can do it with function atan2 Ok it's not easy when you don't know where to start, so here is a little example: function getAnglesBetweenPoints3D( x1, y1, z1, x2, y2, z2 ) x1 = x2 - x1 y1 = y2 - y1 x2 = math.atan2( x1, y1 ) * 57.29578 y2 = math.atan2( z2 - z1, math.sqrt( (x1 * x1) + (y1 * y1) ) ) * 57.29578 return x2, y2 end function displayAngles() local x1, y1, z1, x2, y2, z2 = getCameraMatrix( localPlayer ) local a1, a2 = getAnglesBetweenPoints3D( x1, y1, z1, x2, y2, z2 ) outputChatBox( string.format( "a1 = %.2f a2 = %.2f", a1, a2 ) ) end addEventHandler( "onClientRender", root, displayAngles ) The angle you asked is a2, but you will need a1 as well isn't it?
-
Hello, Using getCameraMatrix, you have the direction vector of where the player is looking
-
Have you tried deleting gta_sa.set in My Documents/GTA San Andreas User Files
-
In the tutorial section: https://forum.multitheftauto.com/viewtopic.php?f=148&t=52868
-
Yes, that's how I found that push eax's length was 1 byte. I don't understand why you say 2 bytes? And I tried to change that number to 3, 6, really anything between 1 and 10, it's still crashing Also, by looking at other hooks in the same file, I see things like this in comments, for example: HookInstall ( HOOKPOS_CEventVehicleDamageCollision_Bike, (DWORD)HOOK_CEventVehicleDamageCollision_Bike, 6 ); ... void _declspec(naked) HOOK_CEventVehicleDamageCollision_Bike ( ) { // .006B8EC6 DC 1D F8 9E 85 00 fcomp ds:__real@0000000000000000 < Hook > // 006B8ECC 8B F1 Another example: HookInstall(HOOKPOS_CPed_IsPlayer, (DWORD)HOOK_CPed_IsPlayer, 6); ... void _declspec(naked) HOOK_CPed_IsPlayer () { /* 005DF8F0 mov eax,dword ptr [ecx+598h] <hook> 005DF8F6 test eax,eax <return> */ Which is why I think that number is the size of the first instruction at the hook position. I'm confused I can successfully disable the wheels by doing: #define HOOKPOS_CAutomobile_ProcessWheel_Size 0x6AA666 DWORD RETURN_CAutomobile_ProcessWheel_Size = 0x6AA675; void _declspec(naked) HOOK_CAutomobile_ProcessWheel_Size() { _asm { jmp RETURN_CAutomobile_ProcessWheel_Size } } But I can't find how to push those floats! I tried: #define HOOKPOS_CAutomobile_ProcessWheels 0x6AA666 DWORD RETURN_CAutomobile_ProcessWheels = 0x6AA669; float fTest1, fTest2, fTest3; void _declspec(naked) HOOK_CAutomobile_ProcessWheel_Size() { fTest1 = 0.5f; fTest2 = 0.5f; fTest3 = 0.5f; _asm { mov eax, offset fTest3 push dword ptr [eax] mov eax, offset fTest2 push dword ptr [eax] mov ecx, offset fTest1 push dword ptr [ecx] //mov eax, fTest3 //push [eax] //mov eax, fTest2 //push [eax] //mov ecx, fTest1 //push [ecx] jmp RETURN_CAutomobile_ProcessWheel_Size } } Amongst other things, but it always crash ... Can you tell me how to fix it please.
-
Hello, I try to make a hook in CAutomobile::ProcessWheel (it's how I named sub_6AA290), however I can't make it work, it crash the game as soon as I join my server. In IDA disassembly, the part I want to hook is this: push eax ; f3 // 0x6AA666 push eax ; f2 // 0x6AA667 push ecx ; f1 // 0x6AA668 lea ecx, [esp+0F8h+m] ; this // 0x6AA669 fstp [esp+0F8h+var_F8] // 0x6AA66D call CMatrix__SetScales // 0x6AA670 CMatrix__SetScales is how I named sub_59AF00, the function prototype is (from what I understand): int __thiscall CMatrix__SetScales( CMatrix *this, float f1, float f2, float f3 ) My goal actually, is to set custom values for f1, f2 and f3 So in \MTA10\multiplayer_sa\CMultiplayerSA.cpp, I did: #define HOOKPOS_CAutomobile_ProcessWheel_Size 0x6AA666 DWORD RETURN_CAutomobile_ProcessWheel_Size = 0x6AA669; void HOOK_CAutomobile_ProcessWheel_Size(); void CMultiplayerSA::InitHooks() { ... // I'm not sure to understand the last parameter, // I've set it to 1 because from what I understand, // it must be the size of the instruction at the pos that is hooked. // So "push eax" is only 1 byte (opcode 0x50)... but is this correct? HookInstall ( HOOKPOS_CAutomobile_ProcessWheel_Size, (DWORD)HOOK_CAutomobile_ProcessWheel_Size, 1 ); ... } float fTest; void _declspec(naked) HOOK_CAutomobile_ProcessWheel_Size() { fTest = 0.5f _asm { // f3 push fTest // f2 push fTest // f1 push fTest // useless in my case? jmp RETURN_CAutomobile_ProcessWheel_Size } } So as I said, it crash the game with this code. I tried many different things, the best result I had was a flickering screen and the front-right wheel with width 0, and the 3 other wheels with weird width. Please help a ASM beginner, tell me what is wrong in my code and if possible, how to fix it. Thanks PS: Here is the crash infos: Version = 1.4-custom.0.000 Time = Thu Feb 14 13:12:14 2013 Module = Code = 0xC0000005 Offset = 0x4CF7F7BB EAX=3F800000 EBX=00B2C701 ECX=00B201D5 EDX=BF0CCCCE ESI=155BD698 EDI=00000003 EBP=00000004 ESP=0028FBFC EIP=4CF7F7BB FLG=00210297 CS=0023 DS=002B SS=002B ES=002B FS=0053 GS=002B
-
Very good, thank you
-
Hello, What do you mean? You can use most of Lua's stock functions, as far as I know only the os library has been removed.
-
I never used regular expressions but it looks like Lua's patterns, only less useful, for example with string.match you can parse a line and store results into variables in a single function call (almost like sscanf). Not bad anyway, it's just not useful for me, might be for others
-
Very good
-
Hello, you got it close: use sub instead (and add "end" after the if statement) http://codepad.org/9cM8U1zq
-
Hello, Check in server's config file for setting "fpslimit".
-
Solved: local bCommandKeyIsDown = {} local iCommandKeysDownCount = {} function handleKeyboard( key, state ) local cmds = getCommandsBoundToKey ( key, "down" ) if cmds then for cmd, _ in pairs ( cmds ) do iCommandKeysDownCount[cmd] = (iCommandKeysDownCount[cmd] or 0) + (state and 1 or -1) bCommandKeyIsDown[cmd] = (iCommandKeysDownCount[cmd] ~= 0) end end end addEventHandler( "onClientKey", root, handleKeyboard )
-
Hello I have a problem in my script that I can't seem to solve. Here is a part of my code: local bCommandKeyIsDown = {} function handleKeyboard( key, state ) local cmds = getCommandsBoundToKey ( key, "down" ) if cmds then for cmd, _ in pairs ( cmds ) do bCommandKeyIsDown[ cmd ] = state end end end addEventHandler( "onClientKey", root, handleKeyboard ) Then I check for bCommandKeyIsDown in a onClientRender, like this: function handleSomething() if bCommandKeyIsDown[ "my_command" ] then DoSomething() end end addEventHandler( "onClientRender", root, handleSomething ) The problem is when I bind multiple keys to "my_command": let's say W and X are the 2 keys bound to that command. - If I press and release W OR X, it work as expected - But if I press and hold W down, and then I press X and release X, then it's like W have been released too, but I'm still holding it down. I understand why it does that, but I don't know how to solve. Help?
-
Hello! (Looks like courteous people are a rare thing on this forum) A much easier and more efficient way of doing this is with the element matrix: local fMatrix = getElementMatrix( iVehicle ) -- Calculate a position that is 10 units (meters) in front of the vehicle's position. local X = fMatrix[4][1] + ( fMatrix[2][1] * 10 ) local Y = fMatrix[4][2] + ( fMatrix[2][2] * 10 ) local Z = fMatrix[4][3] + ( fMatrix[2][3] * 10 )
-
Hello and welcome! What is your problem? Maybe you need to use setModelHandling instead?
-
I have tried with this before but it doesn't work very well (especially when vehicle is upside down ) It's what I used in 3rd post, It's what I use in my script for now, until I make a proper fix to be very accurate with all vehicle.
-
Please read the first post, or just the topic title. I don't need this, I was just answering to his weird, indiscrete question...
-
How are rotations useful in my case?
-
I try to add a detection when vehicle is upside down, to make a "autoflip". I think I fixed it by replacing isVehicleOnGround by: local fGroundZ = getGroundPosition ( fPositionX, fPositionY, fPositionZ ) if fPositionZ - fGroundZ < 3 then // vehicle is close to ground Works very well but need to test more.
-
Hello, I have an small problem because isVehicleOnGround does'nt always work , for example with Dumper or Monster, it's most of the time returning false, only if for example I do a big jump and when landing the suspensions go down, so then it is true for a short time. I believe it's something to do with comparing distance from vehicle's mass center with ground. What can I do?
-
Thank you, I've just found the same thing on the sticky just above... Sorry!