Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/02/22 in Posts

  1. Hi. Could you give us a run down on what sort of work this would entail. The current state of your server, where you plan to take it?
    1 point
  2. DataTable = { } function setData ( Player ) if ( DataTable [ Player ] ) then return false end DataTable [ Player ] = true end function getData ( Player ) return DataTable [ Player ] or false end function resetData ( ) DataTable = { } end setData -> لوضع داتا على اللاعب getData -> لجلب الداتا عن اللاعب resetData -> عندما تنشئ سؤال جديد
    1 point
  3. try using string.len and string.gsub local text = "" -- empty text text = string.gsub(text, "%s+", "") -- delete all spaces if(string.len(text) > 0) then --if text is greater than 0 characters -- codes here end
    1 point
  4. addEventHandler + group elements I noticed that some people like to add 10000000000000000 addEventHandlers for each element, while you probably only need 1 addEventHandler. Using ONE addEventHandler on a group of elements? Answer: local group = createElement("groupMyCutePeds") -- Create a custom element and save it in to the variable <group>. -- Create 3 peds. local ped1 = createPed(120, 5540.6654, 1020.55122, 1240.545) local ped2 = createPed(120, 5541.6654, 1021.55122, 1240.545) local ped3 = createPed(120, 5542.6654, 1022.55122, 1240.545) -- Set the parent of the 3 peds. setElementParent(ped1, group) setElementParent(ped2, group) setElementParent(ped3, group) -- Add an addEventHandler and use the <group> as <attachedTo> element. addEventHandler("onPedWasted", group, -- "onPedWasted" = serverside. "onClientPedWasted" = clientside. function () outputChatBox("One of my cute peds just died. ;'( No exceptions!") end) Code is untested, but the method is tested. Syntax for functions in example createElement syntax element createElement ( string elementType, [ string elementID = nil ] ) setElementParent syntax bool setElementParent ( element theElement, element parent ) addEventHandler syntax bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [ bool getPropagated = true, string priority = "normal" ] ) DO NOT disable getPropagated getPropagated: A boolean representing whether the handler will be triggered if the event was propagated down or up the element tree (starting from the source), and not triggered directly on attachedTo (that is, handlers attached with this argument set to false will only be triggered if source == this). If you disable this, children of the <group> element are not included. Make use of the element tree Element tree For applying addEventHandlers to elements created by the resource: Use: resourceRoot / getResourceRootElement For applying addEventHandlers to elements created by scripts of the resource: Use: getResourceDynamicElementRoot For applying addEventHandlers to elements created by maps of the resource: Use: getResourceMapRootElement I hope your code will be without... print(10^10^10^10) -- Print here: https://www.lua.org/cgi-bin/demo ...addEventHandlers in the future.
    1 point
  5. I updated this function in June 2017 If today the question is relevant, then here is a stable solution local identityMatrix = { [1] = {1, 0, 0}, [2] = {0, 1, 0}, [3] = {0, 0, 1} } function QuaternionTo3x3(x,y,z,w) local matrix3x3 = {[1] = {}, [2] = {}, [3] = {}} local symetricalMatrix = { [1] = {(-(y*y)-(z*z)), x*y, x*z}, [2] = {x*y, (-(x*x)-(z*z)), y*z}, [3] = {x*z, y*z, (-(x*x)-(y*y))} } local antiSymetricalMatrix = { [1] = {0, -z, y}, [2] = {z, 0, -x}, [3] = {-y, x, 0} } for i = 1, 3 do for j = 1, 3 do matrix3x3[i][j] = identityMatrix[i][j]+(2*symetricalMatrix[i][j])+(2*w*antiSymetricalMatrix[i][j]) end end return matrix3x3 end function getEulerAnglesFromMatrix(x1,y1,z1,x2,y2,z2,x3,y3,z3) local nz1,nz2,nz3 nz3 = math.sqrt(x2*x2+y2*y2) nz1 = -x2*z2/nz3 nz2 = -y2*z2/nz3 local vx = nz1*x1+nz2*y1+nz3*z1 local vz = nz1*x3+nz2*y3+nz3*z3 return math.deg(math.asin(z2)),-math.deg(math.atan2(vx,vz)),-math.deg(math.atan2(x2,y2)) end function fromQuaternion(x,y,z,w) local matrix = QuaternionTo3x3(x,y,z,w) local ox,oy,oz = getEulerAnglesFromMatrix( matrix[1][1], matrix[1][2], matrix[1][3], matrix[2][1], matrix[2][2], matrix[2][3], matrix[3][1], matrix[3][2], matrix[3][3] ) return ox,oy,oz end local rotx, roty, rotx, rotw = 0, 0, 0.190809, 0.9816272 -- you can read the Quaternion from IPL file createObject(1337, 5540.6654, 1020.55122, 1240.545, fromQuaternion(rotx, roty, rotx, rotw))
    1 point
×
×
  • Create New...