Jump to content

srslyyyy

Scripting Moderators
  • Posts

    628
  • Joined

  • Days Won

    7

Everything posted by srslyyyy

  1. See post above. Sync settings are optional, but recommended when setting more than one data at once. Hit me up at our Discord in one of scripting help channels, in case of any questions (feel free to @ me there in case of custom data). I'm more active there than on forums.
  2. Try this, but carefully read full page. Might require some changes though. https://wiki.multitheftauto.com/wiki/CallServerFunction
  3. You can use https://wiki.multitheftauto.com/wiki/Animate In order to smoothly change volume.
  4. Napisz tutaj - https://forum.multitheftauto.com/forum/180-ban-appeals/ Tylko po angielsku.
  5. I haven't tested it. However i'd say that the most important thing during data syncing (client <-> server communication) is how often you do that. Whilst receivers being the less matter. Of course i might be totally wrong, so anyone is free to correct me up. At the time when i've learned about buffer & batch, there was no such thing as element data subscription. My server struggled to handle players, i looked for a way to optimise it. The only thing i did back then was implementing delay for continously called (player/vehicle damage) events (so called buffer), and batch for server-side data set. Once that was made, server could actually relief. Unlike to many others, it was PvP based (heavily customised), in a small game zone - it was a great experience to learn from.
  6. New year, new custom data B) On my GH there is new branch called dev. However the changes aren't backwards compatible, and some of the previous features are missing (temporarily, private data & getElementsByKey). I am also remaking documentation, which would be available only on GitHub repository wiki (as soon as i finish it). It might take a while since i'm still busy, code was released earlier in order to not collect dust. Once documentation is completed, dev branch will be merged into main. Some of changes: - Data handlers are now shared (can be used server-side). - Data handlers now pass parameters in table instead separately. - Data handlers now require only function to execute, other conditions are optional. - Syntax become way simpler, you don't need to type everything in order to use batch/buffer. - setCustomData allows you to pass extra data to data handler. - Code is way more readable. -- New syntax local dataKey = "dataKey" local dataValue = "dataValue" local syncSettings = { batchSync = "queue_player_spawn", -- name of batch queue someDataYouWantToPass = "testData" -- this will be forwarded to data handler } setCustomData(source, dataKey, dataValue, "synced", syncSettings) -- & Expanded data handlers function onClientUpdateData(...) local handlerData = ... local playerElement = handlerData.dataHolder local dataKey = handlerData.dataKey local dataValue = handlerData.dataValue iprint(playerElement, dataKey, dataValue, handlerData) end addDataHandler({ --allowedElements = {"player"}, -- allowed element types --allowedKeys = {"playerData"}, -- allowed keys --allowedEvents = {"someEvent"}, -- allowed events --localPlayerOnly = true, -- checks if element is equal to localPlayer initially handlerFunction = onClientUpdateData, -- function which will be executed; this is one and only requirement })
  7. function onClientPlayerDamage(pAttacker, pDamage, pBodypart) local localAttacker = pAttacker == localPlayer if not localAttacker then return false end -- do trigger event to server, preferrably do some check if victim ~= localPlayer; victim in this case is 'source' (without ') end addEventHandler("onClientPlayerDamage", root, onClientPlayerDamage) Note that i won't do everything for you, for next part please read:
  8. Perhaps freeroam/fr_client.lua (line 60) For the next time please use Find in files feature, which should be available in any decent code editor. It's CTRL + SHIFT + F for Sublime Text.
  9. Hit markers are probably based off attacker sync, use onClientPlayerDamage event (bind it to root), check if attacker equal to localPlayer, and then kill player if required (triggerServerEvent, and kill player server-side)
  10. Topic moved for better results.
  11. If you mean command then you could use optional argument for addCommandHandler. bool addCommandHandler ( string commandName, function handlerFunction [, bool restricted = false, bool caseSensitive = true ] )
  12. As long as it have collision it should be retrievable with https://wiki.multitheftauto.com/wiki/OnClientVehicleCollision With either hitElement or model parameter. However i think that's not a case for stinger - which you are trying to do i guess? Have a look at this resource which might help you: https://community.multitheftauto.com/index.php?p=resources&s=details&id=125
  13. Hi Your topic has been moved to Portuguese scripting section for better results.
  14. From what i can see the or operator is missing here. if teamName == "~STAFF" isObjectInACLGroup("user."..account, aclGetGroup("Admin")) then It should looks like this: if teamName == "~STAFF" or isObjectInACLGroup("user."..account, aclGetGroup("Admin")) then Also you need one more end which will close function scope.
  15. Not really. I am using this method on 1360x768.
  16. You would need to use cancelEvent() (to cancel default behaviour) in onClientVehicleDamage and write your own damage system via this event.
  17. srslyyyy

    Dead Body

    We aren't able to help without code.
  18. If you wanna keep script in this state, i will explain what could be done better. Start off by: Saving an function call in: local dimension = getElementDimension(localPlayer) Currently, you are returning it every frame, while you could save it in main scope and avoid calling it. By using onClientElementDimensionChange to store localPlayer's current dimension. local dimension = 0 function onClientElementDimensionChange(_, newDimension) dimension = newDimension end addEventHandler("onClientElementDimensionChange", localPlayer, onClientElementDimensionChange) Saving an another function call: local px, py, pz = getElementPosition(getElementByID("ped1")) I'm assuming that custom element is created on script init, otherwise you would need to update it at the time it creates. -- Main scope local myPed = getElementByID("ped1") -- Render scope local px, py, pz = getElementPosition(myPed) For next step, you could use custom implementation of getDistanceBetweenPoints3D which is faster from MTA (thanks @Sarrum) local function getDistance3D(pFirstX, pFirstY, pFirstZ, pSecondX, pSecondY, pSecondZ) pFirstX, pFirstY, pFirstZ = pFirstX - pSecondX, pFirstY - pSecondY, pFirstZ - pSecondZ return (pFirstX * pFirstX + pFirstY * pFirstY + pFirstZ * pFirstZ) ^ 0.5 end Another thing which most of scripters forget about is using tocolor in render, even if color doesn't change... tocolor(3, 169, 252, 255) -- notice () - a function call which returns same color every frame The solution will be to save it in local variable in main scope and later use it. -- Main scope local textColor = tocolor(3, 169, 252, 255) -- Render scope dxDrawText("Unknown", sx, sy, sx, sy, textColor, 2.02, "default-bold", "center", "center", false, false, false, false, false) If color isn't static you could use, for example events or timers which will be ideal way to update it. Other than that, you might use onClientElementStreamIn/onClientElementStreamOut to add/remove handler when ped appears or disappears from stream zone, as mentioned above by Dutchman101.
  19. There's a guide for this - See How to add "remember me" functionality. You shouldn't store password on client-side, even encoded.
  20. We are here to help, not to do job for you. https://wiki.multitheftauto.com/wiki/OnClientKey See examples to understand how this event works.
  21. Hi As first you need table with your vehicles which is returned by getElementsWithinColShape function. Then you would need to use loop and getVehicleType function in order to verify whether is a helicopter or a simple vehicle. This will allow you to count certain vehicles type, and process logic based on result. getVehicleType function: https://wiki.multitheftauto.com/wiki/GetVehicleType Understanding loops: https://forum.multitheftauto.com/topic/121619-lua-for-absolute-beginners/
  22. Have you tried using onClientKey event instead?
  23. Are you sure that db returns valid database connection? Tip in custom events: Use client variable instead of passing player to server - see https://wiki.multitheftauto.com/wiki/Script_security
  24. You haven't told us how those commands works. Not everyone is familiar with RP.
×
×
  • Create New...