Jump to content

koragg

Members
  • Posts

    730
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by koragg

  1. What's the error in /debugscript 3 ?
  2. Yeah I hid blips exactly the same way but markers couldn't. But hello setMarkerSize(), this is a nice idea
  3. It is Idk why it says 0, like they're not of type 'marker' or something.
  4. Well the easiest way to see if they get detected is this, and it shows 0 in chatbox. function markersTest() local markers = getElementsByType("marker") outputChatBox(#markers) end addCommandHandler("markerstest", markersTest) While doing the same for blips shows 2.
  5. Thing is that i can't get them with getElementsByType for some reason so i can't destroy them on the client.
  6. So I want to hide checkpoint markers and blips created by the map itself. The blips were no problem - I got them via getElementsByType("blip") and set their alpha to 0. But the markers are the problem here because I can't get them with getElementsByType("marker"). It says there are 0 markers when there are 2 right infront of me. So since I can't get them I also can't use setElementVisibleTo or destroy them when needed. Any help? They get created on map start by the "createCheckpoint()" function in 'race_client.lua' file inside the race.zip resource. I don't get why blips work fine but markers don't, but I think it's got something to do with the "createCheckpoint()" function as it has a return value ("checkpoint.marker"). Maybe that prevents me to find all markers somehow? No idea, they're made using the normal 'createMarker()' function so it should work.
  7. Try to add "local nextSong" at the very top of your script above all other functions (if you haven't done it already, I'm from phone and I'm sleepy so forgive me xd). And yes you can nest functions but no i got no idea how it works (just seen it done once somewhere). Oh and I'm pretty sure you need to add both an event as well as a handler before triggering it.
  8. if sound then stopSound (sound) end Or if isElement (sound) then stopSound (sound) end On client render^
  9. Oh, you can't use it like that. Read what the wiki says: https://wiki.multitheftauto.com/wiki/GetTickCount This function returns amount of time that your system has been running in milliseconds. So you can't compare it like that as it will always be a lot higher than 45000. You can compare two variables which you've assigned to getTickCount(). For example: 1. You make "local startTime = getTickCount()" when the resource starts. 2. You make "local currentTime = getTickCount()" when some condition is met (not when the resource starts) 3. Now you can check it like this somewhere else in your code: "if currentTime - startTime < 60000 then".
  10. Hm, I guess you can set element data server-side when the player logs in. Something like this: function onPlayerLogin() setElementData(source, "loggedIn", true) end addEventHandler("onPlayerLogin", root, onPlayerLogin) And then on the client you can add this so that it checks for that data every frame: function StopLoginSound() local loggedIn = getElementData(localPlayer, "loggedIn") if loggedIn == true then stopSound(sound) if isTimer ( nextSong ) then killTimer ( nextSong ) end end end addEventHandler("onClientRender", root, StopLoginSound)
  11. Sorry, can you tell at which line you get that boolean error, please?
  12. nextSong = setTimer(nextSound, soundLength*1000, 0) https://wiki.multitheftauto.com/wiki/SetTimer timesToExecute: The number of times you want the timer to execute, or 0 for infinite repetitions. The 0 at the end should be a 1 if you want to play it only once. Otherwise when the timer ends/gets killed it will get created again, and like this forever. Remember that when calling the 'nextSound' function from inside of it at line 42 it's OK to have the last argument set to 1, because every time the 'nextSound' gets triggered it will create a new timer. And since the timer that triggers the function is inside of it, even with '1' instead of '0' it will repeat with another song. I think Give it a go, I don't see any errors in your code.
  13. You can use each of those things. For me setTimer is easier but getTickCount() can do the same job, sometimes even better.
  14. Sadly it didn't. But I noticed that you tried to fix it only by using 'AngZ'. Isn't the 'AngZ' variable used while moving mouse? The problem in video is that without moving mouse, the camera does not go up/down a bit so that those glitches can be avoided.
  15. At first I did it with attachElements but the camera couldn't be moved by mouse then. Anyway, the shake is from the race_ghost resource, it lags even when not spectating it . Can you have a look at the code I posted and see how the X position is fixed? I think @orel56000 fixed it.(OK, it was @idan1432) Maybe something similar for the Z one (though I tried and meh)? Problem's that I'm not that good at maths stuff (like Vectors, etc) otherwise I'd do it myself but can't do anything with such calculations And if not, thanks for trying atleast
  16. Here's a video explaining the problem better: As you see in the first 50 seconds of the video the camera is behind the car. But from around 0:55 when the car goes up the hill the camera does not stay behind it but goes ontop of it.Also on 1:05 you can clearly see how the camera goes under the GTA textures because it does not stay behind the car, but this time is under it as it's going downhill. Could somebody please help me out with a code or formula so that the camera will stay always behind the car, thus avoiding those under-texture peaks and ontop-of-car weird look. It should always be focused at the back of the car as it is on a straight road from the start of the video until around 0:50. This is the full code for the camera function: local AngX, AngZ, specDist, specTarget, ticks, speed, fixedCam, isMinimized = 0, 0, 0, nil, 0, 0.8, true, false ------------------------------------------------------------------------------------------------------------------------- function MoveMouse(rx, ry, x, y) if not isCursorShowing() and not isMTAWindowActive() and getKeyState("Q") == false and getKeyState("E") == false and getKeyState("mouse3") == false and isMinimized == false then fixedCam = false local sx, sy = guiGetScreenSize() ticks = getTickCount() AngX = (AngX + (x - (sx / 2)) / 10) % 360 AngZ = (AngZ + (y - (sy / 2)) / 10) % 360 if AngZ > 180 then if AngZ < 315 then AngZ = 315 end else if AngZ > 45 then AngZ = 45 end end end end ------------------------------------------------------------------------------------------------------------------------- function RenderVeiw() local ox, oy, oz local x, y, z local savedDis1 local savedSpeed if specTarget then x, y, z = getElementPosition(specTarget) end if x and y and z and AngX and AngZ and specDist then if getKeyState("Q") == true and getKeyState("E") == false and getKeyState("mouse3") == false and not isCursorShowing() and not isMTAWindowActive() then local rx, ry, rz = getElementRotation(specTarget) local dis = AngX - (270 - rz) local dis1 = math.abs(dis) if dis1 > 30 then if speed < 4 then speed = speed + 0.4 end elseif dis1 < 30 then if speed > 0.8 then speed = speed - 0.4 end elseif dis1 > speed then dis = dis / (dis1 / speed) end savedDis1 = dis1 savedSpeed = speed fixedCam = true AngX = AngX - dis elseif getKeyState("Q") == false and getKeyState("E") == true and getKeyState("mouse3") == false and not isCursorShowing() and not isMTAWindowActive() then local rx, ry, rz = getElementRotation(specTarget) local dis = AngX - (90 - rz) local dis1 = math.abs(dis) if dis1 > 30 then if speed < 4 then speed = speed + 0.4 end elseif dis1 < 30 then if speed > 0.8 then speed = speed - 0.4 end elseif dis1 > speed then dis = dis / (dis1 / speed) end savedDis1 = dis1 savedSpeed = speed fixedCam = true AngX = AngX - dis elseif ((getKeyState("Q") == true and getKeyState("E") == true) or getKeyState("mouse3") == true) and not isCursorShowing() and not isMTAWindowActive() then local rx, ry, rz = getElementRotation(specTarget) local dis = AngX - (180 - rz) local dis1 = math.abs(dis) if dis1 > 30 then if speed < 4 then speed = speed + 0.4 end elseif dis1 < 30 then if speed > 0.8 then speed = speed - 0.4 end elseif dis1 > speed then dis = dis / (dis1 / speed) end savedDis1 = dis1 savedSpeed = speed fixedCam = true AngX = AngX - dis elseif ((getKeyState("Q") == false and getKeyState("E") == false) or getKeyState("mouse3") == false) then if ticks + 1500 < getTickCount() then local rx, ry, rz = getElementRotation(specTarget) local dis = AngX - (360 - rz) local zDis = AngZ - (360 - rz) local dis1 = math.abs(dis) if fixedCam == false then if dis1 > 30 then if speed < 4 then speed = speed + 0.4 end end if dis1 < 30 then if speed > 0.8 then speed = speed - 0.4 end end if dis1 > speed then dis = dis / (dis1 / speed) end if dis1 < speed then fixedCam = true end end if fixedCam == true then if dis1 > 30 then if speed < 4 then speed = speed + 0.4 end elseif dis1 < 30 then if speed > 0.8 then speed = speed - 0.4 end elseif dis1 > speed then dis = dis / (dis1 / speed) end end savedDis1 = dis1 savedSpeed = speed AngX = AngX - dis end end if isCursorShowing() or isMTAWindowActive() then if ticks + 1500 < getTickCount() then if savedDis1 and savedSpeed and savedDis1 < savedSpeed then fixedCam = true end end end ox = x - math.sin(math.rad(AngX)) * specDist oy = y - math.cos(math.rad(AngX)) * specDist oz = z + math.tan(math.rad(AngZ)) * specDist + 2 setCameraMatrix(ox, oy, oz, x, y, z) end end ------------------------------------------------------------------------------------------------------------------------- addEvent("setPlayerSpecOnElement", true) function PlayerSpecOnElement(target, distance) if target == nil or distance == nil or target == "None" then if isEventHandlerAdded("onClientCursorMove", root, MoveMouse) == true then removeEventHandler("onClientCursorMove", root, MoveMouse) movedMouse = false end if isEventHandlerAdded("onClientRender", root, RenderVeiw) == true then removeEventHandler("onClientRender", root, RenderVeiw) end specTarget = nil specDist = 0 return 1 end if specTarget then if isEventHandlerAdded("onClientCursorMove", root, MoveMouse) == true then removeEventHandler("onClientCursorMove", root, MoveMouse) movedMouse = false end if isEventHandlerAdded("onClientRender", root, RenderVeiw) == true then removeEventHandler("onClientRender", root, RenderVeiw) end end specTarget = target specDist = distance if isEventHandlerAdded("onClientCursorMove", root, MoveMouse) == true then removeEventHandler("onClientCursorMove", root, MoveMouse) movedMouse = false end if isEventHandlerAdded("onClientCursorMove", root, MoveMouse) == false then addEventHandler("onClientCursorMove", root, MoveMouse) movedMouse = true end if isEventHandlerAdded("onClientRender", root, RenderVeiw) == true then removeEventHandler("onClientRender", root, RenderVeiw) end if isEventHandlerAdded("onClientRender", root, RenderVeiw) == false then addEventHandler("onClientRender", root, RenderVeiw) end end addEventHandler("setPlayerSpecOnElement", root, PlayerSpecOnElement)
  17. You can send variables's values only via events: https://wiki.multitheftauto.com/wiki/TriggerServerEvent https://wiki.multitheftauto.com/wiki/TriggerClientEvent https://wiki.multitheftauto.com/wiki/TriggerEvent or element data: https://wiki.multitheftauto.com/wiki/SetElementData https://wiki.multitheftauto.com/wiki/GetElementData
  18. That's bad I guess you can give a weapon with ammo 1 when ammo reaches 0 and somehow disable firing until ammo goes above 1.
  19. I'm no expert in modes other than race but you could test if holding a weapon with 0 ammo is even possible the following way: Make a function which gives you a weapon and set it's ammo variable to 0 with this: https://wiki.multitheftauto.com/wiki/GiveWeapon via a command handler. If it doesn't disappear then there is a way to do what you want, otherwise it could be hardcoded to go away when out of ammo. You can also see if it has 0 ammo with this: https://wiki.multitheftauto.com/wiki/GetWeaponAmmo And as long as your weapon has 0 ammo you give yourself a new weapon and set it's ammo to 0. Probably onClientRender would be needed for this.
  20. This is the solution Turned out old maps use the size attribute in a different way than new ones and the value needs to be multiplied by 4. In the above topic you'll see how to detect if a map is in the old format or not by inspecting it's .map file. If there is a "mod" attribute then the map is in the old format so the checkpoint size value needs to be multiplied four times to have it in real size. Problem fixed
  21. xmlNodeGetAttribute(mapFile, "mod") did it, fixed.
  22. I found the answer to this thanks to Xiti. But in order to fix it I need to get information from the map's '.map' file and I'm having a bit of trouble with that. The file has this inside of it: <?xml version="1.0" encoding="utf-16"?> <map mod="deathmatch"> ... <spawnpoint posX="2866.353027" posY="-901.636719" posZ="10.800994" rotation="358" vehicle="411" id="spawnpoint0" /> ... </map> What I need is to somehow get the value of 'mod' and 'mod' itself in a local variable. But the problem is that xmlFindChild() can't be used here. If I needed to get the 'spawnpoint' node and some of it's attributes xmlFindChild() would work, but the 'mod' attribute seems to be a bit different than a regular node (as you see above). So how can I get the 'mod' node and it's value in two different local variables in my script? I need to check if a map has the 'mod' node in it's '.map' file in order to fix my problem with the markers' size.
  23. Still can't find a way to fix the camera's Z position to be like in normal spectating mode - always behind the car, not under or ontop of it.
  24. You can try to do 'getSoundLength*100' and use this to round it up to an integer: --http://lua-users.org/wiki/FormattingNumbers function round(val, decimal) if (decimal) then return math.floor( (val * 10^decimal) + 0.5) / (10^decimal) else return math.floor(val+0.5) end end So something like: setTimer(nextSound, round(soundLength), 1) You can also do like this until you get an integer: setTimer(nextSound, round(soundLength, 2), 1) The '2' can be higher, depends which value for it returns an integer of the passed number. Experiment a bit with it.
  25. getRootElement() is the same as root btw.
×
×
  • Create New...