Jump to content

IIYAMA

Moderators
  • Posts

    6,058
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. getElementMatrix(getCamera()) function getElementMatrix(element) local rx, ry, rz = getElementRotation(element, "ZXY") rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz) local matrix = {} matrix[1] = {} matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry) matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry) matrix[1][3] = -math.cos(rx)*math.sin(ry) matrix[1][4] = 1 matrix[2] = {} matrix[2][1] = -math.cos(rx)*math.sin(rz) matrix[2][2] = math.cos(rz)*math.cos(rx) matrix[2][3] = math.sin(rx) matrix[2][4] = 1 matrix[3] = {} matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx) matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx) matrix[3][3] = math.cos(rx)*math.cos(ry) matrix[3][4] = 1 matrix[4] = {} matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element) --image position. matrix[4][4] = 1 return matrix end https://wiki.multitheftauto.com/wiki/GetElementMatrix 》getPositionFromElementOffset《 And full control depending on the camera.
  2. Please use tabs in your code, I am not going to read this otherwise.
  3. I already gave you the methode to built that. You only have to edit it in terms of your needs...
  4. That happens when you do not fill in valid para. (which has to be a string which only contains numbers.) para = tonumber(para) -- `para` is already a local as it is a parameter. function (parameters...) if para and para > 10001 and para < 99 then -- works good! end And your bug is here: function spin(source, cmd, para) function spin(cmd, para) As it is clientside, only the localPlayer(YOU/You/you/and just you) can activate an addCommandHandler. Which means they decided to not pass the player on to the first parameter. Check wiki: https://wiki.multitheftauto.com/wiki/AddCommandHandler Serverside syntax: player playerSource, string commandName, [string arg1, string arg2, ...] Clientside syntax string commandName, [string arg1, string arg2, ...] Please do not use `source` in addCommandHandlers, it is for eventHandlers! You will only confuse yourself!
  5. For the spin delay, use tickCount. local nextSpinTime = 0 local spinDelay = 10000 -- 10 sec -- function () local timeNow = getTickCount() if timeNow > nextSpinTime then nextSpinTime = timeNow + spinDelay -- -- You can only execute this code every 10 sec. -- else -- Not so fast... end --end
  6. Then you do not need this: local para = math.min = (100) and math.max (10000) Only this: para = tonumber(para)
  7. local para = math.random(100, 10000)
  8. An object isn't a streamed able element. There is no way for server-side to know where this colshape is located in the world. (Especially when the client moves the object) It might be possible based on last set position but even so it is very inaccurate.
  9. local getDistanceBetweenPointAndSegment3D = function (pointX, pointY, pointZ, x1, y1, z1, x2, y2, z2) local A = pointX - x1 local B = pointY - y1 local C = pointZ - z1 -- local D = x2 - x1 local E = y2 - y1 local F = z2 - z1 -- local point = A * D + B * E + C * F local lenSquare = D * D + E * E + F * F local parameter = point / lenSquare local shortestX local shortestY local shortestZ if parameter < 0 then shortestX = x1 shortestY = y1 shortestZ = z1 elseif parameter > 1 then shortestX = x2 shortestY = y2 shortestZ = z2 else shortestX = x1 + parameter * D shortestY = y1 + parameter * E shortestZ = z1 + parameter * F end local distance = getDistanceBetweenPoints3D(pointX, pointY,pointZ, shortestX, shortestY,shortestZ) -- return distance end 3D version of this one: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D Useful for detecting if something is between 2 points.
  10. local peds = getElementsByType("ped", root, true) for i=1, #peds do local ped = peds[i] end getDistanceBetweenPoints3D() local x, y, z = getElementPosition(ped) local x2, y2, z2 = getElementPosition(localPlayer) killPed(ped) etc. https://wiki.multitheftauto.com/wiki/Scripting_Introduction
  11. On the brick of annihilation: bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] ) Put it to FALSE setElementData ( theElement, key, value, false )
  12. function GiveItemOnSpawn () setElementData(source, "M4A1 CCO", 1) outputChatBox("Test!", source, 255, 255, 255, true) end addEvent ("LEVEL1",true) addEventHandler ("LEVEL1",getRootElement(),GiveItemOnSpawn ) addEventHandler("onPlayerSpawn",getRootElement(), GiveItemOnSpawn) https://wiki.multitheftauto.com/wiki/OnPlayerSpawn Source The source of this event is the player that just spawned. https://wiki.multitheftauto.com/wiki/AddEventHandler addEventHandler This function will add an event handler. An event handler is a function that will be called when the event it's attached to is triggered. See event system for more information on how the event system works. Event handlers are functions that are called when a particular event happens. Each event specifies a specific set of variables that are passed to the event handler and can be read by your function. The following global variables are available for use in handler functions: source: the element that triggered the event
  13. Isn't your network getting :Oed up? You might want to do: /shownetstat while running this with multiple players. Which is also possible for causing the frame/cpu lagg.
  14. If not A-sync, then: function testFunction () return math.random(1000) % 2 == 0 end function start () for i=1, 1000 do local value = testFunction() if value then print(value) else break end end end start() If A-sync, use: https://www.lua.org/pil/9.1.html
  15. No other encrypted format is supported to be decrypt by then server except for luac. Which means that if a custom de-crypter isn't included (but still working) then it is compiled AND encrypt with luac. https://luac.multitheftauto.com/ Uploading/downloading = compiled Extra obfuscation = encryption
  16. IIYAMA

    stop driveby

    toggleControl(player, "vehicle_fire",false) * as it is server-side.
  17. IIYAMA

    stop driveby

    Use this event instead: https://wiki.multitheftauto.com/wiki/OnVehicleEnter Also: (not sure what this was about) toggleControl ( "vehicle_fire", false ) (true, "blockedvehicle")
  18. Debug your code manually. Easiest way for us to help you and to help yourself. I assume you have already seen this topic, but fortunately it is exactly what you need to do in this situation. Locate bugs... and annihilate them.
  19. IIYAMA

    stop driveby

    Only ADD, with the code you already used. This code will replace the original setPedDoingGangDriveby function clientside and use it serverside instead. It will fix your de-synchronization. Remember, you still need to use setPedDoingGangDriveby in your original code. clientside function setPedDoingGangDriveby (ped, state ) triggerServerEvent("setPedDoingGangDriveby", resourceRoot, ped, state ) end serverside addEvent("setPedDoingGangDriveby", true) addEventHandler("setPedDoingGangDriveby", resourceRoot, function (ped, state ) if isElement(ped) then setPedDoingGangDriveby(ped, state ) end end, false)
  20. I do not agree with that. Colour 1: 255, 100, 50 Colour 2: 255, 70, 50 <-
  21. Don't forget to give the resource admin rights.
  22. if r ~= r2 or g ~= g2 or b ~= b2 then -- not the same color end
  23. baseWidth * (progress / 100) 4 progress / 100 = 0.04 0.04 * 200 = 8 px
×
×
  • Create New...