Jump to content

arezu

Members
  • Posts

    446
  • Joined

  • Last visited

Everything posted by arezu

  1. We can see that Rank 1 - Rank 2 = 4 Rank 2 - Rank 3 = 3 Rank 3 - Rank 4 = 2 etc, so the difference is one less for each rank (not tested) local playersAtStartOfRound = 5 -- Highest rank should be rank 1, while lowest being = playersAtStartOfRound function getCashByRank(rank) local rankDiff = (playersAtStartOfRound - 1) - (rank - 1) -- n * (n + 1) / 2 = sum equation return playersAtStartOfRound + (rankDiff * (rankDiff + 1) / 2) end
  2. Should be root instead of source there.
  3. Maybe try this? https://wiki.multitheftauto.com/wiki/OnClientObjectBreak And if you have to, sync with server the broken state for an object (maybe by using getElementSyncer to prevent all players that see the object breaking to sync with server?) I haven't tried but, maybe isObjectBreakable returns false if the object is broken?
  4. I have maps with compiled scripts that use old compilers and im not the owner of the scripts. Now mta is about to make them unplayable, sounds right?
  5. If you read wiki carefully, you should see that getPedMoveState returns a string which move state the ped is in at the moment. So your code should be: if state == "sprint" or state == "walk" or state == "powerwalk" then instead of if state.sprint or state.walk or state.powerwalk then on line 12.
  6. What does stack overflow have to do with anti-cheat system?
  7. arezu

    Kills Shooter

    Harder to know if the driver has been killed by that shot ... Harder than what? onPlayerWasted doesn't set the killer as the creator of the projectile that you were killed by, so onClientVehicleDamage is the best way to do it. Just save the player that hit you last, and check if you died in an explosion within 5 seconds since then.
  8. arezu

    Kills Shooter

    Use this: https://wiki.multitheftauto.com/wiki/OnClientVehicleDamage (MTA 1.3.5 and forwards)
  9. It is "only rotating in the square", your problem is that your are using dxDrawImageSection as big as the render target, so when you rotate it you dont draw on the whole render target. To fix this, make the dxDrawImageSection draw a bigger section than the render target that you are drawing on (render target will take care of the slicing, so you dont have to care about that).
  10. There is a big problem with removing compatibility with other compilers, and that is that there are a lot of maps that has compiled scripts (for example maps that uses puma markers), and i've tested and the official compiler isn't much better than any other (except if you also use the encrypt option), it is often easily decompilable. If you really want to force people to change to it, then at least have a setting in mtaserver.conf to remove that, like: "Only change this if you want to take the risk of having your scripts stolen".
  11. I tried making a gta V style radar in mta, but when rotating the image in 3d, the quality becomes horrible. I had to change to a very high resolution map, but then the download is like 8mb.
  12. You can download and use a packet sniffer tool in just a few seconds, since http downloads are not encrypted. The best way to make sure that nobody steals your scripts is by making a custom downloader script that sends client scripts using triggerClientEvent since packets are then encrypted, and do loadstring on the code instead of saving onto a file.
  13. arezu

    car parts

    use https://wiki.multitheftauto.com/wiki/SetVehicleComponentVisible to make the door invisible, or use shaders.
  14. Compiling a lua script turns the code into instructions which can be read by the lua interpreter, and details about the interpreter exists online so what each instruction does is clear and that is why there are tools to decrypt from instructions to readable code. So compiling has nothing to do with being able to steal code or not. Encryption on the other hand is when you have text (code in this case) and you scramble the characters so that it is no longer readable, and the way the scrambling is done is by using a "password" and mta has not shared that password so the safest option to make sure nobody steals your code is to use mta encryption.
  15. Compiling does NOT prevent anyone from stealing your scripts in any way. It's very easy to decompile (even if you compile using mta's compiler). You should instead use mta's encryption option.
  16. Render targets are like textures (images) that you can draw on, think of it like layers in photoshop. You can draw on it using dx functions like dxDrawText/dxDrawImage, and anything that is draw outside the area of the render target will get "cut off". Simple example: -- true as third argument creates the render target with transparent background local renderTarget = dxCreateRenderTarget(640, 480, true) -- Using true as second argument will clear/erase the content of the render target, making it fully transparent dxSetRenderTarget(renderTarget, true) -- Position starts from top left of the render target! dxDrawText("test", 0, 0) -- Calling dxSetRenderTarget with no arguments will set the render target on which dx content will be drawn on to the screen, so we can draw the render target on the screen now dxSetRenderTarget() addEventHandler("onClientRender", root, function() -- You can treat the render target like a texture dxDrawImage(300, 300, 640, 480, renderTarget) end) Render targets can be used if you want to increase performance by only a lot of drawing dx stuff once, and display it many times, or if you want to "draw" using lua to a texture, or if you want to rotate text in 3d together with shader. Render targets can also be used if you want to scale an image and still have good quality, as using render targets somehow scale better visually. Also you make sure to play with dxSetBlendMode to get best visual result, otherwise it can look weird.
  17. If you still need to make it only set velocity to 1 in the direction, then divide the components of the vector with the length (normalization) local vehicle = getPedOccupiedVehicle(localPlayer) local mx, my, mz, mpx, mpy, mpz = getCameraMatrix() local dist = getDistanceBetweenPoints3D(mx, my, mz, mpx, mpy, mpz) local vector = { (mx - mpx) / dist, (my - mpy) / dist, (mz - mpz) / dist } setElementVelocity(vehicle, -vector[1], -vector[2], -vector[3]) It may give better result if you use the vehicle position and camera position instead of camera position and camera target position.
  18. This same question has been asked at least 70 times on this forum already. Please search on the forum first with the search button.
  19. Using setmetatable(env, {__index = _G}) means if a variable/function doesn't exist in the environment, then search in the global environment (of the resource), which means if you are trying to disallow triggerServerEvent, then a map can simply have script that does this: triggerServerEvent = nil and the map will have access to the real triggerServerEvent function. To fix this problem, you should copy variables instead: function copyTable(tbl) local t = {} for k, v in pairs(tbl) do if(type(v) ~= "table")then t[k] = v else t[k] = copyTable(v) end end return t end -- Define env as an empty table before this. -- Make sure to use pairs, not ipairs. for k, v in pairs(_G) do if(v ~= _G)then if(type(v) ~= "table")then env[k] = v else env[k] = copyTable(v) end end end env._G = env The only problem left is that source, resourceRoot, localPlayer, resource etc are global variables and are only set in the default environment (resource global environment), so you need to do to so that if you are trying to get/set the value of any of those variables, then you should access the global environment (of the resource) instead, but at the same time, your environment should not have access to that environment. This can be done by taking advantage of 'variable capturing', which means refrences to variables are copied into functions that are defined in a scope (for example if a function is defined in another function, then that function will have access to variables that the function that created it, has access to too), for example: function f(v) local d = 23 local f2 = function() outputChatBox(d) -- will output 23 outputChatBox(v) -- will output the value of 'v' from the function v end end We can take advantage of this method to give metamethod __index and __newindex of the new environment access to global environment without giving the actual environment access to it. An example of how the metamethod looks like (this should be called in the global environment before copying variables/functions): setmetatable(env, { __index = function(t, key) local r = rawget(_G, "_GET_GLOBAL")(key) if(r)then return r end return rawget(t, key) end, __newindex = function(t, key, value) local r = rawget(_G, "_SET_GLOBAL")(key, value) if(not r)then rawset(t, key, value) end end }) _GET_GLOBAL and _SET_GLOBAL are functions defined in the global environment, and what they simply do is check if the key you called it with is "source", "resource", "resourceRoot" etc, then return the value, or set the value and return true; otherwise get the value from the new environment or set it in the new environment. The reason you need __newindex as well is because __index is only called when trying to access a variable that doesn't exist (we dont want source, resourceRoot etc to exist in the new environment), and if a script in a map for example has: source = aValue and you dont have __newindex set, then source will be saved as a new variable in the environment, and __index will not be called when trying to access source, and source will always have the same value until you manually override it again. The order you should do everything in is: Create a empty table (env in this case). Set the metamethods for __index and __newindex for it, to get/set values from global environment instead. Loop the global environment and copy variables. Set the environments _G table to itself (env._G = env in this case). (Set the environments debug table to nil, in this case env.debug = nil, to prevent a user from doing stuff that they should not able to do. Do the same for loadstring and load). Load your code with loadstring and use setfenv on the returned function Use pcall to call the function returned from loadstring.
  20. If you are drawing by using a texture to draw on a render target like i replied in your other thread, then you can do so you save the coordinates you are drawing at, and only save each time the new drawing position is far from previous drawing position and is at a different angle than previous frames compared to previous saved coordinates. Doing this will remove redundant data and using only the minimum possible data. You can then sync with server each second or two and send the data that has accumulated since last syncing. Then when you send the data to clients, you interpolate between the coordinates to make it smoother.
  21. You can change to use a render target that you make transparent, and then when you want to draw a circle, draw an image with a circle in it with smoothed edges/glow (make the edges go from no transparency to full transparency in photoshop or whatever) on the render target. You can then blend using lerp in shader. Drawing to render target using an image is much faster than using pixel functions.
  22. It should be safe if you have a table of common d3d9 checksums, like default one, ultrathing and enb(?), and compare those to getPlayerACInfo in onPlayerConect to check if the player is using a dll injection. If he is using a non-common d3d9 file, then it could be a dll injection, and you can then use cancelEvent to prevent the user from connecting to the server. Or should I said, you should have this kind of anti-cheating system no matter what, since otherwise a player can steal maps, call exported functions, setElementData (which is especially bad for gamemodes like race, that depend on element data very much), and triggerServerEvent's.
  23. They cant do that, because mta will detect that and redownload the resource files then.
  24. local rectWidth1 = 355 local rectWidth2 = rectWidth1 * 0.5 -- 0.5 is 50%, 0.0 is 0% and 1.0 is 100%
×
×
  • Create New...