Jump to content

The_GTA

Helpers
  • Posts

    822
  • Joined

  • Last visited

  • Days Won

    86

Everything posted by The_GTA

  1. By using the above "interpolate_position" function you can spawn the object one metre or farther in front of the camera. local start_distance = 1 -- the amount of metres to be starting away from local start_x, start_y, start_z = interpolate_position( csx, csy, csz, cdir, start_distance ); local object = createObject ( 1600, start_x, start_y, start_z ) You can then use start_x, start_y, start_z vector instead of csx, csy, csz vector in the above onClientRender event handler to perform the flight from the new position. Maybe you want to spawn an object in front of the player instead? Then you need to use different mathematics: the element matrix. I recommend you a read of the wiki article about MTA's matrix implementation. But here is some sample code. local rotVec = Vector3(getElementRotation(localPlayer)); local posVec = Vector3(getElementPosition(localPlayer)); local playerMat = Matrix(posVec, rotVec); local one_metre_in_front = playerMat.transformPosition(Vector3(0, 1, 0)); This code could be simplified if you enable OOP for your MTA resource. Then you can access the "localPlayer.matrix" field to get the matrix instead of calculating it.
  2. Sounds like a lag issue due to the server-side event "onPlayerVehicleEnter". Could you try using the clientside event "onClientPlayerVehicleEnter" instead and using the clientside version of setVehicleLightState?
  3. Interesting feature request. So what script have you tried so far that did not work for you? Did you try setting the vehicle headlight state during every onClientRender? If you post a script then we could test it ourselves. But I doubt that there is a feature that just disables turning on the headlights other than setting them to broken.
  4. Have you replaced the "jailTime1" event handler with the code I posted? That is all that you have to do.
  5. Hello SoManyTears, in line 24 you have to... addEvent ( "jailTime1", true ) addEventHandler ( "jailTime1", root, function ( ) countDown = 20 start = getTickCount() addEventHandler("onClientRender",root,render) addEventHandler("onClientRender",root,jailText) render() setTimer(function() removeEventHandler("onClientRender",root,jailText) end, 20000, 1) end ) ... reset the timer variables countDown and start. Other than that you could improve this script by starting a one-second timer for removing the jailText onClientRender event in line 9. Then the text would not be prematurely removed due to frame-time differences to the real clock.
  6. Hello Spakye, I think that time synchronization can be very accurate. If you count the time on the server then you can tell the client on join what time it is. Then, assuming that the clients count the time the same speed, they can tell all the future time values without a single message by the server. So it does not stress the network and does not create performance problems on the client. I do not understand how you assumed that it would be "laggy for the server"? I recommend the following functions to synchronize the time: setMinuteDuration - recommended to set something higher than 1000 to have more accurate time if players have like 500ms lag getTickCount - you can create some kind of time counter using this function getRealTime - if you want to use the wall-clock as time using a minute duration of 60000 ms then use this Hopefully my answer could help you get the hang of this problem.
  7. Since there is no serverside physics simulation you really should do the hit detection on the clientside. You have to take physics depending on player framerate into account which is impossible to do on the server. Thus the client has to trigger a server event to tell the server about a projectile hit. I hope you see that anything involving game physics is doomed from a security point of view. But that is why we have anti-cheat detection systems built into the MTA system so do not worry. ?
  8. The_GTA

    Inventory

    Hello redditing, please look at my discussion about general inventory system design with iwalidza: It does cover the creation of any inventory system and does give recommendations for functions you should use.
  9. Hello Bartje, I understand that you want to simulate shooting a rocket launcher in the direction of the player's view/camera/where-he-is-looking-at. I assume that you want to have the definition of the line starting from the camera position going in the direction of the camera's front vector. This is actually not as difficult as you might think. Here is some code as an idea. client.Lua -- Calculate the direction vector. local csx, csy, csz, ctx, cty, ctz = getCameraMatrix(); local cdir = Vector3(ctx - csx, cty - csy, ctz - csz); cdir:normalize(); -- The line starts of (csx, csy, csz) and the direction vector is cdir. -- You can now interpolate on this line using setElementPosition and the following function. local function interpolate_position(px, py, pz, dir, timeSpeed) return px + dir.x * timeSpeed, py + dir.y * timeSpeed, pz + dir.z * timeSpeed; end -- An example? local obj = createObject(1454, csx, csy, csz); local moveStart = getTickCount(); addEventHandler("onClientRender", root, function() local curTime = getTickCount(); local elapsedTime = ( curTime - moveStart ); local timeSeconds = elapsedTime / 1000; setElementPosition(obj, interpolate_position(csx, csy, csz, cdir, timeSeconds)); end ); (code not tested) Explanation: the direction is defined as the normal vector of the difference between two 3D points. You can subtract the start 3D vector from the target 3D vector to get the difference between two 3D points. Of course, if you want to keep multiple objects flying in certain directions you must remember their starting positions and their direction vectors along with the MTA object handle. Should be a good exercise with the boiler-plate code above. You have mentioned the moveObject function. Your feeling may be correct because that function does specify fixed timelimit for object flight whereas above code does allow for indefinite length of object flight. - Martin
  10. Which resources are storing SQL data and do you know what kind of data it is? Since you are making a server does it mean that you are creating scripts that use SQL for it too? Your support request might turn into a resources question: do all resources properly store their SQL data at any given point x between events? But if we get a better idea about your server resources setup we could imagine how to start it. ?
  11. Hello Rolplay, you have to use shaders and apply them to the exhaust smoke texture. Then you can multiply pixel with a black tint. Only downside is that the smoke could be used somewhere else in the game and that is going to be black aswell.
  12. Actually no, the system I recommended does not work if you want to dump while the server is operating on the database. If you want to dump during server runtime you absolutely have to do so with a server resource. Maybe like this... output a server message that the server is saving data, thus not responding for a while save the entire game state to the database; this is so that the database is in a consistent state create a .sql file into the resource directory write the table layouts as CREATE TABLE commands into the .sql file dump the table contents as INSERT INTO commands into the .sql file flush and close the .sql file resume server execution output a server message that the server has finished saving data Sorry but I have no easy solution for you. It would be best if MTA itself had a dumping function since this feature seems pretty important for data security.
  13. Hello Hazardinho, how about dumping the SQLite database into one big query .sql file and running that query inside of your MySQL server to load the database? Take a look at the following article: https://www.sqlitetutorial.net/sqlite-dump/ I have no experience with dumping from SQLite to MySQL but I think that the query format should be very compatible.
  14. Correct. You have be to logged-in as admin of course. This way you see both client-side errors as well as server-side errors. Always happy to help! ?
  15. Hello Bartje, the problem is that you are mixing up client-side functionality with server-side functionality. You are trying to use the localPlayer global variable in a server-side script. But there is no localPlayer on the server because the server is not a game window. Fixed script for you: function createTheMarker ( cmdPlayer ) local x, y, z = getElementPosition(cmdPlayer) local theMarker = createMarker ( x, y+5, z, "cylinder", 1.5, 255, 255, 0, 170 ) addEventHandler( "onMarkerHit", theMarker, markerTriggered ) end addCommandHandler ( "create", createTheMarker ) function markerTriggered ( ) outputServerLog ( 'hit' ) end Did you know about the script debug output? If you look into the server console then it should tell you which line is at fault and maybe which function got you an error.
  16. https://www.w3schools.com/SQL/sql_orderby.asp SELECT state1, state2, state3, ..., characterName FROM characters WHERE ... ORDER BY characterName ASC
  17. The_GTA

    hat script

    I recommend you to look at the maskepanel resource aswell, the one that Patrick posted. It has good sample code if you need to know specifics.
  18. The_GTA

    hat script

    local object = createObject(hat_model, 0, 0, 0) exports.bone_attach:attachElementToBone(object, localPlayer, 1, 0, 0, 0, 0, 0, 0) clientside script. not tested. addCommandHandler("hat", function(p) local object = createObject(hat_model, 0, 0, 0) exports.bone_attach:attachElementToBone(object, p, 1, 0, 0, 0, 0, 0, 0) end ); serverside version.
  19. Hello XxARTUROxx, have you tried searching on the community resources website for roleplay scripts? Do you want to learn Lua to create your very own roleplay scripts?
  20. The_GTA

    hat script

    Hello WIRECOM, have you tried using the bone_attach resource and attaching the hat object to the head bone of your ped? What kind of hat are you trying to display on the head?
  21. The_GTA

    Nightvision

    Hello 1LoL1, here are some relevant functions: setCameraGoggleEffect - you can disable the nightvision effect using this function takeWeapon - combined with setCameraGoggleEffect you can remove the nightvision stuff from a player
  22. Thank you for coming back to this forum and sharing the results of your work/research! I wish more people would do this kind of thing.
  23. Hello Aaron, use the setPlayerVoiceBroadcastTo serverside function to limit the voice to phoning players, etc. Did you know that MTA has many sound functions? Please take a look at the wiki to find the features that you need for radio. Also take a look at the resource community site to find example resources.
  24. sorry about multi-post, the board has had an issue.
  25. Since PC infections are a serious issue, the user should also reinstall their Windows 10. But we are not a virus support board. We just happen to have the best virus detection system as well as support team. ?
×
×
  • Create New...