Jump to content

DiSaMe

Helpers
  • Posts

    1,461
  • Joined

  • Last visited

  • Days Won

    34

Everything posted by DiSaMe

  1. Using setElementPosition without setting the 5th argument to false will reset the animation. Try something like this for speed-up: local speedmult = 0.1 addEventHandler("onClientPreRender", root, function(timeslice) local x, y, z = getElementPosition(ped2) local vx, vy, vz = getElementVelocity(ped2) local speedmult = speedmult*timeslice vx, vy, vz = vx*speedmult, vy*speedmult, vz*speedmult setElementPosition(ped2, x+vx, y+vy, z+vz, true) end ) As you can see, it gets the velocity of the ped, multiplies it by some value (you can change the speed by editing the speedmult value) and adds it to the position, so it moves in the direction where the animations and control states make it move.
  2. Updating the table is faster than using getElementsByType every time. When you call getElementsByType, you are creating a new table and doing this every 0.3 seconds isn't efficient. When you update the table, the slowest code to execute is looping through all players and using table.remove (which also pushes all elements back by one index) and doing this when the player leaves isn't that much. So if you're after performance, update the table instead of creating a new one. By the way, it's better to use the player element as the key for the table: --onPlayerJoin myPlayers[source] = true --onPlayerQuit myPlayers[source] = nil --looping through all players: for player in pairs(myPlayers) do end No need to loop through the table on quit, Lua will take care of what's needed, resulting in best performance.
  3. The doors of Patriot have no textures. You could edit the model of the vehicle to add the textures or make a workaround which gets the positions of multiple points of the door (using getElementMatrix) and display the image there with dxDrawMaterialLine3D / dxDrawMaterialSectionLine3D.
  4. That's wrong. Element data is always synced unless you set the 4th argument to false.
  5. You can try using Lua coroutines. They are a nice way to pause the execution of function and resume it later. An example: function infiniteLoopFunction() local lastresume = getTickCount() while true do --do something if getTickCount() > lastresume+200 then coroutine.yield() lastresume = getTickCount() end end end function resumeLoopThread() coroutine.resume(loopThread) end loopThread = coroutine.create(infiniteLoopFunction) resumeLoopThread() setTimer(resumeLoopThread, 400, 0) This code will execute the infinite loop in the infiniteLoopFunction function, but will not cause the error. It runs the loop for 200 ms, then pauses for another 200 ms before resuming the loop again. More about coroutines: http://www.lua.org/pil/9.html http://lua-users.org/wiki/CoroutinesTutorial By the way, I used coroutines in my traffic resource to load the paths. It takes 8-9 seconds to load them on my older computer and the maximum execution time of the loop (unless you use certain functions) is 5 seconds. To avoid "too long execution" error, I put the loading code into the coroutine and the problem was solved
  6. I'm not sure what you mean. The only type you can use as account data is string. It all depends on how you convert the values between strings and other data types.
  7. Element data and event triggering are the only general ways to send the data between server and client. What's wrong about using those functions?
  8. Are you setting the money on the client rather than server? If you do, then you're not really setting it - client-side money functions only change the value which the player sees, not the one which is kept in the server.
  9. There's no way to send the data between server and client without using any bandwidth.
  10. DiSaMe

    fileOpen..

    All what xmlLoadFile does is loading the data from the file into memory. It doesn't do anything related to the data transfer.
  11. DiSaMe

    fileOpen..

    Of course, you have a file because you load it using fileOpen. Use xmlLoadFile to get the node instead.
  12. Use setElementDimension client-side. For example, you can get the dimension of the local player in onClientPreRender event, check if it has changed since the last frame and if so, use setElementDimension to change the dimension of the marker to the player's dimension. Client-side dimension changes are not synced automatically, so every player can see the same marker in their own dimension.
  13. You can replace the models during the whole gameplay process. For example, if you go to one place, the model ID has some model, then if you go to another place, another model is put into the same ID slot. If you make it like this, you may have multiple different models with the same ID as long as you make sure that these models are not both visible for the player at the same time.
  14. If that doesn't make it clear for you, maybe I should also add these: setPedRotation https://wiki.multitheftauto.com/wiki/FindRotation
  15. If that means reinventing, then I spend a lot of time reinventing. There is one thing which can only exist as long as it's reinvented: originality.
  16. toggleControl setControlState
  17. Because localplayer is probably undefined, you probably meant localPlayer.
  18. I haven't made a proper obstacle checking yet. The cars only stop if there's an obstacle in the middle. Otherwise they keep driving. As for stealing the cars, you can't just pull the peds out of them (MTA limitation), but you can kill the peds, they will fall out and you will be able to take the cars.
  19. So, you have downloaded what you need (except the ByteData, you don't need to download it, it's already included in the traffic resource). Now you have to extract these archives, override the contents of npchlc_traffic (from npchlc_traffic_0.1 archive) with the contents of paths_san_andreas_1.0 archive. Move the folders npc_hlc, server_coldata, npchlc_traffic and optionally npchlc_traffic_denctrl to the server resources folder, then start npchlc_traffic.
  20. This problem was solved a few days ago: http://bugs.multitheftauto.com/view.php?id=7478
×
×
  • Create New...