Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local events = require 'lib.samp.events'
- CarTp = false
- function main()
- repeat wait(0) until isSampAvailable();
- sampRegisterChatCommand("arztp",
- function()
- result, x, y, z = getTargetBlipCoordinatesFixed()
- if result then
- if isCharInAnyCar(PLAYER_PED) then
- lua_thread.create(carTeleport, x, y, z)
- else
- lua_thread.create(teleport, x, y, z)
- end
- else
- printStringNow("~>~ ~r~marker not found ~<~", 2500)
- end
- end)
- sampRegisterChatCommand("arztpc",
- function()
- result, x, y, z = SearchMarker(getCharCoordinates(PLAYER_PED))
- if result then
- if isCharInAnyCar(PLAYER_PED) then
- lua_thread.create(carTeleport, x, y, z)
- else
- lua_thread.create(teleport, x, y, z)
- end
- else
- printStringNow("~>~ ~r~checkpoint not found ~<~", 2500)
- end
- end)
- wait(-1)
- end
- function carTeleport(x, y, z)
- CarTp = true
- nopHook("onSendUnoccupiedSync", true)
- nopHook("onSendPassengerSync", true)
- nopHook("onSendVehicleSync", true)
- lockPlayerControl(true)
- coordmaster(x, y, z)
- end
- function teleport(x, y, z)
- nopHook("onSendPlayerSync", true)
- nopHook("onSetPlayerPos", true)
- lockPlayerControl(true)
- coordmaster(x, y, z)
- end
- function sendOnfootSync(x, y, z)
- local data = allocateMemory(68)
- local _, pId = sampGetPlayerIdByCharHandle(PLAYER_PED)
- sampStorePlayerOnfootData(pId, data)
- setStructFloatElement(data, 6, x, false)
- setStructFloatElement(data, 10, y, false)
- setStructFloatElement(data, 14, z, false)
- setStructFloatElement(data, 38, 0.9, false)
- setStructFloatElement(data, 42, 0.9, false)
- setStructFloatElement(data, 46, -0.9, false)
- sampSendOnfootData(data)
- freeMemory(data)
- end
- function sendSpectatorSync(x, y, z)
- local data = allocateMemory(20)
- setStructElement(data, 0, 2, 0, false)
- setStructElement(data, 2, 2, 0, false)
- setStructElement(data, 4, 2, 0, false)
- setStructFloatElement(data, 6, x, false)
- setStructFloatElement(data, 10, y, false)
- setStructFloatElement(data, 14, z, false)
- sampSendSpectatorData(data)
- freeMemory(data)
- end
- function sendPassengerSync(x, y, z)
- local data = allocateMemory(24)
- local _, pId = sampGetPlayerIdByCharHandle(PLAYER_PED)
- sampStorePlayerPassengerData(pId, data)
- setStructElement(data, 2, 1, 1, false)
- setStructFloatElement(data, 12, x, false)
- setStructFloatElement(data, 16, y, false)
- setStructFloatElement(data, 20, z, false)
- sampSendPassengerData(data)
- freeMemory(data)
- end
- function sendUnoccupiedSyncBySeatId(x, y, z, seatId)
- local data = allocateMemory(67)
- local car = storeCarCharIsInNoSave(PLAYER_PED)
- local _, vehicleId = sampGetVehicleIdByCarHandle(car)
- local rx, ry, rz = getCarRoll(car)
- setStructElement(data, 0, 2, vehicleId, false)
- setStructElement(data, 2, 1, seatId, false)
- -- roll
- setStructFloatElement(data, 3, rx, false)
- setStructFloatElement(data, 7, ry, false)
- setStructFloatElement(data, 11, rz, false)
- -- direction
- setStructFloatElement(data, 15, 0.09, false)
- setStructFloatElement(data, 19, -0.8, false)
- setStructFloatElement(data, 23, 0.02, false)
- -- position
- setStructFloatElement(data, 27, x, false)
- setStructFloatElement(data, 31, y, false)
- setStructFloatElement(data, 35, z, false)
- -- speed
- setStructFloatElement(data, 39, 0.0012, false)
- setStructFloatElement(data, 43, 0.02, false)
- setStructFloatElement(data, 47, 0.0017, false)
- -- turning speed
- setStructFloatElement(data, 51, 0.005, false)
- setStructFloatElement(data, 55, -0.002, false)
- setStructFloatElement(data, 59, 0.3, false)
- -- car health
- setStructElement(data, 63, 4, 0, false)
- sampSendUnoccupiedData(data)
- freeMemory(data)
- end
- function sendOnFootFakePosition(x, y, z)
- for i = 0, 2 do
- sendOnfootSync(x, y, z)
- sendSpectatorSync(x, y, z)
- end
- end
- function sendInCarFakePosition(x, y, z)
- for i = 0, 2 do
- local data = allocateMemory(24)
- local _, pId = sampGetPlayerIdByCharHandle(PLAYER_PED)
- sampStorePlayerPassengerData(pId, data)
- local seatId = getStructElement(data, 2, 1, false)
- freeMemory(data)
- sendUnoccupiedSyncBySeatId(x, y, z, seatId)
- sendPassengerSync(x, y, z)
- end
- end
- function coordmaster(x, y, z)
- if CarTp then
- local step = 10
- local car = storeCarCharIsInNoSave(PLAYER_PED)
- local cx, cy, cz = getCarCoordinates(car)
- local angle = getAngle(cx, cy, x, y)
- while true do
- wait(0)
- printStringNow("~Y~please wait~s~", 50)
- if getDistanceBetweenCoords2d(cx, cy, x, y) > step then
- cx = cx + math.sin(angle) * step
- cy = cy + math.cos(angle) * step
- sendInCarFakePosition(cx, cy, cz)
- else
- sendInCarFakePosition(x, y, z)
- setCarCoordinates(car, x, y, z)
- nopHook("onSendUnoccupiedSync", false)
- nopHook("onSendPassengerSync", false)
- lockPlayerControl(false)
- CarTp = false
- printStringNow("~>~ ~p~successful ~s~teleport ~<~",2500)
- addOneOffSound(0.0, 0.0, 0.0, 1139)
- break
- end
- end
- else
- local step = 30
- local cx, cy, cz = getCharCoordinates(PLAYER_PED)
- local angle = getAngle(cx, cy, x, y)
- while true do
- wait(0)
- printStringNow("~Y~please wait~s~", 50)
- if getDistanceBetweenCoords2d(cx, cy, x, y) > step then
- cx = cx + math.sin(angle) * step
- cy = cy + math.cos(angle) * step
- sendOnFootFakePosition(cx, cy, cz)
- else
- sendOnFootFakePosition(x, y, z + 55)
- setCharCoordinates(PLAYER_PED, x, y, z)
- wait(250)
- nopHook("onSendPlayerSync", false)
- nopHook("onSetPlayerPos", false)
- lockPlayerControl(false)
- printStringNow("~>~ ~p~successful ~s~teleport ~<~",2500)
- addOneOffSound(0.0, 0.0, 0.0, 1139)
- break
- end
- end
- end
- end
- function getAngle(x1, y1, x2, y2)
- return math.atan2(x2 - x1, y2 - y1);
- end
- function nopHook(name, bool)
- local samp = require 'samp.events'
- samp[name] = function()
- if bool then
- return false
- end
- end
- end
- function getTargetBlipCoordinatesFixed()
- local bool, x, y, z = getTargetBlipCoordinates()
- if not bool then
- return false
- end
- requestCollision(x, y)
- loadScene(x, y, z)
- local bool, x, y, z = getTargetBlipCoordinates()
- return bool, x, y, z
- end
- function SearchMarker(posX, posY, posZ)
- local ret_posX = 0.0
- local ret_posY = 0.0
- local ret_posZ = 0.0
- local isFind = false
- for id = 0, 31 do
- local MarkerStruct = 0
- MarkerStruct = 0xC7F168 + id * 56
- local MarkerPosX = representIntAsFloat(readMemory(MarkerStruct + 0, 4, false))
- local MarkerPosY = representIntAsFloat(readMemory(MarkerStruct + 4, 4, false))
- local MarkerPosZ = representIntAsFloat(readMemory(MarkerStruct + 8, 4, false))
- if MarkerPosX ~= 0.0 or MarkerPosY ~= 0.0 or MarkerPosZ ~= 0.0 then
- ret_posX = MarkerPosX
- ret_posY = MarkerPosY
- ret_posZ = MarkerPosZ
- isFind = true
- end
- end
- return isFind, ret_posX, ret_posY, ret_posZ
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement