Jump to content

Ace_Gambit

Members
  • Posts

    569
  • Joined

  • Last visited

Everything posted by Ace_Gambit

  1. 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)
  2. 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.
  3. 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.
  4. Actually searching in XML is slower than executing a query. I am just trying to point out that if you want to keep records of players with stats and all it is better to use SQL instead. You can always output it to an XML file in order to make it interchangeable between applications. Use XML files to store static data that is required to be loaded only once. This is just my point of view.
  5. Actually searching in XML is slower than executing a query. I am just trying to point out that if you want to keep records of players with stats and all it is better to use SQL instead. You can always output it to an XML file in order to make it interchangeable between applications. Use XML files to store static data that is required to be loaded only once. This is just my point of view.
  6. I have some general advice regarding data storage. It's better to use SQL instead of XML when dealing with large amounts of records or nodes. As a general rule you should try to avoid using XML as a database.
  7. I have some general advice regarding data storage. It's better to use SQL instead of XML when dealing with large amounts of records or nodes. As a general rule you should try to avoid using XML as a database.
  8. 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)
  9. 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)
  10. The getCameraPosition function is purely client sided. You will have to teleport the vehicle server side and tell the client to start the camera check timer.
  11. The getCameraPosition function is purely client sided. You will have to teleport the vehicle server side and tell the client to start the camera check timer.
  12. Strange, because that should work. Maybe you must add brackets? ... if (not isPlayerInVehicle ( player )) then ...
  13. Strange, because that should work. Maybe you must add brackets? ... if (not isPlayerInVehicle ( player )) then ...
  14. Sorry for hijacking this thread but maybe a member of the development team can answer this for me. Is it not easier to synchronize the casino games instead of having members scripting it? I do not mean to offend the thread starter. I really like the idea of having casino games. But this feels like reinventing the wheel. If this has already been answered somewhere down the line you can just ignore this post.
  15. Sorry for hijacking this thread but maybe a member of the development team can answer this for me. Is it not easier to synchronize the casino games instead of having members scripting it? I do not mean to offend the thread starter. I really like the idea of having casino games. But this feels like reinventing the wheel. If this has already been answered somewhere down the line you can just ignore this post.
  16. Yes, the logical operator is correct. However your syntax is wrong (parentheses is missing). It should be: client if not isPlayerInVehicle() then -- end server if not isPlayerInVehicle(player) then -- end
  17. Yes, the logical operator is correct. However your syntax is wrong (parentheses is missing). It should be: client if not isPlayerInVehicle() then -- end server if not isPlayerInVehicle(player) then -- end
  18. Here is an alternative (maybe cleaner) method to prevent vehicle from being catapulted into the air. Your method works as well but could cause problems on slow computers. I have noticed that the catapulting is related to the streaming of world objects. When objects are not fully streamed in the vehicle is catapulted more often. What happens on slow computers is that the camera is not close enough to the vehicle when your method unfreezes it. The following code may prevent that from happening. client function trackcam(vehicle) local x, y, z = getElementPosition(vehicle) local cx, cy, cz = getCameraPosition() local dist = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) if (dist < 25.0) then setVehicleFrozen(vehicle, false) else setTimer(trackcam, 50, 1, vehicle) end end function yourtpfunc() -- teleport the vehicle trackcam(vehicle) end Why do you need a function that says you are not in a vehicle when that is exactly what the isPlayerInVehicle function does?
  19. Here is an alternative (maybe cleaner) method to prevent vehicle from being catapulted into the air. Your method works as well but could cause problems on slow computers. I have noticed that the catapulting is related to the streaming of world objects. When objects are not fully streamed in the vehicle is catapulted more often. What happens on slow computers is that the camera is not close enough to the vehicle when your method unfreezes it. The following code may prevent that from happening. client function trackcam(vehicle) local x, y, z = getElementPosition(vehicle) local cx, cy, cz = getCameraPosition() local dist = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) if (dist < 25.0) then setVehicleFrozen(vehicle, false) else setTimer(trackcam, 50, 1, vehicle) end end function yourtpfunc() -- teleport the vehicle trackcam(vehicle) end Why do you need a function that says you are not in a vehicle when that is exactly what the isPlayerInVehicle function does?
  20. You got the syntax wrong. ID is a separate parameter and should be defined as follows: "samsite1" object model="4866" posX="-542.96350097656" posY="886.63665771484" posZ="2.7947807312012" rotX="0.5" rotY="0.5" rotZ="75"/> Notice the id instead of objectID. This should work. This is also correct: oSAM = createObject(3884, x, y, z) -- SAM site object Edit: You can use the testTargetAngleAgainstLoS as a 2D look at function as well. Just add angle as return value to get the rotation needed to make an object face a particular target.
  21. You got the syntax wrong. ID is a separate parameter and should be defined as follows: "samsite1" object model="4866" posX="-542.96350097656" posY="886.63665771484" posZ="2.7947807312012" rotX="0.5" rotY="0.5" rotZ="75"/> Notice the id instead of objectID. This should work. This is also correct: oSAM = createObject(3884, x, y, z) -- SAM site object Edit: You can use the testTargetAngleAgainstLoS as a 2D look at function as well. Just add angle as return value to get the rotation needed to make an object face a particular target.
  22. I don't like the CEGUI at all, it's fugly. I prefer the original SA dialogs and fonts.
  23. I don't like the CEGUI at all, it's fugly. I prefer the original SA dialogs and fonts.
  24. That's great. And you can also make them shoot: http://development.mtasa.com/index.php? ... ntrolState Now all we need is a function to make them target client players .
  25. That's great. And you can also make them shoot: http://development.mtasa.com/index.php? ... ntrolState Now all we need is a function to make them target client players .
×
×
  • Create New...