Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by arezu

  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.
  16. No, you can use packet sniffing tools to read received packet data, but nobody who has the knowledge to do that would bother doing that and trying to deduce which encrypted strings that are received that are part of the script, and the scripts are sent in several packets so they would need to find them all and put them together. It would be much easier and less troublesome for them if they made the lua scripts themselves instead. As long as scripts are sent to client, they can always be stolen. I think that was fixed.
  17. That is not enough luac.multitheftauto.com encrypts your file the same way packets are encrypted when you are sending data from server to client (triggerClientEvent). The other option is to add cache="false" in meta for script file, and it will send the file to client encrypted (just like triggerClientEvent) and load it but not save it on the clients harddrive, the exact same thing you are trying to do with triggerClientEvent + loadstring.
  18. setVehicleHandling animGroup "GetOutF" could maybe have worked, but it was disabled because
  19. Did you try https://wiki.multitheftauto.com/wiki/GetPedTargetCollision?
  20. You can just do this and it will automatically shoot forwards, and it wont collide with your vehicle either. function ejectProjectile() local vehicle = getPedOccupiedVehicle(source) if(vehicle)then local x, y, z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) end end I edited the wiki page for createProjectile for others that need it as well.
  21. It depends on how many times you call it. If you explain what you are using it for and how, then maybe we can suggest alternative solutions or optimization tips.
  22. Since it seems the delete button for my own resources doesn't work, I would like to have the following of my resources deleted: https://community.multitheftauto.com/index.php?p=resources&s=details&id=2454 https://community.multitheftauto.com/index.php?p=resources&s=details&id=2458 https://community.multitheftauto.com/index.php?p=resources&s=details&id=2568 https://community.multitheftauto.com/index.php?p=resources&s=details&id=2580 https://community.multitheftauto.com/index.php?p=resources&s=details&id=3421 https://community.multitheftauto.com/index.php?p=resources&s=details&id=3667 https://community.multitheftauto.com/index.php?p=resources&s=details&id=3668 Thanks. Edit: Updated links DONE
  23. arezu


    If you want to prevent element data "blood" to be changed from client-side (by players), then check if "client" global variable is set in onElementDataChange when it's triggered when "blood" is changed, that means it was changed from client-side. Read this: https://wiki.multitheftauto.com/wiki/Script_security
  24. Since novo hasn't updated his reply yet: local SCREEN_WIDTH, SCREEN_HEIGHT = guiGetScreenSize() if(isCursorShowing())then local curX, curY = getCursorPosition() curX, curY = curX * SCREEN_WIDTH, curY * SCREEN_HEIGHT -- circleCenterX and circleCenterY should be the center coordinate of your circle local distance = getDistanceBetweenPoints2D(curX, curY, circleCenterX, circleCenterY) -- circleRadius should be the distance from the center of your circle to the circle lines (border) if(distance <= circleRadius)then -- The cursor is inside the circle! end end
  • Create New...