Jump to content

IIYAMA

Moderators
  • Posts

    6,062
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. You can also use this selector if you want all columns from a specific table: jobs_sys.* But it could override some of the table values, if the names are the same from the 2+ tables.
  2. The alignment of the tables have to be defined. Try this: SELECT jobs_sys.uid, jobs_sys.x, jobs_sys.y, jobs_sys.z, jobs.money FROM jobs_sys LEFT JOIN jobs ON jobs_sys.uid = jobs.uid
  3. Do a left (table) join. https://www.w3schools.com/sql/sql_join_left.asp This is the default way data get aligned and merged from different tables.
  4. As long as you work with hashed passwords and not just encryption (decryption serverside), it should be fine. Working with real passwords (even when encrypted) is the reason why it shouldn't be done. When the 'remember me' is checked, the password field should be disabled and not be filled in. (or even the form shouldn't be showed)
  5. An example: local scale = interpolateBetween(0.7, 0, 0, 0, 0, 0, progress, "OutQuad") local width, height = dxGetTextWidth(getPlayerName(v),scaleF,settings.font,true), 2*scale local imageSize = 40 * scale local offset = 40 * scale local sx, sy = sx - (width / 2 + imageSize + offset), sy-height dxDrawImage(sx, sy, imageSize, imageSize, "files/typing.png",0,0,0,tocolor(255,181,64,255)) -- no imageSize since the image is drawn from left to right local sx, sy = sx + (width / 2 + offset), sy-height dxDrawImage(sx, sy, imageSize, imageSize, "files/typing.png",0,0,0,tocolor(255,181,64,255)) Anyway, I am wondering why you use the value '350'. The image was only 40 pixels and unscaled.
  6. Normally you would calculate the position like this: -- The width local textWidth = dxGetTextWidth(getPlayerName(v),scaleF,settings.font,true) local offset = scale * 50 -- Offset from the text -- Note: The text is centered!!! local positionX -- Before positionX = positionX - (textWidth / 2 + offset) -- After positionX = positionX + (textWidth / 2 + offset)
  7. What about dxGetTextWidth(getPlayerName(v), 1,settings.font,true) + 270 * scale -- or if the font is scaled: dxGetTextWidth(getPlayerName(v), scale,settings.font,true) + 270 * scale for the width.
  8. I am also using triggerClientEvent for the rotations. But not because of this issue, it is more for combining all AI instructions in to 1 packet and therefore reducing data. While rewriting your code, you might take that concept in consideration.
  9. Not sure what the best approach is. Kashtesov released a function that allows you to get the ground position serverside of the GTA san world. But it would be probably better for your user case: 1. Send triggerClientEvent 2. Draw lines at the place where you want to place the vehicle and check for any collision. https://wiki.multitheftauto.com/wiki/IsLineOfSightClear 3. Then confirm if there is any space: triggerServerEvent That way you also take custom objects in account. Or you can also combine those methods. Good luck!
  10. Try this local myFunctions = { ["FUNCTION_1"] = function (...) return exports.myresource:myFunction(...) end } Predefining export functions from another resource is not a good idea. Because when restarting that resource, all export functions will be reset.
  11. You should first check if the table exist. If not, fill in the blanks. local blankValue = "-" local c1, c2, c3, c4 = blankValue, blankValue, blankValue, blankValue local speedData = vehicleSpeeds[carID] if speedData then c1, c2, c3, c4 = unpack(speedData) end guiSetText(cLbl[1], "Stoke. speed: "..c1.." km/h.") guiSetText(cLbl[2], "Max. speed: "..c2.." km/h.") guiSetText(cLbl[3], "Acceleration 0-100 for "..c3.." s.") guiSetText(cLbl[4], "Drive unit: "..c4..".")
  12. nope, didn't think about that. ? But since you can draw on top of the chat, it is still worth a try. Or just draw it double, but bigger.
  13. Maybe you can draw something on top of it. *edited* https://wiki.multitheftauto.com/wiki/OnClientPlayerNetworkStatus
  14. Locked, requested by the creator.
  15. Server Client The key (server) "Level" is not the same as (client) "player:level". So there is your mismatch.
  16. I don't think that would be an issue. You can always optimise it later if it doesn't work as intended: Use multiple files instead. Or downloading only the ones of the peds in range. You can compile the file, (without obfuscation!), to speed up the downloading and loading time of the file. https://luac.multitheftauto.com/
  17. IIYAMA

    Inventory

    If you want to know that, then I recommend to take a closer look at the community resources (inspiration). https://community.multitheftauto.com/index.php?p=resources&s=list&name=&descr=inventory&category=
  18. The more entities it finds, the more performance it cost. (!!!especially if you loop over them) 1. A way to improve performance could be done by only get the streamed in players. getElementsByType("player", root, true) For example if you are drawing name-tags on players, you want to draw them only on players close by. By pre narrowing down the segment of players, this will reduce the amount of loops you are going to preform. for key, player in ipairs(getElementsByType("player", root, true)) do 2. And switching to a more basic loop could also help a lot with the performance. for i=1, #table do end 3. If the element type isn't a player, scoping the function to the resource which creates a specific element, could also help with performance. getElementsByType("vehicle", resourceRoot, true)
  19. You can combine the tables first with for example this method table.merge. (make sure to copy the code) And then loop through them. Keep in mind that the table.merge method is mutating the first table. (mutating = changing the content of the table, instead of returning a new one) table1 = {1,2,3} table2 = {4,5,6} ---- local newTable = {} table.merge(newTable, table1, table2) -- or with table names table.merge(newTable, {"table1"}, table1, {"table2"}, table2)
  20. I am not sure why you would invent a new format for your data. You can just use JSON, supported by PHP, JavaScript, Nodejs and even MTA. local vehicles = { {model = 411, slot = 1}, {model = 562, slot = 2}, {model = 562, slot = 3}, } local dataString = toJSON(vehicles) -- text -- https://wiki.multitheftauto.com/wiki/ToJSON -- https://wiki.multitheftauto.com/wiki/FromJSON Normally I wouldn't use JSON for my vehicles, since you want MySQL to take care of that by having a separated vehicle table. Which allows me to fire MySQL queries to find the data, instead of having Lua parsing the JSON data and blocking the MTA thread. But if you are not very familiar with MySQL, JSON is the second best option.
  21. The easing? -- The first 7 of this table are used: local strEasingTypes = { "Linear", "InQuad", "OutQuad", "InOutQuad", "OutInQuad", "InElastic", "OutElastic", "InOutElastic", "OutInElastic", "InBack", "OutBack", "InOutBack", "OutInBack", "InBounce", "OutBounce", "InOutBounce", "OutInBounce", "SineCurve", "CosineCurve" } local images = math.max(math.ceil(7 * ((getTickCount() % 14000) / 14000)), 1) local move = interpolateBetween(3, 0, 0, -06, 0, 0, ((getTickCount() - startTicking) / 5000), strEasingTypes[images])
  22. An example of a nice and simple way to add 'time driven' animations to your MTA creations.

     

  23. Not random, but it does it's thing. 14000 / 7 = 2000 ms each image. local images = math.max(math.ceil(7 * ((getTickCount() % 14000) / 14000)), 1) getTickCount() % 14000 This gives you a value between 0 and 13999 in milliseconds. This value counts up, resets and counts up again. (getTickCount() % 14000) / 14000) Value between 0 and 0.999999999. 7 * ((getTickCount() % 14000) / 14000) Value between 0 and 6.9999999 math.ceil(7 * ((getTickCount() % 14000) / 14000)) Value between 0 and 7. (very small chance that the value is 0) math.max(math.ceil(7 * ((getTickCount() % 14000) / 14000)), 1) Value between 1 and 7.
  24. You can make peds immortal like this: Server: -- top of the script local immortalPedsParent = createElement("immortalPedsParent", "immortalPedsParent-" .. getResourceName(getThisResource())) Client: addEventHandler("onClientPedDamage", getElementByID("immortalPedsParent-" .. getResourceName(getThisResource())), function () cancelEvent() end) Server: -- when creating an immortal ped local ped = createPed(skin,x,y,z,rotZ) setElementParent(ped, immortalPedsParent) But keep in mind that other scripts might interfere.
  25. That is correct, it is not the same. setElementData does not modify the parent<>child relationship. It only makes a reference between the 2. setElementParent does modify the parent<>child relationship: And therefore you can use call-propagation. Using the destroyElement function on the parent will also apply the function on it's children.
×
×
  • Create New...