Search the Community

Showing results for tags 'math'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • community.mtasa.com
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash
  • Private Bugtracker

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Gang


Location


Occupation


Interests

Found 6 results

  1. I want know what fail in my script because i'm new in LUA Scripting and if a "professional" resolve my problem maybe i can learn of that In this script i want make math problems and if the players resolve this gain $2k setTimer(function() x1 = math.random(500) x2 = math.random(600) outputChatBox("#1860F1[Math]#ffffff " .. x1 .. " + " .. x2 .. " = ", root, 255, 255, 255, true) end, 30000, 0) function mathSystem(text, source) outputChatBox(text, source, 255, 255, 255, true) if text == x1 + x2 then givePlayerMoney(source, 2000) end end addEventHandler("onPlayerChat", root, mathSystem)
  2. Hello! I am trying to do a boundary system based on coordinates, so no col shapes or anything. Unfortunately I'm not that good at math, but I tried doing it based on found results on the internet. My problem is that this whole script is not working how it should, check it for yourself, it has debug outputs and visible markers for corners and the center. Why does the width and height return a much bigger number than the calculatedX and calculatedY? Why does the calculatedX and calculatedY return always the same? Why does the width and height change values as I move around? I would be really grateful if somebody could help me, this is for a community project, so others would be too! Here's my current full code: Global: customBoundaries = { -- this boundary is between the big brown building(s) and the skatepark on the road in LS ["test"] = { point1 = {x = 1842.2908935547, y = -1412.469360351}, point2 = {x = 1856.8596191406, y = -1412.555664062}, point3 = {x = 1851.5925292969, y = -1436.5225830078}, point4 = {x = 1842.0438232422, y = -1424.5217285156}, }, } Client: local debugEnabled = true function sum(n) return ((n+1) * n) / 2 end function isElementWithinBoundary(element, boundary) if element and isElement(element) then local elementX, elementY, elementZ = getElementPosition(element) boundary = tostring(boundary) if boundary and type(boundary) == "string" then if customBoundaries and customBoundaries[boundary] then local corner1 = {customBoundaries[boundary].point1.x, customBoundaries[boundary].point1.y} local corner2 = {customBoundaries[boundary].point2.x, customBoundaries[boundary].point2.y} local corner3 = {customBoundaries[boundary].point3.x, customBoundaries[boundary].point3.y} local corner4 = {customBoundaries[boundary].point4.x, customBoundaries[boundary].point4.y} local centerX, centerY = (corner1[1] + corner2[1] + corner3[1] + corner4[1])/4, (corner1[2] + corner2[2] + corner3[2] + corner4[2])/4 local originX, originY = elementX - corner1[1], elementY - corner1[2] local width = math.sqrt((corner2[1] - originX)^2 + (corner2[2] - originY)^2) local height = math.sqrt((corner4[1] - originX)^2 + (corner4[2] - originY)^2) local calculatedX = originX * (corner2[1] - originX)/width + originY * (corner2[2] - originY)/height local calculatedY = originX * (corner4[1] - originX)/width + originY * (corner4[2] - originY)/height outputChatBox("X: " .. math.floor(calculatedX) .. " | width: " .. math.floor(width)) outputChatBox("Y: " .. math.floor(calculatedY) .. " | height: " .. math.floor(height)) if (0 <= calculatedX and calculatedX <= width) and (0 <= calculatedY and calculatedY <= height) then outputChatBox("XD") end if debugEnabled then for points, coordinates in pairs(customBoundaries[boundary]) do local cornerMarker = createMarker(coordinates.x, coordinates.y, getGroundPosition(coordinates.x, coordinates.y, elementZ), "cylinder", 2, 140, 245, 20, 150) local centerMarker = createMarker(centerX, centerY, getGroundPosition(centerX, centerY, elementZ)+2, "arrow", 1, 245, 140, 20, 150) end end end end end end isElementWithinBoundary(localPlayer, "test") Here's the calculation I was trying to copy and make it work based on: https://math.stackexchange.com/a/190257 I hope you understand my problem, thank you for your reply in advance!
  3. s2sk

    Sin and cos work?

    Hi. I want to create object in front of the coordinates for the angle. createObject(objectid, x + DISTANCE * -math.sin(angle + 90.0, degrees), y + DISTANCE * math.cos(angle + 90.0, degrees), z) It code WORK in SAMP. And not work in MTA. Since when are the sinuses and cosines different?
  4. Working on a First Person Shooter gamemode, and i found a bug. The event onClientPreRender causes some delay at attachElements. Can somebody reproduce attachElements maths for me?
  5. iMr.WiFi..!

    *[شرح] math

    بسم الله الرحمن الرحيم السلام عليكم ورحمة الله وبركاته .. كيفكم شباب ؟ ان شاء الله تكونو بأتم الصحة والعافية .. راح اشرحلكم اهم الاشياء في math نبدأ بسم الله أول شيء ال math.ceil ► يقرب العدد العشري الى اقرب عدد صحيح : تقولي كيف يعني ؟ يعني الارقام الي زي كذا 1.6 تتحول الى 2 مافهمت ؟ هذا يحول الرقم على حسب العدد العشري فأذا كان من 1 - 4 فيصير نفس الرقم الي هو عليه مثلاً : 1.3 local s = math.ceil(1.3) print ( s) -- 1 والارقام من 5 - 9 تتحول الى الرقم التالي مثلاً : 1.9 local s = math.ceil(1.9) print ( s) -- 2 math.floor ► يحذف الفاصلة العدد العشري تقولي كيف ؟ مثلاً : 2.9 local s = math.floor (2.9) print(s) -- 2 , -- ليس مثل ال -- math.ceil -- فهو للتقريب اما هذا للحذف math.random ► لجلب الرقم العشوائي من بين رقمين واضح جداً مثلاً : 200 - 400 راح يجيب رقم عشوائي local s = math.random (200,400) print ( s ) --398 math.min ► يجلب اصغر رقم من المجموعة او من رقمين مثلاً : local s = math.min (200,400,600,700) print ( s ) --200 math.max ► يجلب اكبر رقم من المجموعة او من رقمين مثلاً : local s = math.max (200,400,600,700) print ( s) --700 وكذا يكون وصلنا الى ختام الشرح ... وشكر خاص الى نصور .. واهداء للجميع من في المنتدى .. وسلام خير الختام ,,
  6. Artisz

    Vehicle cap position

    Hi! I want to create a fuel system. But I don't know how to calculate the cap's position. I know, that I can do it with getElementPosition, getElementRotation and Offset. But how?