Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. First start with debug the variable: ? iprint("vehHealth: ", vehHealth) If this is oke, then show me how you create your table.
  2. I do not see the variable >Map< in this code. You sure this is the right code that contains this error?
  3. Afaik the loss has already been subtract from the vehicle health. This should be enough: (There is no need for convert it to integer, since a float number is more exact) local vehHealth = getElementHealth(source)
  4. Most likely it is because this file loads later than the file that is already using WorldRadar. In short: You can't use something which hasn't been loaded yet. To solve that problem, you can execute code after ALL the code has been loaded using the event: 'onClientResourceStart'. It is clientside right? (for serverside use onResourceStart) function Map.start() MiniMap.start() WorldRadar.start() end addEventHandler("onClientResourceStart", resourceRoot, function () Map.start() end)
  5. WorldRadar Doesn't contain a value. (which should contain a table) You can check if WorldRadar does have a positive value, by writing it like this: if WorldRadar then -- code that uses WorldRadar end This will stop the errors/warnings, but doesn't guarantee that the script will operate as pleased. So make sure that: WorldRadar does contain a valid value.
  6. You want to know where you made a mistake? Then this tutorial is perfect for you:
  7. Are you talking about the moving speed or the time when the ped can move freely again? For moving freely you need to edit the anim_breakout_time property. Set it at 0. https://wiki.multitheftauto.com/wiki/SetWeaponProperty If this is not what you mean, then I did like to see that (not created yet) video.
  8. no, I am not expecting that. I am expecting it to create a new copy of the default state of the block every time the function has been called. Which is lua actually doing at the moment. It is just strange that when the function (that has been created in testVariable) is destroyed, the block(copy) where it has been created also gets destroyed. I know it is complicated.
  9. It is indeed a kinda unexpected/ yet expected that testVariable remains part of the scope per function. But the main reason why I posted this, is: function testFunction () local testVariable = 100 local function firstFunctionInBlock () print("first function, testVariable: " .. testVariable ) testVariable = testVariable + 1 end local function secondFunctionInBlock () print("second function, testVariable: " .. testVariable) testVariable = testVariable + 1 end return function () firstFunctionInBlock() secondFunctionInBlock () end end This new created function is created inside the function block and yet it is the reason why this block remains to exist. If this function is destroyed it should automatic clear the whole function block with the garbage collector: Which has been created when the testFunction is called: local newCreatedFunction = testFunction() function testFunction () local testVariable = 100 local function firstFunctionInBlock () print("first function, testVariable: " .. testVariable ) testVariable = testVariable + 1 end local function secondFunctionInBlock () print("second function, testVariable: " .. testVariable) testVariable = testVariable + 1 end return function () firstFunctionInBlock() secondFunctionInBlock () end end
  10. Nobody is interested in it? I am getting really sad you know, eat my smiley!
  11. Or use this one: nightly.multitheftauto.com/files/shaders/shader_circle.zip Might not look as pretty as the one that @koragg gave to you, but uses 10 t/m 1000 times less memory.(depending on the circle size)
  12. Ah sorry for my late reply, I didn't saw that you had replied. You are using callRemote right? This function is currently blocked by the default acl. (I am not sure if it was blocked from the beginning)
  13. Hi, I was curious when the garbage collector would clean something like this: function testFunction () local testVariable = 100 local function firstFunctionInBlock () print("first function, testVariable: " .. testVariable ) testVariable = testVariable + 1 end local function secondFunctionInBlock () print("second function, testVariable: " .. testVariable) testVariable = testVariable + 1 end return function () firstFunctionInBlock() secondFunctionInBlock () end end function testFunction () -------------------------- -- function block -- -------------------------- end Executed with: local newCreatedFunction = testFunction() newCreatedFunction() newCreatedFunction() newCreatedFunction() -- print("--") -- local newCreatedFunction2 = testFunction() newCreatedFunction2() newCreatedFunction2() newCreatedFunction2() Results: first function, testVariable: 100 second function, testVariable: 101 first function, testVariable: 102 second function, testVariable: 103 first function, testVariable: 104 second function, testVariable: 105 -- first function, testVariable: 100 second function, testVariable: 101 first function, testVariable: 102 second function, testVariable: 103 first function, testVariable: 104 second function, testVariable: 105 I assume when I nil the function that is active in the block. newCreatedFunction = nil It will clear the first created function block by the garbage collector. newCreatedFunction2 = nil Same goes for clearing the second created function block. I did like to hear your opinion about this matter!
  14. Replace line 5 and line 5 at both of the scripts. With the almost identical code from my post.
  15. triggerClientEvent(sourcePlayer, "onPayPhone", resourceRoot, sourcePlayer) < server (3e argument is the source of the event that will be executed. The source isn't a parameter.) The source is now the resourceRoot. ------- Client > addEventHandler("onPayPhone", resourceRoot, onPayPhone) The resourceRoot element is shared over client and serverside. This eventhandler will only accept the resourceRoot of this resource.
  16. Make sure you break the loop after cancelling the event. (performance) break
  17. My last code post will help you out with that problem, since it isn't corner based but distance based.
  18. How about you try to pre render it? > onClientPreRender < Maybe the GTA is re-adjusting the wheels every frame.
  19. I wonder if you can rotate tires like that. Why don't you try it with: https://wiki.multitheftauto.com/wiki/SetAnalogControlState ? Since you are only rotating the Z as.
  20. You might want to reply @klaw , it is a bit rude if you do not.
  21. You might want to reply @pepsi18 it is a bit rude if you do not.
  22. I could have written it better. I skipped here and there some words, but I am happy that you like it. P.s: Learning tables will make you a god at scripting systems like this.
  23. I came up with an easier concept for it. This will compare the centres of the rectangles with each other, which only requires 4 conditions. local rectangleX1, rectangleY1 = 25, 0 local rectangleX2, rectangleY2 = -25, 10 local rectangleSizeX, rectangleSizeY = 50, 50 function isRectangleInRectangle(X1, Y1, sizeX1, sizeY1, X2, Y2, sizeX2, sizeY2) local centreX1, centreY1 = X1 + sizeX1 / 2, Y1 + sizeY1 / 2 local centreX2, centreY2 = X2 + sizeX2 / 2, Y2 + sizeY2 / 2 local distanceX = centreX1 - centreX2 local distanceY = centreY1 - centreY2 if distanceX < 0 then distanceX = -distanceX end if distanceY < 0 then distanceY = -distanceY end if distanceX <= sizeX1 / 2 + sizeX2 / 2 and distanceY <= sizeY1 / 2 + sizeY2 / 2 then return true end return false end iprint(tostring(isRectangleInRectangle(rectangleX1, rectangleY1, rectangleSizeX, rectangleSizeY, rectangleX2, rectangleY2, rectangleSizeX, rectangleSizeY)))
  24. nvm you are right. I think I am a bit tired, that must be the problem. I will solve it for you tomorrow if nobody already solved it for you.
  25. sides should be included afaik, my bad for forgetting to mention that. It is untested, so test it with all possible combinations you can come up with.
×
×
  • Create New...