Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. Is the gate used in an interior? If yes, then you also have to change that: https://wiki.multitheftauto.com/wiki/SetElementInterior
  2. Nice work! I updated the code in the tutorial.
  3. That you do not have a super computer that can read > convert > play(at location) a sound within 1ms. Can't you do it in an x amount of time in the future? Atleast convert it to a wav format, else it has to re-uncompress the file.
  4. @xuaNN The bar element: local bar = DGS:dgsCreateImage(0.7 * fScreenX, 0 * fScreenY, 0.24 * fScreenX, 1 * fScreenY,_,false,_,tocolor(0,0,0,225)) Is not available here: addEventHandler("onDgsMouseClick",bar,buttonClick) Either: - The addEventHandler is placed higher in the code, than where the bar is created. - The addEventHandler is placed in another file, than where the bar is created. - Or the bar has not been created at all.
  5. @xuaNN Where did you define the `bar` variable? (created the button)
  6. Obvious, at the place where you want to use a timer. It is your code, you know that best.
  7. @Quenix There is no timer function in this code... In case you use a timer function and you want to pass arguments: function remindMe (arg1, arg2) iprint(arg1, arg2) end ------------------- local arg1 = "argument1" local arg2 = "argument2" setTimer(remindMe, 1000, 1, arg1, arg2)
  8. IIYAMA

    destroyElement

    ... what do you do? ?
  9. then you should start with an array structured table and create and object structured table afterwards. Start with an array structured table. local tableTestArray = { {key = "Room1"}, {key = "Room2"}, {key = "Room3"}, {key = "Room4"} } local tableTestObject = {} for i=1, #tableTestArray do tableTestObject[tableTestArray[i].key] = tableTestArray[i] end This allows you to access the data with multiple ways. access to ipairs (loop in order) --> tableTestArray access to # (item count) --> tableTestArray access with "Room1" --> tableTestObject NOTE: the sub tables are LINKED between: tableTestArray <> tableTestObject They are the same.
  10. ipairs loop only works an array structure tables. indexes: 1,2,3,4 The # only works for array structured tables. But yours is an object/custom structured table. indexes: 'Room1', 'Room2', 'Room3', 'Room4' And for that you need the pairs loop function getTableCount(thisTable) local count = 0 for k, v in pairs(thisTable) do count = count + 1 end return count end local count = getTableCount(tableTest) @Overkillz
  11. IIYAMA

    destroyElement

    then it is: if timehour == 6 then or not executed at all.
  12. IIYAMA

    destroyElement

    if timehour == 6 then if wind and isElement(wind) then destroyElement(wind) wind = nil outputChatBox ("Object destroyed") end elseif not wind or not isElement(wind) then wind = createObject(1337,2321.5, -1659.5,13.5) outputChatBox ("Object created") end @Zcraks
  13. If you use Globals, you will be overwriting the variables. for i = 1, 40 do local Gate3 = createObject ( 5020, -2660.8000488281, 1424.8000488281, 921.20001220703, 0, 0, 270 ) setElementDimension( Gate3, i ) local x,y,z = getElementPosition (Gate3) local Zona = createColCircle ( x,y, 3, 3 ) local function Portao7(thePlayer) for _, group in ipairs ({"Console"}) do if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then moveObject (Gate3, 3000, -2660.8000488281, 1424.8000488281, 923 ) end end end addEventHandler ( "onColShapeHit", Zona, Portao7 ) -- not> Portao5 local function Portao8(thePlayer) for _, group in ipairs ({"Console"}) do if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then moveObject (Gate3, 3000, -2660.8000488281, 1424.8000488281, 921.20001220703 ) end end end addEventHandler ( "onColShapeLeave", Zona, Portao8 ) -- not> Portao6 end
  14. As far as I know these settings are only used for sync element orientations. p.s you might also reduce data like this: function onClientPlayerDamage(attacker, weapon, bodypart, loss) local newHealth = getElementHealth(localPlayer) if newHealth > 0 then -- is not dead local oldHealth = newHealth + loss setElementHealth(localPlayer, oldHealth) -- reset else -- is dead cancelEvent() triggerLatentServerEvent("onPlayerDamage_", localPlayer, attacker, weapon, bodypart, loss) end end addEventHandler("onClientPlayerDamage", localPlayer, onClientPlayerDamage) p.s this might also be needed serverside. addEvent("onPlayerDamage", false) --remote disabled
  15. function onClientPlayerDamage(...) cancelEvent() triggerLatentServerEvent("onPlayerDamage_", localPlayer, ...) end addEventHandler("onClientPlayerDamage", getLocalPlayer(), onClientPlayerDamage) addEvent("onPlayerDamage_", true)-- fake event onPlayerDamage_ = security addEventHandler("onPlayerDamage_", root, function (...) triggerEvent("onPlayerDamage", client, ...) end) It can be faked, but you might need to figure out a way to reduction data. @majqq For example buffer up till 100 ms, before sending the message This will reduce a lot in case of fire/minigun/Spraycan/Fire Extinguisher damage: (NOTE: surprisingly the minigun also fires a bullet every frame) How much reduction do you want for that scenario? Do the maths! local sendingDelay = 100 -- ms local fps = 60 local timeSlice = 1000 / fps local dataReduction = sendingDelay / timeSlice print("~" .. (dataReduction - 1 ) .. " x times LESS per " .. sendingDelay .. "ms") https://www.lua.org/cgi-bin/demo
  16. because the MTA developers decided to consider cancelled events as 'it never happened`. onPayerDamage is a delayed/streamed version of onClientPlayerDamage
  17. fileRead https://wiki.multitheftauto.com/wiki/FileRead fileWrite https://wiki.multitheftauto.com/wiki/FileWrite Examples are already included on the WIKI. Enjoy!
  18. @MatheusCalixto The files are mostlikely protected. I recommend to delete and recreate them.
  19. Hmm indeed strange. And what if you re-parse it? function reParseNumber(number) return tonumber(tostring(number)) end
  20. He is talking about the solution for this situation: The server sending a triggerClientEvent. But unfortunately the client is still downloading/loading the scripts. So the message isn't delivered and will give you that error that you are having. onClientResourceStart can be used as indication that the client is loaded and ready to receive triggerClientEvent's. (For that specific resource atleast)
  21. @majqq Did you checked if those are actual numbers? (and not strings. In that case you wouldn't see the difference in the outputChatBox.) Also you do not need to use Vector3 in the second example, it can be filled in without. That will save you another function execution.
  22. Ah that is a petty I do not think there are much options left. Except if the player is `standing still` and `doing nothing`. local x, y, z = getElementPosition(localPlayer) setElementPosition(localPlayer, x, y, z, true) -- warp argument is by default `true` but just so you know that it is doing something ... Optional Arguments warp: teleports players, resetting any animations they were doing. Setting this to false preserves the current animation. https://wiki.multitheftauto.com/wiki/SetElementPosition
  23. You could try to cancel the damage + set the health manually. (Only if the remaining health is not 0) https://wiki.multitheftauto.com/wiki/OnClientPlayerDamage Not sure if it will work, but good luck.
  24. I am going to be honest here. It is possible, but not for a beginner. As it is something that has to be either faked or recreated, that is complex stuff.
  25. While creating elements: -- on top of the script local boneAttachContainer = createElement("boneAttachContainer", "boneAttachContainer") -- while making objects local object = createObject(...) setElementParent(object, boneAttachContainer) -- on top of the script local validBoneAttachModels = {[2763] = true, [1820] = true, [2708] = true, [15036] = true} -- while pressing key local boneAttachContainer = getElementByID("boneAttachContainer") if boneAttachContainer then local objects = getElementsByType("object", boneAttachContainer, true) for i = 1, #objects do local object = objects[i] local model = getElementModel(object) if validBoneAttachModels[model] then setElementAlpha(object, alpha) end end end You might want to consider using a dirty timer or find an event that will occur at that time.
×
×
  • Create New...