XetaQuake Posted May 21, 2008 Author Share Posted May 21, 2008 The getCameraPosition function is purely client sided. Oh You will have to teleport the vehicle server side and tell the client to start the camera check timer I wonder for a long time how i can create a bridge between server and client side script, can you give me a tip? Link to comment
XetaQuake Posted May 21, 2008 Author Share Posted May 21, 2008 The getCameraPosition function is purely client sided. Oh You will have to teleport the vehicle server side and tell the client to start the camera check timer I wonder for a long time how i can create a bridge between server and client side script, can you give me a tip? Link to comment
Ace_Gambit Posted May 21, 2008 Share Posted May 21, 2008 Try something like this: server function teleportPlayerVehicle(player) local vehicle = getPlayerOccupiedVehicle(player) local targetX, targetY, targetZ = 0, 0, 0 -- teleport location if (vehicle) then -- teleport vehicle (setElementInterior or setElementPosition) triggerClientEvent(player, "onVehicleTeleport", player, targetX, targetY, targetZ) end end function onVehicleTeleported() local vehicle = getPlayerOccupiedVehicle(source) if (vehicle) then setVehicleFrozen(vehicle, false) end end addEvent("onVehicleTeleported", true) addEventHandler("onVehicleTeleported", getRootElement(), onVehicleTeleported) client function onVehicleTeleport(targetX, targetY, targetZ) local vehicle = getPlayerOccupiedVehicle(getLocalPlayer()) local vX, vY, vZ = 0, 0, 0 local cX, cY, cZ = 0, 0, 0 if (vehicle) then vX, vY, vZ = getElementPosition(vehicle) cX, cY, cZ = getCameraPosition() if (getDistanceBetweenPoints3D(vX, vY, vZ, targetX, targetY, targetZ) < 5.0 and getDistanceBetweenPoints3D(cX, cY, cZ, targetX, targetY, targetZ) < 25.0) then triggerServerEvent("onVehicleTeleported", getLocalPlayer()) else setTimer(onVehicleTeleport, 50, 1, targetX, targetY, targetZ) end end end addEvent("onVehicleTeleport", true) addEventHandler("onVehicleTeleport", getRootElement(), onVehicleTeleport) Link to comment
Ace_Gambit Posted May 21, 2008 Share Posted May 21, 2008 Try something like this: server function teleportPlayerVehicle(player) local vehicle = getPlayerOccupiedVehicle(player) local targetX, targetY, targetZ = 0, 0, 0 -- teleport location if (vehicle) then -- teleport vehicle (setElementInterior or setElementPosition) triggerClientEvent(player, "onVehicleTeleport", player, targetX, targetY, targetZ) end end function onVehicleTeleported() local vehicle = getPlayerOccupiedVehicle(source) if (vehicle) then setVehicleFrozen(vehicle, false) end end addEvent("onVehicleTeleported", true) addEventHandler("onVehicleTeleported", getRootElement(), onVehicleTeleported) client function onVehicleTeleport(targetX, targetY, targetZ) local vehicle = getPlayerOccupiedVehicle(getLocalPlayer()) local vX, vY, vZ = 0, 0, 0 local cX, cY, cZ = 0, 0, 0 if (vehicle) then vX, vY, vZ = getElementPosition(vehicle) cX, cY, cZ = getCameraPosition() if (getDistanceBetweenPoints3D(vX, vY, vZ, targetX, targetY, targetZ) < 5.0 and getDistanceBetweenPoints3D(cX, cY, cZ, targetX, targetY, targetZ) < 25.0) then triggerServerEvent("onVehicleTeleported", getLocalPlayer()) else setTimer(onVehicleTeleport, 50, 1, targetX, targetY, targetZ) end end end addEvent("onVehicleTeleport", true) addEventHandler("onVehicleTeleport", getRootElement(), onVehicleTeleport) Link to comment
XetaQuake Posted May 22, 2008 Author Share Posted May 22, 2008 Now i found the problem why i think i "falling down". Its following: i frezzes the car after 150 milli seconds because so i can fix the problem that the car runs crasy But the problem with this metode: sometimes when the car is not hight enought (interiors are in the air...) and then the frezz launches, the car stop teleporting (flying) to the destination point, because 150 milli seconds is not enought to get in the interior. Why i don´t use more milli seconds? Because every PC uses different hardware and have different pings. Now my idea: i need a function to check that the vehicle is on the place it should be beamed, like getVehiclePosition or so. is that possibly? Link to comment
XetaQuake Posted May 22, 2008 Author Share Posted May 22, 2008 Now i found the problem why i think i "falling down". Its following: i frezzes the car after 150 milli seconds because so i can fix the problem that the car runs crasy But the problem with this metode: sometimes when the car is not hight enought (interiors are in the air...) and then the frezz launches, the car stop teleporting (flying) to the destination point, because 150 milli seconds is not enought to get in the interior. Why i don´t use more milli seconds? Because every PC uses different hardware and have different pings. Now my idea: i need a function to check that the vehicle is on the place it should be beamed, like getVehiclePosition or so. is that possibly? Link to comment
Ace_Gambit Posted May 22, 2008 Share Posted May 22, 2008 Take a good look at the code in the post above you . That is exactly what the check does. It checks if the vehicle is within range of its target location. Link to comment
Ace_Gambit Posted May 22, 2008 Share Posted May 22, 2008 Take a good look at the code in the post above you . That is exactly what the check does. It checks if the vehicle is within range of its target location. Link to comment
XetaQuake Posted May 22, 2008 Author Share Posted May 22, 2008 That is exactly what the check does. sorry ^^ Its a little bit complicated to build it in, i try it but it don´t works, where is setVehicleFrozen(vehicle, true) in this code? On local targetX, targetY, targetZ = 0, 0, 0 -- teleport location and -- teleport vehicle (setElementInterior or setElementPosition) i need to set the destination point? That´s my currently code: http://mta.pastebin.com/m5c934a89 And now i tries to build you code in it: http://mta.pastebin.com/m449eab5b but it don´t work notice: the client script is build in in the meta.xml, don´t worry ^^ Link to comment
XetaQuake Posted May 22, 2008 Author Share Posted May 22, 2008 That is exactly what the check does. sorry ^^ Its a little bit complicated to build it in, i try it but it don´t works, where is setVehicleFrozen(vehicle, true) in this code? On local targetX, targetY, targetZ = 0, 0, 0 -- teleport location and -- teleport vehicle (setElementInterior or setElementPosition) i need to set the destination point? That´s my currently code: http://mta.pastebin.com/m5c934a89 And now i tries to build you code in it: http://mta.pastebin.com/m449eab5b but it don´t work notice: the client script is build in in the meta.xml, don´t worry ^^ Link to comment
Ace_Gambit Posted May 22, 2008 Share Posted May 22, 2008 I've just tested this code (made some minor changes to yours) and it seems to work. server local targetX, targetY, targetZ = -1396.1995849609, 1093.6236572266, 1048.9255371094 local sourceX, sourceY, sourceZ = 1078.9619140625, 1602.2117919922, 12.546875 local ColHotringRaceEingang = createColSphere(sourceX, sourceY, sourceZ, 2) function HotringRaceMarkerEingang(name) if (name ~= getThisResource()) then return else createMarker(sourceX, sourceY, sourceZ, "cylinder", 4, 219, 155, 135, 100) end end function HotringRaceMarkerEingangBeamer(player) local vehicle = false if (getElementType(player) == "player") then vehicle = getPlayerOccupiedVehicle(player) if (vehicle) then setElementInterior(vehicle, 15, targetX, targetY, targetZ) setVehicleFrozen(vehicle, true) setElementInterior(player, 15, targetX, targetY, targetZ) triggerClientEvent(player, "onVehicleTeleport", player, targetX, targetY, targetZ) end end end function onVehicleTeleported() local vehicle = getPlayerOccupiedVehicle(source) if (vehicle) then setVehicleFrozen(vehicle, false) end end addEvent("onVehicleTeleported", true) addEventHandler("onVehicleTeleported", getRootElement(), onVehicleTeleported) addEventHandler("onColShapeHit", ColHotringRaceEingang, HotringRaceMarkerEingangBeamer) addEventHandler("onResourceStart", getRootElement(), HotringRaceMarkerEingang) client function onVehicleTeleport(targetX, targetY, targetZ) local vehicle = getPlayerOccupiedVehicle(getLocalPlayer()) local vX, vY, vZ = 0, 0, 0 local cX, cY, cZ = 0, 0, 0 if (vehicle) then vX, vY, vZ = getElementPosition(vehicle) cX, cY, cZ = getCameraPosition() if (getDistanceBetweenPoints3D(vX, vY, vZ, targetX, targetY, targetZ) < 5.0 and getDistanceBetweenPoints3D(cX, cY, cZ, targetX, targetY, targetZ) < 25.0) then triggerServerEvent("onVehicleTeleported", getLocalPlayer()) else setTimer(onVehicleTeleport, 50, 1, targetX, targetY, targetZ) end end end addEvent("onVehicleTeleport", true) addEventHandler("onVehicleTeleport", getRootElement(), onVehicleTeleport) Link to comment
Ace_Gambit Posted May 22, 2008 Share Posted May 22, 2008 I've just tested this code (made some minor changes to yours) and it seems to work. server local targetX, targetY, targetZ = -1396.1995849609, 1093.6236572266, 1048.9255371094 local sourceX, sourceY, sourceZ = 1078.9619140625, 1602.2117919922, 12.546875 local ColHotringRaceEingang = createColSphere(sourceX, sourceY, sourceZ, 2) function HotringRaceMarkerEingang(name) if (name ~= getThisResource()) then return else createMarker(sourceX, sourceY, sourceZ, "cylinder", 4, 219, 155, 135, 100) end end function HotringRaceMarkerEingangBeamer(player) local vehicle = false if (getElementType(player) == "player") then vehicle = getPlayerOccupiedVehicle(player) if (vehicle) then setElementInterior(vehicle, 15, targetX, targetY, targetZ) setVehicleFrozen(vehicle, true) setElementInterior(player, 15, targetX, targetY, targetZ) triggerClientEvent(player, "onVehicleTeleport", player, targetX, targetY, targetZ) end end end function onVehicleTeleported() local vehicle = getPlayerOccupiedVehicle(source) if (vehicle) then setVehicleFrozen(vehicle, false) end end addEvent("onVehicleTeleported", true) addEventHandler("onVehicleTeleported", getRootElement(), onVehicleTeleported) addEventHandler("onColShapeHit", ColHotringRaceEingang, HotringRaceMarkerEingangBeamer) addEventHandler("onResourceStart", getRootElement(), HotringRaceMarkerEingang) client function onVehicleTeleport(targetX, targetY, targetZ) local vehicle = getPlayerOccupiedVehicle(getLocalPlayer()) local vX, vY, vZ = 0, 0, 0 local cX, cY, cZ = 0, 0, 0 if (vehicle) then vX, vY, vZ = getElementPosition(vehicle) cX, cY, cZ = getCameraPosition() if (getDistanceBetweenPoints3D(vX, vY, vZ, targetX, targetY, targetZ) < 5.0 and getDistanceBetweenPoints3D(cX, cY, cZ, targetX, targetY, targetZ) < 25.0) then triggerServerEvent("onVehicleTeleported", getLocalPlayer()) else setTimer(onVehicleTeleport, 50, 1, targetX, targetY, targetZ) end end end addEvent("onVehicleTeleport", true) addEventHandler("onVehicleTeleport", getRootElement(), onVehicleTeleport) Link to comment
XetaQuake Posted May 22, 2008 Author Share Posted May 22, 2008 I thank you! hehe a movie don´t was needed ^^ But now whe fixed the bug =) thanks Ace_Gambit, now this thread is REALY finished ^^ Link to comment
XetaQuake Posted May 22, 2008 Author Share Posted May 22, 2008 I thank you! hehe a movie don´t was needed ^^ But now whe fixed the bug =) thanks Ace_Gambit, now this thread is REALY finished ^^ Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now