Jump to content

IIYAMA

Moderators
  • Posts

    6,089
  • Joined

  • Last visited

  • Days Won

    216

Everything posted by IIYAMA

  1. IIYAMA

    playsound

    triggerClientEvent ( source, "sess", root ) Syntax: bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) https://wiki.multitheftauto.com/wiki/TriggerClientEvent Required Arguments sourceElement: The element that is the source of the event. name: The name of the event to trigger client side. You should register this event with addEvent and add at least one event handler using addEventHandler Optional Arguments NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments. sendTo: The event will be sent to all players that are children of the specified element. By default this is the root element, and hence the event is sent to all players. If you specify a single player it will just be sent to that player. This argument can also be a table of player elements. arguments...: A list of arguments to trigger with the event. You can pass any lua data type (except functions). You can also pass elements. You might want to reply here as well...
  2. IIYAMA

    little help

    function player_Wasted ( ammo, attacker, weapon, bodypart ) if isElementWithinColShape(source, lvcol) then outputChatBox("öldün") end end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) https://wiki.multitheftauto.com/wiki/IsElementWithinColShape
  3. Tables are indeed a good way to deal with this. Included optimise this code. (speed/performance) But first things first.
  4. If tables are too much for you, then you can also consider the function block as part of functional programming. The only thing about it, is that memory leaks can occur more often. Which happens for example if you do not remove an addEventHandler from a local function. This code will create the functions `markersize` and `colhit` for every new projectile. And when ALL eventHandlers are removed, so will be the functions. (Warning: if one of the handlers remains to exist, so will remain the whole block.) addEventHandler("onClientProjectileCreation", root, function(creator) if getProjectileType(source) == 17 then setTimer(markerfunc, 2000, 1, source) end end) function markerfunc(elem) local ms = 0 local mst = 0.5 local x,y,z = getElementPosition(elem) setElementPosition(elem, 0, 0, 0) local m = createMarker(x, y, z, "cylinder", 1, 0, 255, 0, 255) local col = createColSphere(x, y, z, mst * 12) local function markersize() ms = ms + mst setMarkerSize(m, ms) local mx,my,mz = getElementPosition(m) setElementPosition(m, mx, my, mz-mst / 1.3) end local function colhit(thePlayer, matchingDimension) if getElementType ( thePlayer ) == "player" then outputChatBox(tostring(getPlayerName(thePlayer))) end end addEventHandler("onClientRender", root, markersize) addEventHandler("onClientColShapeHit", col, colhit) setTimer(function() removeEventHandler("onClientColShapeHit", col, colhit) removeEventHandler("onClientRender", root, markersize) destroyElement(m) destroyElement(col) end, 500, 1) end
  5. Afaik mysql does have such things as events: https://dev.mysql.com/doc/refman/5.7/en/events-privileges.html (never used it thought) I am not sure what the possibilities with this are, but it can do a part of the administration for you.
  6. local rotationDirection = "right" -- function scope ... if rotationDirection == "right" then rotationDirection = "left" setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) + 0.08)) else rotationDirection = "right" setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) - 0.08)) end -- end
  7. 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.
  8. Please use tabs in your code, I am not going to read this otherwise.
  9. I already gave you the methode to built that. You only have to edit it in terms of your needs...
  10. 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!
  11. 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
  12. Then you do not need this: local para = math.min = (100) and math.max (10000) Only this: para = tonumber(para)
  13. local para = math.random(100, 10000)
  14. 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.
  15. 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.
  16. 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
  17. 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 )
  18. 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
  19. 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.
  20. 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
  21. 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
  22. IIYAMA

    stop driveby

    toggleControl(player, "vehicle_fire",false) * as it is server-side.
  23. 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")
  24. 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.
×
×
  • Create New...