Jump to content


  • Posts

  • Joined

  • Last visited


  • Gang

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

arezu's Achievements


Hustler (26/54)



  1. I'm not noticing anything like that in your script, or do you mean it's slow when you are turning? I think that is because your gravity is too strong. Btw, you should use onClientPreRender instead of onClientRender for the gravity and then multiply the gravity power with the 'timeSlice' parameter you get from onClientPreRender. If you dont multiply by the time slice, then the gravity will be very different depending on your fps.
  2. I used setVehicleGravity(vehicle, 0, 0, 0) and then used setElementVelocity on the vehicle in that script instead to simulate gravity, since setElementVelocity doesn't affect the camera in the same way as setVehicleGravity.
  3. Your pcre syntax does not match anything in php or javascript either. Test it here and you will see: https://regex101.com/#pcre Remove the first anchor and it will work: [^local ]function (.*?)\( (Im completely newbie at using regular expressions so don't ask me more about it)
  4. If there a runtime error in the code you load with loadstring, for example trying to call a function that doesn't exist; then when you call the function returned by loadstring, the script you are running will stop execution (but mta will still call your code functions in the script, like events, binds etc). That means if you have code like this: local func = loadstring("outputChatBoxZ('hello, world!')") func() outputChatBox("After calling loadstring func") then the second outputChatBox will not be called. But if you are using pcall: local func = loadstring("outputChatBoxZ('hello, world!')") pcall(func) outputChatBox("After calling loadstring func") then the second outputChatBox will be called. You will get a chance to recover from script error. pcall also returns true or false if the script executed without any errors.
  5. The best way to do it is probably to create a command that saves data (maybe stopping work and afk resource first?) and then closes the server. Something like this: local resourcesToWaitFor = { "work", "afk" } local waitingForResources = {} local doShutdown = false addCommandHandler("safeshutdown", function(player) outputChatBox("Safely shutting down the server...") for k, resourceName in ipairs(resourcesToWaitFor) do local resource = getResourceFromName(resourceName) if(resource)then waitingForResources[resource] = true end end doShutdown = true for resource, resourceWaitState in pairs(waitingForResources) do stopResource(resource) end end, true, false) addEventHandler("onResourceStop", root, function(stoppedResource) if(doShutdown and waitingForResources[stoppedResource])then waitingForResources[stoppedResource] = false for resource, resourceState in pairs(waitingForResources) do if(resourceWaitState)then return false end end shutdown("The server has safely been shutdown.") end end) Make sure the resource has the rights to use the shutdown function, etc.
  6. You also have to change the velocity setElementVelocity
  7. How are you animating? show your code
  8. Something like this if you just want to get started and might want to learn about vectors more later: -- "ball" is the ball element -- "vehicle" is the vehicle element that collided with the ball local x, y, z = getElementPosition(ball) local x2, y2, z2 = getElementPosition(vehicle) local velX, velY, velZ = getElementVelocity(vehicle) local vel = math.sqrt(velX*velX + velY*velY + velZ*velZ) -- equal to getDistanceBetweenPoints3D(0, 0, 0, velX, velY, velZ) local dirX, dirY, dirZ = x - x2, y - y2, z - z2 local dist = math.sqrt(dirX*dirX + dirY*dirY + dirZ*dirZ) -- equal to getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) dirX, dirY, dirZ = dirX / dist, dirY / dist, dirZ / dist -- To change velocity of the ball now, i guess you might want to do: -- setElementVelocity(ball, dirX * vel, dirY * vel, dirZ * vel) Keep in mind that this will set the velocity of the ball to the velocity of the vehicle in the direction that the ball is compared to the center of the vehicle, and that's why you might want to instead get the point of collision in onClientVehicleCollision and use that point together with vehicle position and you could then add stuff like spin to the ball as well then, but that is a bit more advanced.
  9. You can fix it by drawing your dx stuff into a render target and changing the depth that you render the texture (also enabling depth checking), the same way I believe Ren's shader does it.
  10. Change this on line 16: dxSetRenderTarget(login.background) to: dxSetRenderTarget(login.background, true)
  11. arezu

    Prevent File

    From downloadFile wiki page: In other words: downloadFile will only download the file if the file doesn't exist, or if the file exists and the content of the file does not match the content of the file you want to download.
  12. You have to check that the file exists and that you have permission to read from it.
  13. onClientClick executes twice because it executes when you press down a mouse button and when release it. The button state is the second parameter value for the callback function. https://wiki.multitheftauto.com/wiki/OnClientClick You just have to check if button == "left" and state == "down" to make your function only detect a click when your left mouse button is pressed down.
  14. That runs on server's performance sadly, there's no client part. Tick the box "include clients" and select a player and it will tell you performance information from the player (client-side performance).
  15. Try creating a custom font of several sizes and switch between the fonts depending on the size.
  • Create New...