Antibird
Members-
Posts
177 -
Joined
-
Last visited
Everything posted by Antibird
-
Here's a very basic script to show the idea of how things can be done. However you can't aim with your weapon when camera is not following the player in it's "typical" way. You can make a separate client-side script file out of it. local x, y, z, x1, y1, z1 local fpcam = false local PLAYER = getLocalPlayer() bindKey( "F1", "down", function() if fpcam then setCameraTarget( PLAYER, PLAYER ) end fpcam = not fpcam end ) addEventHandler( "onClientPreRender", root, function() if fpcam then x, y, z = getPedBonePosition( PLAYER, 6 ) setCameraMatrix( x, y, z, x + x1, y + y1, z + z1 ) end end ) addEventHandler( "onClientCursorMove", root, function( _, _, _, _, wx, wy, wz ) local cx, cy, cz = getCameraMatrix() x1 = ( wx - cx ) / 300 y1 = ( wy - cy ) / 300 z1 = ( wz - cz ) / 300 end )
-
Because of this: http://en.wikipedia.org/wiki/Floating_point But saying shortly, using round functions helps in many cases.
-
Korean I think: https://forum.multitheftauto.com/viewtop ... 60#p304360 But anyway, you better find somebody who speak both your native language and English as well, google translator is not perfect.
-
At line 3 you point at the function which you later declare at line 4, but this should be vice-versa. Put a timer after function, not before it, e.g after line 13. Either move the function out of the onClientResourceStart() body.
-
Do you run it clientside? Just quickly checked through the server console, returned 3 "true" and a file. UPD Nice for clientside as well, both with full path and relative one. Weird, your code is fine. Try to make new resource from scratch and avoid using "xml" into it's filename. Sounds weird, I know, but who knows. I clearly remember I couldn't give a "hud" name to the node. Everything else was working, but "hud" wasn't. You may be the chosen one
-
Try to use two backslashes in the filepath instead of the single slash, like: xmlCreateFile(":xmlsave\\vvv.xml", "xml") I'm not joking. If it doesn't help, try to specify a path via only a filename without a name of the resource.
-
It's obvious that "source" is not equal to "Truck[thePlayer]" in the "exit" event. But since you say "truckerarbeit_func" does the job just great and there are no any errors/warnings in server console, then I can't tell you what's wrong, I can't see the reason. It's something related to the rest code you have, most likely some mess with "Truck" table. Use debug strings throughout the code, check it line by line. Either post everything here if you like so.
-
Exactly. Should output something like "userdata: [some hexadecimal number]". If one hex is not equal to another one then " if ( source == Truck[thePlayer]) " condition won't ever become true. By the way, why not to have a check: function exitVehicle ( thePlayer, seat, jacked ) if ( source == Truck[thePlayer]) then outputChatBox( "must be correct!" ) local success = destroyElement(Truck[thePlayer]) if sucess then outputChatBox( "vehicle destroyed" ) end else outputChatBox( "Epic fail" ) end end addEventHandler ( "onVehicleExit", getRootElement(), exitVehicle ) or something like that. Come on, fill up your code with debug strings. It always helps. How can you fix the error if you have no idea where it's located? I don't see anything wrong with Gamesnerts code neither.
-
function exitVehicle( thePlayer ) outputChatBox( tostring( source ) ) outputChatBox( tostring( Truck[thePlayer] ) ) end addEventHandler ( "onVehicleExit", getRootElement(), exitVehicle ) Do line 2 and line 3 output the same?
-
Sorry, maybe I misread the question, but I think you was asking for this: M = getElementMatrix( vehicle ) rotZ = math.deg( math.atan2( M[1][2], M[1][1] ) ) If I'm correct, being upside-down makes getVehicleRotation() return Z coordinate swapped 180 deg. In this case to get the heading, I'm using getElementMatrix(), and it works just great regardless of vehicle orientation. UPD: Indeed, I misunderstood. Have a look at code below, handled by timer, this will push your vehicle in a direction you need: local velx, vely, velz = getElementVelocity ( vehicle ) local X, Y, Z = 0, 0.1, 0 --try out setting different values here setElementVelocity( vehicle, velx + X * M[1][1] + Y * M[2][1] + Z * M[3][1], vely + X * M[1][2] + Y * M[2][2] + Z * M[3][2], velz + X * M[1][3] + Y * M[2][3] + Z * M[3][3] ) , where X is relative to "left-right" movement, Y for "forward-backward" and Z for "up-down".
-
Hello. If anybody could be so kind to explain, I'd like to know the difference between vehicles created via map file info on resource startup and vehicles created by "createVehicle()" function ( on the resource startup as well, means no players connected yet, if that matters ); which positive/negative sides both ways (probably) have?
-
Doomed_Space_Marine, yes, I've noticed the same. Variating the minute duration affects blending time. I've also seen It been discussed somewhere already. Hope one day MTA team tweak setWeatherBlended() functon into more flexible and powerful thing to play with the weather changes.
-
game freezee after connect, (+converting maps to lua)
Antibird replied to dzek (varez)'s topic in Scripting
Hello there. If you convert maps into client-side scripts, the first thing you should worry about is saving your copyrights, since every player then gets an access to your map, being able to use it in any way he wants. Freezing of the game can be really related to the amount of objects, check if easily by non-loading the map one time and load it on next attempt. 1.02 Mb should be more than 1 thousand of objects I suppose, are you building up your own state of "San-Andreas" eh -
I've been using onClientPreRender for a cockpit camera and there is no problem to me, but onClientRender brings the "shaking" effect. However I have a getElementMatrix() instead of of getElementPosition(), and this is the only major difference between your and mine script logics. Does it matter? No idea, so I can't see a reason why onClientPreRender doesn't work to you in a way it does to me, still this is the solution.
-
The getElementVelocity() does not return speed in kmph, but is shows the maximum speed of a vehicle in SA is 1.5. If we let 1 SA distance unit to be 1 meter (which I'm sure to myself it is), you should multiply your "speed" result at 183.33, this will give you kmph. It's '183' because if you use 50 ms timer to get the distance a vehicle traveled for 50 ms and then calculate the speed, you'll get 275. So 1.5 * 183.33 = 275. About the first point, if I understood it well, you're trying to bind a key to a function that will open a chat for input and write in there a "/su" text, so the player won't need to write that by himself? If so, I'd like to know the answer as well, since there's no way to output a text into chatbox and keep it "non-sent", saving the input for user; outputChatBox/outputConsole doesn't work in a way we need. Can anybody answer is it possible or not to make a setKeyState() function? Might be very useful to simulate a key pressed (I'm not taking into account security problems it could bring up).
-
Create a police maverick, put a ped inside, force its "horn" control on; switch off helis engine, remove collision and make it whole invisible. Then attach to your UFO.. Or you may want to try a white arrow marker attached "upside-down" to the UFOs bottom, so it would point to UFO from beneath.
-
( You three just explained it all well, while I was typing for the same purpose, thanks. )
-
Try this one: bindKey( "m", "down", function() showCursor( not isCursorShowing() ) end )
-
Hello there.There's a problem with this font having different sizes on different resolutions of my screen (and not only mine). So launched e.g 800x600 my lil gui window is finely marked-up with some text labels, however if I switch to, let's say 1440x900, the font is suddenly growing up, becomes unreadable and that looks just weird. This font has got a report on bugtracker, not sure if there was the same reason, but anyway I wonder, can this be fixed by somehow using MTA scripting gui tools and functions? And the second question is can I scale fonts or use a custom font I need. This is a point I can't get: to have fonts of 7 - 9 pixels, then 26 pixels but nothing else between those two sides. https://wiki.multitheftauto.com/wiki/GUI_Fonts EDIT: Here was a discussion http://bugs.mtasa.com/view.php?id=2955, especially custom fonts would be just a piece of cake. Well, if I'm correct it's related to cegui engine, means this won't be solved soon? Anyway, capsed default font makes the job more or less. I see no more simple solutions.
-
There are lot of syntax mistakes: Lines 3, 11, 15: missed "( )" after function name Line 4: should be for index, player in [color=#FF0000]pairs[/color]( getElementsByType ( "player" ) ) do Line 5: bindKey ( player, "p[color=#FF0000]", "[/color]down", "hookCursor" ) Line 9: "onPla[color=#FF0000]y[/color]erJoin" Line 12: bindKey( source, "p"[color=#FF0000],[/color]"down", "hookCursor" ) Finally, this script can't be client-side, all the functions and events you're using are for server-side scripts.
-
Yeah, might be. Thanks again.
-
For synchronization purposes. Saying simply there is a table that stores variables which are changing on clients PC, some are by script, some by user himself; the rate of update is not preset, several values may never change while others are updated 10 times a second. The only syncing function are called by timer periodically. It checks a list of values those should be synced (just another table) key by key and if the value's been changed since the last check, the "key-value" pair is put to the list of data which is eventually sent to other client(s)/server/whatever (the destination). It all works fine and the only thing I wanted is probably to make the whole procedure more simple and, let's say, more independent of the subject it serves to atm. Not really sure, I like the process of scripting itself ) Got a chance to get into metamethods for a bit I guess.
-
The script is client-side. Yep, my fail, tried to add new field and it worked. Thank you, madis. Still, basically I need an event that is triggered every time an existing value is changed so I could get the key that stores the value. I used to copy the whole table then periodically compare 'copied' one with 'new' one (that may got some changes in it) key by key. I wonder if there's another way, thought this can be done via metatables.
