Jump to content

srslyyyy

Scripting Moderators
  • Posts

    635
  • Joined

  • Days Won

    8

Everything posted by srslyyyy

  1. I've received different results when testing them one at once. In 2019 i had completely different CPU (and bad PC with Windows 7 - now i'm using Windows 10), it was AMD Athlon II x2 2.70 GHz. bone_attach_original stands for main version which uses pairs, and coroutines. bone_attach_2k19 stands for "optimized" version which i was pretty sure, that it works well (seems i was wrong), uses for i = 1, #tableSize do loop, localized math methods, all tables, all resource functions. bone_attach_2k20 stands for version which i've rewrited today. Uses aswell for i = 1, #tableSize do loop, localized math methods, all tables, all resource functions, mostly called functions (setElementPosition/getElementPosition; setElementRotation/getElementRotation), variables inside of functions scope are declared in main one (they aren't recreating every frame, so script just overwrite values - excluding one variable; i've exceeded upvalues limit - they aren't so fast as in function scope, but it's still better solution to overwrite rather than create new ones - correct me if i'm wrong), however - between 2020 version and original; 2019 there's small (?) difference in logic, in newest version i've implemented fix for CJ skin, which uses math.round method (solution from haron4igg - https://forum.multitheftauto.com/topic/57349-help-attachelementtobone/?tab=comments#comment-661478), besides that, data is stored in sub-tables (+ 1 indexing count) - by data i mean attachments, bone 0/T/F offsets. However, i've greatly reduced count of accessing render data. Latest difference between 2020 version and others is that, it doesn't use server-side at all (creates objects via client-side and attach them directly there) Used to be: local element = bone_attach[i][1] local ped = bone_attach[i][2] local attached_x = bone_attach[i][4] local attached_y = bone_attach[i][5] local attached_z = bone_attach[i][6] local attached_rx = bone_attach[i][7] local attached_ry = bone_attach[i][8] local attached_rz = bone_attach[i][9] Now it's: CLocalRenderData = CLocalRenderAttachments[i] local CLocalRenderElement = CLocalRenderData[1] CLocalRenderPed = CLocalRenderData[2] CLocalRenderBone = CLocalRenderData[3] CLocalRenderAttachX = CLocalRenderData[4] CLocalRenderAttachY = CLocalRenderData[5] CLocalRenderAttachZ = CLocalRenderData[6] CLocalRenderAttachRX = CLocalRenderData[7] CLocalRenderAttachRY = CLocalRenderData[8] CLocalRenderAttachRZ = CLocalRenderData[9] IPB results: 50 objects: 100 objects: Maybe i made something wrong, in 2019, honestly, i don't know
  2. Hi. So after all i've decided to play with bone attach once again, had to fix CJ skin bug, and decided to squeeze out even more performance CPU: i5-9400F 1 attached object: 100 attached objects:
  3. https://wiki.multitheftauto.com/wiki/GuiSetVisible
  4. setWeaponProperty on client-side is only for custom weapons. Maybe it's good to create feature request on GitHub (and if it's possible, someone could do that) - i might do that. You can have 3 different levels of accuracy etc. per weapon. (poor, std, pro) - setPedStat for changing those levels.
  5. Make sure your script is set to client in meta.xml
  6. https://wiki.multitheftauto.com/wiki/SetPedTargetingMarkerEnabled
  7. This should help. I think, there's no other way rather than weapon levels.
  8. attachElements expect object. Create object with model 1097, save it to variable, and then pass it as 1st argument.
  9. local colshape = createColSphere(tonumber(x), tonumber(y), tonumber(z), tonumber(radius)) If you create colshape, and not delete it it will stay on map until resource restart, wanna see? After using your command follow steps below. Execute this command in admin panel (Resources > Execute command) setDevelopmentMode(true) for client & server. And then, simply write: /showcol in chat. I've added additional element data check, so if vehicle doesn't have such element data, it wouldn't compare number with boolean. Besides, my version of code is somewhat faster, because of integer loop (you can't really see difference, but it's better to use it anyways) Source: https://springrts.com/wiki/Lua_Performance Why after all people use ipairs without sensible reason? I don't know, maybe because some of them lazy, or they don't even know that you can use int loop.
  10. function lockCar(player, cmd) local radius = 3 local x, y, z = getElementPosition(player) local vehiclesAround = getElementsWithinRange(x, y, z, radius, "vehicle") local vehicleElement = false if #vehiclesAround == 0 then outputChatBox("no vehicles around", player, 220, 220, 0) return end for i = 1, #vehiclesAround do vehicleElement = vehiclesAround[i] if getElementData(vehicleElement, "uid") and getElementData(vehicleElement, "uid") == 0 then setVehicleLocked(vehicleElement, true) outputChatBox("lock", player, 220, 220, 0) break end end end addCommandHandler("wv", lockCar) Here you go, i also changed loop to faster, and we don't need colshape to get vehicles around. (+problem is that, that you create colshape and never delete it)
  11. setPlayerHudComponentVisible("area_name", false) setPlayerHudComponentVisible("vehicle_name", false)
  12. Those are private files, as Tut said, someone didn't wish that his files would be used on other servers.
  13. That's correct, it's either true or false. p isn't defined in your code. Test this piece of example code, you should understand after typing /testcmd (server-side code) function myCommand(player, cmd) outputChatBox("player: "..inspect(player).." cmd: "..inspect(cmd)) end addCommandHandler("testcmd", myCommand)
  14. Due of error codes, it's easy. Function expects element (mostly stored in variable or as parameter), your p is nil. Similar case, but this time you got boolean (false), let's check what returns getPlayerAccount: Your variable p was nil, and therefore function returned false on it's failure.
  15. Impact at server will only exists during sync events, if you gonna create healthy triggers everything should be alright.
  16. Can you share your solution so others might find it and do not create other topics for that?
  17. Server-side functions doesn't exist on client-side.
  18. If you gonna use variables inside render scope, it is better to reuse them (declare it in main scope), so they are not recreating every frame. local x, y, z = 0, 0, 0 addEventHandler("onClientPreRender", root, function() for i = 1, table.size(spawnedItem_ID), 1 do x, y, z = getElementPosition(localPlayer) if(getDistanceBetweenPoints3D(x, y, z, spawnedItem_X[i], spawnedItem_Y[i], spawnedItem_Z[i]) <= 5) then triggerEvent("onPlayerEnterItemArea", root, spawnedItem_ELEMENTO[i]) -- Draw the image and the text end end end) However colshape solution it's better. (if you not gonna reach thousands of them for client/server)
  19. Thanks for suggestion, but i already tested isElementOnScreen, it would cause object stay for a moment when not looking on it. However this was so far ago, so i might did something incorrect. Whatsoever performance in render can be improved by declaring variables out of rendering scope (so basically in main one), and reusing them. I will rewrite bone attach once again to apply some tricks what i've learnt since this topic (to gain even more than 50% performance boost), and let you know about results in this topic
  20. Maybe because of: Serverside commands can only be executed by the server. The same applies to the client side This is how you kill your server network. local players = getElementsWithinRange(x, y, z, 50, "player") for i,player in ipairs(players) do triggerClientEvent(player, "chat:box", root, thePlayer, set, first) end You trigger this event separately per player. Very bad solution. You know you can use table of players instead as first argument? Which is players in your case. Also using ipairs is bad, since this is worst type of loop. I'm kinda repeating myself - https://forum.multitheftauto.com/topic/121808-doubts-if-you-can-improve-performance/
  21. Hey, as topic title says, i'm offering scripting services in MTA:SA. My adventure with Lua started a little bit later than year ago, during that time i've learnt quite more than I wanted, so starting from today i'm ready to complete some - or even all of your tasks. In case, if you have problems with communicating in English, i also know Russian - so feel free to speak with me po-russki My possibilites with scripts: ▪ Creating new, on your request. ▪ Editing already existing ones. ▪ Fixing bugs/issues. ▪ Optimising. I provide: ▪ Error/warning free code. ▪ Element data free code (unless you really need that, i love to work with triggers & tables instead) ▪ Support after receiving services, in case of any problems. If you are interested, contact with me: via Discord: SERIOUSLY?#4654 (Also describe your request as well as you can, so I will know if i can handle it)
  22. It is because you cannot attach your handler to commands like: check ; list ; test Check wiki for more info - https://wiki.multitheftauto.com/wiki/AddCommandHandler Good luck on your adventure with Lua in MTA:SA :)
  23. Yes, but those do not need to be official functions. It could be operations on variables/tables, and other custom functions.
  24. srslyyyy

    Suggestion

    Probably it will be 1.6, not 1.5.8. If you wanna ask devs - ask at #development channel at MTA:SA discord.
×
×
  • Create New...