Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Author: Azller Lollison (in public this source is missing)
- local sampev = require "lib.samp.events"
- local memory = require "memory"
- local onFootSpeed = 2.0
- local inCarSpeed = 4.0
- function getCameraPositionUnfixed()
- return memory.getfloat(0xB6F248), memory.getfloat(0xB6F258)
- end
- function main()
- while not isSampAvailable() do wait(0) end
- sampRegisterChatCommand("fly", function() flyActivated = not flyActivated; sampAddChatMessage(flyActivated and "Activated" or "Offline", -1) end)
- sampRegisterChatCommand("slap", function(id) target = tonumber(id) slapActivated = not slapActivated; sampAddChatMessage(slapActivated and "Activated" or "Offline", -1) end)
- while true do wait(0)
- if isKeyDown(18) and flyActivated then
- if not isCharInAnyCar(PLAYER_PED) then
- local x, y, z = getCharCoordinates(PLAYER_PED)
- freezeCharPosition(PLAYER_PED, true);
- sampForceOnfootSync(); wait(0)
- if isKeyDown(87) then
- local xAngle, zAngle = getCameraPositionUnfixed()
- setCharHeading(PLAYER_PED, math.deg(zAngle + math.pi / 2))
- setCharCoordinatesDontResetAnim(PLAYER_PED, x - onFootSpeed * math.cos(zAngle), y - onFootSpeed * math.sin(zAngle), z)
- end
- if isKeyDown(83) then
- local xAngle, zAngle = getCameraPositionUnfixed()
- setCharHeading(PLAYER_PED, math.deg(zAngle + math.pi / 2))
- setCharCoordinatesDontResetAnim(PLAYER_PED, x + onFootSpeed * math.cos(zAngle), y + onFootSpeed * math.sin(zAngle), z)
- end
- if isKeyDown(49) then
- setCharCoordinatesDontResetAnim(PLAYER_PED, x, y, z + 1.5)
- end
- if isKeyDown(50) then
- setCharCoordinatesDontResetAnim(PLAYER_PED, x, y, z - 1.5)
- end
- if isKeyDown(107) then
- onFootSpeed = onFootSpeed + 0.1
- printStringNow("~r~OnFoot speed: ~w~"..onFootSpeed, 1000)
- end
- if isKeyDown(109) then
- onFootSpeed = onFootSpeed - 0.1
- printStringNow("~r~OnFoot speed: ~w~"..onFootSpeed, 1000)
- end
- freezeCharPosition(PLAYER_PED, false)
- sampForceOnfootSync()
- else
- local handle = storeCarCharIsInNoSave(PLAYER_PED)
- freezeCarPosition(handle, true)
- local x, y, z = getCarCoordinates(handle)
- _, id = sampGetVehicleIdByCarHandle(handle)
- if getDriverOfCar(handle) == 1 then
- sampForceVehicleSync(id); sampForceVehicleSync(id);
- else
- local seatId = getPlayerSeatId(PLAYER_PED);
- sampForcePassengerSyncSeatId(id, seatId); sampForceUnoccupiedSyncSeatId(id, seatId)
- end
- if isKeyDown(87) then
- local xAngle, zAngle = getCameraPositionUnfixed()
- setCarHeading(handle, math.deg(zAngle + math.pi / 2))
- setCarCoordinates(handle, x - inCarSpeed * math.cos(zAngle), y - inCarSpeed * math.sin(zAngle), z)
- end
- if isKeyDown(83) then
- local xAngle, zAngle = getCameraPositionUnfixed()
- setCarHeading(handle, math.deg(zAngle + math.pi / 2))
- setCarCoordinates(handle, x + inCarSpeed * math.cos(zAngle), y + inCarSpeed * math.sin(zAngle), z)
- end
- if isKeyDown(49) then
- setCarCoordinates(handle, x, y, z + 3)
- end
- if isKeyDown(50) then
- setCarCoordinates(handle, x, y, z - 3)
- end
- if isKeyDown(107) then
- inCarSpeed = inCarSpeed + 0.1
- printStringNow("~r~InCar speed: ~w~"..inCarSpeed, 1000)
- end
- if isKeyDown(109) then
- inCarSpeed = inCarSpeed - 0.1
- printStringNow("~r~InCar speed: ~w~"..inCarSpeed, 1000)
- end
- freezeCarPosition(handle, false)
- end
- end
- end
- wait(-1)
- end
- function getPlayerSeatId(handle)
- if result and isCharInAnyCar(handle) then
- local car = storeCarCharIsInNoSave(ped)
- for i = 0, getMaximumNumberOfPassengers(car) do
- if not isCarPassengerSeatFree(car, i) and getCharInCarPassengerSeat(car, i) == ped then
- return i -- seat id
- end
- end
- end
- return nil
- end
- function setCharCoordinatesDontResetAnim(char, x, y, z)
- if doesCharExist(char) then
- local ptr = getCharPointer(char)
- setEntityCoordinates(ptr, x, y, z)
- end
- end
- function setCarCoordinates(car, x, y, z)
- local ptr = getCarPointer(car)
- setEntityCoordinates(ptr, x, y, z)
- end
- function setEntityCoordinates(entityPtr, x, y, z)
- if entityPtr ~= 0 then
- local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
- if matrixPtr ~= 0 then
- local posPtr = matrixPtr + 0x30
- writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) --X
- writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) --Y
- writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) --Z
- end
- end
- end
- function sampev.onSendUnoccupiedSync(data)
- if flyActivated and isKeyDown(18) then
- if data.vehicleId == id then
- data.moveSpeed.z = -1.5;
- data.turnSpeed = {x = 0.1, y = 0.1, z = 0.1}
- data.roll = {x = 0.1, y = 0.1, z = 0.1}
- end
- end
- end
- function FindRandomVehInSphere()
- local x, y, z = getCharCoordinates(PLAYER_PED)
- local res, veh = findAllRandomVehiclesInSphere(x, y, z, 5000.0, true, false)
- if res then
- local res, id = sampGetVehicleIdByCarHandle(veh)
- if res then return id, x, y, z else return -1, x, y, z end
- end
- end
- function sampev.onSetPlayerPos()
- if flyActivated then return false end
- end
- function sampev.onSetPlayerPosFindZ()
- if flyActivated then return false end
- end
- function sampev.onApplyPlayerAnimation()
- if flyActivated then return false end
- end
- function sampev.onClearPlayerAnimation()
- if flyActivated then return false end
- end
- function sampev.onSendPlayerSync(data)
- if flyActivated then
- data.animationId = 1538;
- data.animationFlags = 32772;
- if isKeyDown(18) then
- data.moveSpeed.x = 0.1;
- data.moveSpeed.y = 0.1;
- data.moveSpeed.z = 0.135;
- data.keysData = 0;
- local v_id, x, y, z = FindRandomVehInSphere()
- if v_id ~= -1 and v_id ~= nil then
- onFootSpeed = 4.1
- -- sampAddChatMessage(string.format('surfing veh = %d', v_id), -1)
- data.surfingVehicleId = v_id
- data.surfingOffsets = {x = x, y = y, z = z}
- else onFootSpeed = 2.5 end
- end
- end
- end
- function sampev.onSendVehicleSync(data)
- if flyActivated and isKeyDown(18) then
- data.moveSpeed.z = -0.1;
- end
- if isKeyDown(16) and slapActivated then
- local res, handle = sampGetCharHandleBySampPlayerId(target)
- if res then
- sampAddChatMessage("Ebanulo 1", -1)
- local x1, y1, z1 = getCharCoordinates(handle)
- data.position = {x = x1, y = y1, z = z1 + 1.0}
- data.moveSpeed.x = -0.1
- data.moveSpeed.z = -1.0
- end
- end
- end
- function sampev.onSetVehicleVelocity()
- if flyActivated then print("Noped"); return false end
- end
Add Comment
Please, Sign In to add comment