Jump to content

IIYAMA

Moderators
  • Posts

    6,058
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. Compiled scripts run faster, as they are optimised(cleaner) for computer execution. Decryption is only happening at the start of the resources. (The scripts will be loaded in the ram + executed) So yes, that might be happening in the beginning of the reading process if you have a lot of scripts. But after that, it shouldn't be a problem.
  2. IIYAMA

    setCameraMatrix

    That is not the correct syntax for setCameraMatrix clientside. Serverside bool setCameraMatrix ( player thePlayer, float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] ) Clientside bool setCameraMatrix ( float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] ) In clientside you do not define the player, because a client(a player) can't change other players(clients) their camera. So that option has been left out. Try this: function CameraMatrix () local x, y, z = getElementPosition ( object ) setCameraMatrix(x, y, z + 5, x, y + 20, z + 5) end function move () moveObject ( object, 40000, -2837.884765625, -3147.1728515625, 666.09998 ) addEventHandler ( "onClientRender", root, CameraMatrix ) end addCommandHandler("move", move) (if nothing happens, it might be possible that you run the script serverside)
  3. IIYAMA

    setCameraMatrix

    Use this event to update the position every frame(frames per second): https://wiki.multitheftauto.com/wiki/OnClientRender Example on that page: Instead of using the localPlayer, use the object: local x, y, z = getElementPosition ( object )
  4. This will solve it in most cases: 1. If it is nil or false use OR to change it to the next value, which is in this case 0. getElementData(player, "Radio Device") or 0 2. If it was a string before, it is now converted to a number, with the lua function tonumber. "100" (string) is now converted to 100 (number) tonumber(getElementData(player, "Radio Device") or 0) 3. Apply your statement. if tonumber(getElementData(player, "Radio Device") or 0) >= 1 then addCommandHandler("radiochat", function(player, _, ...) if tonumber(getElementData(player, "Radio Device") or 0) >= 1 then for _,v in ipairs(getElementsByType("player")) do if tonumber(getElementData(v, "Radio Device") or 0) >= 1 then if getElementData(v, "radiochannel") == getElementData(player, "radiochannel") then outputChatBox("#BCC643[Radio] "..getPlayerName(player):gsub("#%x%x%x%x%x%x", "").." : #d0e1e1"..table.concat({...}, " "):gsub("#%x%x%x%x%x%x", ""), v, 255, 255, 255, true); end end end end end)
  5. Unfinished(some unseen bugs) and very very untested. Will not work if you do not fix my silly if then statement. CLIENT local rpgFireLimit = { controls = { block = function () toggleControl("fire", false) toggleControl("aim_weapon", false) end, unBlock = function () toggleControl("fire", true) toggleControl("aim_weapon", true) rpgFireLimit.timer = nil end } } addEventHandler ( "onClientPlayerWeaponFire", localPlayer, function (weapon) -- The `source` of this event is the same as `localPlayer` in this example. if weapon == 36 or weapon == 35 then -- https://wiki.multitheftauto.com/wiki/Weapons if false and nil and false and nil and false and nil then -- << testing if you are actually reading my code... rpgFireLimit.controls.block() if isTimer(rpgFireLimit.timer) then killTimer(rpgFireLimit.timer) end rpgFireLimit.timer = setTimer(rpgFireLimit.controls.unBlock, 20000, 1) end end end) --[[ addEventHandler("onClientPlayerWeaponSwitch", localPlayer, function etc... ]]
  6. I am not kidding. Isn't it obvious that you show me your progress even though it doesn't work? So that I can help you finish it? It is not that I am fixing code without making sure that YOU actually learn from your mistakes, because that would be a waste of my time wouldn't it? Work with me, not against me and not on the side line. That is all I ask of you.
  7. In lua I somehow do not really like OOP to the max. It doesn't feel like how it works in JavaScript(always OOP). So I prefer a mix depending on the situation, but consisted.
  8. Code can't correct itself. Even stupid @IIYAMA knows that.
  9. https://wiki.multitheftauto.com/wiki/OnClientWeaponFire That event is for custom weapons(elements), which are not the same as weapons fired by players. https://wiki.multitheftauto.com/wiki/Element/Weapon Use this event instead: https://wiki.multitheftauto.com/wiki/OnClientPlayerWeaponFire The first parameter is the weapon that is fired, syntax: int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement, float startX, float startY, float startZ And the source is the player that fires the weapon. (this can also be a remote player if the root element is attached to the event, I recommend to attach the localPlayer) addEventHandler ( "onClientPlayerWeaponFire", localPlayer, function (weapon) -- The `source` of this event is the same as `localPlayer` in this example. if weapon == 36 or weapon == 35 then -- https://wiki.multitheftauto.com/wiki/Weapons -- etc. end end)
  10. IIYAMA

    [math.random]

    local fegyverPedP = { {2756.822265625, -2513.9208984375, 13.642685890198}, {2761.572265625, -2531.7333984375, 13.638335227966} } function createThisPed(positions) local randomPos = math.random(#positions) local fegyverPed = createPed(111, positions[randomPos][1], positions[randomPos][2], positions[randomPos][3]) setElementInterior(fegyverPed, 0) setElementDimension(fegyverPed, 0) setElementFrozen(fegyverPed, true) setElementRotation(fegyverPed, 0, 0, 90) end createThisPed(fegyverPedP) Untested
  11. IIYAMA

    [math.random]

    The answer to your question is already in YOUR comments. local fegyverPed = createPed(111, fegyverPedP[randompos][1], fegyverPedP[randompos][2], fegyverPedP[randompos][3])
  12. Use: https://wiki.multitheftauto.com/wiki/SetPedCameraRotation
  13. You might be able to validate the function with: https://www.tutorialspoint.com/lua/lua_debugging.htm This doesn't stop the function from being overwritten, but you can stop the script operations if the info tells you that a lua function is called instead of a C function.(afaik default mta functions are considered as C functions, but not 100% sure) print(debug.getinfo(1)) Maybe getinfo does the job:
  14. I do not know if that happens in the current version of MTA. But afaik there were in the past versions that didn't sync that. For security(cheating effect, but not real cheating) / (always small) de-sync you shouldn't not do that clientside.
  15. I don't think that is possible by default. do local vehicles = getElementsByType("vehicle") for i=1, #vehicles do local vehicle = vehicles[i] setElementFrozen(vehicle, true) end end You can freeze the vehicles, but that also means you can't drive them any more. https://wiki.multitheftauto.com/wiki/SetElementFrozen Or you could make the vehicles more heavy, with: (recommend this one) https://wiki.multitheftauto.com/wiki/SetModelHandling Or you can remove the collision between the players and the vehicles: https://wiki.multitheftauto.com/wiki/SetElementCollidableWith
  16. @overlocus For example this. setElementPosition(vehicle, 0, 0, 10) -- position setElementRotation(vehicle, 90, 180, 0, "ZYX") -- orientation/rotation Just play with it, until you understand it. (best way of learning) Quick test code: (client / server) do local vehicles = getElementsByType("vehicle") for i=1, #vehicles do local vehicle = vehicles[i] setElementPosition(vehicle, 0, 0, 10) -- position setElementRotation(vehicle, 90, 180, 0, "ZYX") -- orientation/rotation end end Wiki: https://wiki.multitheftauto.com/wiki/SetElementPosition https://wiki.multitheftauto.com/wiki/SetElementRotation
  17. IIYAMA

    Play Sound

    It is , take it or leave it. But don't be so ungrateful.
  18. That's why you need two... since polygons can't be limited on the height.
  19. IIYAMA

    Play Sound

    There is a tutorial for learning server client communication:
  20. Html/css/js is not made to be private. But what you can do: If you want to protect the interaction, you will have to write it with some more back-end or wire the JavaScript with lua.
  21. Write with JavaScript? https://wiki.multitheftauto.com/wiki/ExecuteBrowserJavascript Ofcourse you can't protect it 100%, but atleast you can keep your HTML files almost empty. Making it beginner proof. SASS is unrelated. (It is a kind of advanced css format that will be converted to css after being compiled)
  22. You can use a second colshape in combination with: https://wiki.multitheftauto.com/wiki/IsElementWithinColShape So group the colshapes, attach a single handler. And use the function to check if the player is in both.
  23. Reducing 8 similar loops to 1 loop is unclear? Really? Momentarily you are giving me the feeling that you do not understand your own script, which is a big issue.
  24. @JeViCo Once you change the file, it is no longer valid for MTA and will be re-downloaded.(your previous problem, which is related to file security) Please show me your code. Because it looks like you either didn't close the file in time or deleted it too fast.
  25. That doesn't happen for me. Are you editing the files or something like that? (Or doing this before the resource has started?)
×
×
  • Create New...