[İSTEK] Sinema Koltuğuna Oturma Script

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı ulusoy

  • Yeni Üye
  • *
    • İleti: 50
Öncelikle herkese iyi günler .

Google üzerinde çok araştırdım bu konuyu ve en son olarak bu forum sitesini buldum yardım edebiliceğinizi düşünüyorum her neyse konuya gelelim.

Ben bir sinema salonu oluşturdum ve koyduğum koltuklara oyuncular geldiğinde oturabilmelerini istiyorum.

Kafamdaki fikir şu yönde ; koltuğun önünde marker var oyuncu 1 numaralı marker'e geldiğinde ekranın ortasında oturmak için 'c' tuşuna basın yazısı olsun c ye tıkladığımızda 1 numaralı 1562 id'li koltuğun pozisyonuna "ped" animasyon katagorisinden "SEAT_idle" animasyonu ile oturabilsin ve hudlar kapanıp fp moduna geçilsin. Bu konuda yardımcı olursanız sevinirim.
« Son Düzenleme: 12 Mart 2018, 19:20:45 Gönderen: Narkoz »
 


MTASATURK

[İSTEK] Sinema Koltuğuna Oturma Script
« : 12 Mart 2018, 14:28:31 »

Çevrimdışı MarkeloF

  • Admin
  • *
    • İleti: 901
  • Maybe later.
Yanıtla #1 : 12 Mart 2018, 15:09:38
Neden bu kadar abartıyorsun ki? Gereksiz bir kalabalık olur bence. /otur ve /kalk scirptini indir hem yer kaplamaz hemde isteyen istediği yere oturur önerim
 


Çevrimdışı ulusoy

  • Yeni Üye
  • *
    • İleti: 50
Yanıtla #2 : 12 Mart 2018, 15:31:04
Linki görebilmek için Kayıt olun yada Giriş yapın.
Neden bu kadar abartıyorsun ki? Gereksiz bir kalabalık olur bence. /otur ve /kalk scirptini indir hem yer kaplamaz hemde isteyen istediği yere oturur önerim

tabikide öyle , atıyorum 20 koltuk var salona birisi geldi istediği koltuğu seçti önüne gitti /otur dedi mesela koltuğa oturdu yada c butonuna bastı oturdu misal marker ile bunu yapmak ne kadar mümkün bilemiyorum.
 


Çevrimdışı Mahlukat

  • Uzman Üye
  • *
    • İleti: 637
Yanıtla #3 : 12 Mart 2018, 15:36:37
İnce ayarları yaptıktan sonra atarım kodları

Spoiler for Hiden:


Linki görebilmek için Kayıt olun yada Giriş yapın.
 


Çevrimdışı ulusoy

  • Yeni Üye
  • *
    • İleti: 50
Yanıtla #4 : 12 Mart 2018, 15:43:52
Linki görebilmek için Kayıt olun yada Giriş yapın.
İnce ayarları yaptıktan sonra atarım kodları

Spoiler for Hiden:



Çok teşekkür ederim ,hakkınızı helal edin.
 


Çevrimdışı Mahlukat

  • Uzman Üye
  • *
    • İleti: 637
Yanıtla #5 : 12 Mart 2018, 16:03:30
hud ve radar olarak standart olanımı kullanıyosun yoksa başka mı ?
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


MTASATURK

Ynt: [İSTEK]Sinema Koltuğuna Oturma Script
« Yanıtla #5 : 12 Mart 2018, 16:03:30 »

Çevrimdışı ulusoy

  • Yeni Üye
  • *
    • İleti: 50
Yanıtla #6 : 12 Mart 2018, 16:14:31
Linki görebilmek için Kayıt olun yada Giriş yapın.
hud ve radar olarak standart olanımı kullanıyosun yoksa başka mı ?
hud standart radar script
 


Çevrimdışı Mahlukat

  • Uzman Üye
  • *
    • İleti: 637
Yanıtla #7 : 12 Mart 2018, 16:20:42
O halde sadece hudu gizleyebilirim :/ veya ekrandaki herşeyi gizlerim(chat de dahil) seç birini sana kalmış
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


Çevrimdışı ByCash

  • Admin
  • *
    • İleti: 986
Yanıtla #8 : 12 Mart 2018, 16:21:52
Linki görebilmek için Kayıt olun yada Giriş yapın.
O halde sadece hudu gizleyebilirim :/ veya ekrandaki herşeyi gizlerim(chat de dahil) seç birini sana kalmış
Aslında radar scriptini atarsa gizleyebiliriz
 


Çevrimdışı Mahlukat

  • Uzman Üye
  • *
    • İleti: 637
Yanıtla #9 : 12 Mart 2018, 16:22:55
Linki görebilmek için Kayıt olun yada Giriş yapın.
Aslında radar scriptini atarsa gizleyebiliriz
+1
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


Çevrimdışı ulusoy

  • Yeni Üye
  • *
    • İleti: 50
Yanıtla #10 : 12 Mart 2018, 16:24:24
Linki görebilmek için Kayıt olun yada Giriş yapın.
Aslında radar scriptini atarsa gizleyebiliriz

Linki görebilmek için Kayıt olun yada Giriş yapın.
 


Çevrimdışı Mahlukat

  • Uzman Üye
  • *
    • İleti: 637
Yanıtla #11 : 12 Mart 2018, 16:38:25
server.lua
Kod: lua
koltuklar = {-- objeId, x, y, z, rotationX, rotationY, rotationZ
--Koltuklar tek sıra halinde olursa yani hepsinin rotasyonları aynı olursa daha iyi olur.
--Rotasyonları ayrı ayrı olursa oyuncu koltuğa oturduğunda rotasyonu düz olmayabilir :c
-- Aşşağılarda bir yer daha işaretledim. Objenin rotationZ değeri 0 ise o işaretlediğm yer 180 olcak
-- 0 dan başka ise kendin deneyerek bulmalısın oraya ne yazılcağını :c
{1562, 2308, 582, 7.5, 0, 0, 0},
{1562, 2308, 584, 7.5, 0, 0, 0},
{1562, 2308, 586, 7.5, 0, 0, 0},

{1562, 2310, 582, 7.5, 0, 0, 0},
{1562, 2310, 584, 7.5, 0, 0, 0},
{1562, 2310, 586, 7.5, 0, 0, 0},
}

tablo = {}

function alanaGirince(giren)
if getElementType(giren) == "player" then
triggerClientEvent(giren, "addRender", giren, tablo[source].numara)
toggleControl(giren, "crouch", false)
end
end

function alandanCikinca(cikan)
if getElementType(cikan) == "player" then
triggerClientEvent(cikan, "removeRender", cikan)
toggleControl(cikan, "crouch", true)
if tablo[source].oturan == cikan then
tablo[alan].oturan = "server"
triggerClientEvent(cikan,"herSeyiGizle", cikan, "Gizleme")
end
end
end

for i,v in pairs(koltuklar) do
local ID,x,y,z,rx,ry,rz = unpack(v)
local koltuk = createObject(ID,x,y,z,rx,ry,rz)
local alan = createColSphere(x,y,z, 1.1)
tablo[alan] = {}
tablo[alan].koltuk = koltuk
tablo[alan].numara = i
tablo[alan].oturan = "Bos"
addEventHandler("onColShapeHit", alan, alanaGirince)
addEventHandler("onColShapeLeave", alan, alandanCikinca)
end


function otur(oyuncu)
for i,alan in pairs(getElementsByType("colshape", resourceRoot)) do
if tablo[alan] then
if isElementWithinColShape(oyuncu, alan) then
if tablo[alan].oturan == oyuncu then
setPedAnimation(oyuncu)
tablo[alan].oturan = "Bos"
triggerClientEvent(oyuncu,"herSeyiGizle", oyuncu, "Gizleme")
executeCommandHandler ( "fp", oyuncu )
return
end
if tablo[alan].oturan == "Bos" then
local x,y,z = getElementPosition(tablo[alan].koltuk)
local px,py,pz = getElementPosition(oyuncu)
local rx,ry,rz = getElementRotation(oyuncu)
setElementPosition(oyuncu, x,y-0.5,z)
setElementRotation(oyuncu, rx,ry,180) -- Oyuncu koltuğa oturduğunda oyuncunun rotasyonunu ayarlıyoruz.
setPedAnimation( oyuncu, "ped", "SEAT_idle", false, false, false)
tablo[alan].oturan = oyuncu
tablo[oyuncu] = alan
triggerClientEvent(oyuncu,"removeRender", oyuncu)
triggerClientEvent(oyuncu,"herSeyiGizle", oyuncu, "Gizle")
end
end
end
end
end

addEventHandler("onPlayerQuit", root, function()
if tablo[oyuncu] then
local alan = tablo[oyuncu]
if tablo[alan].oturan == source then
tablo[alan].oturan = "Bos"
end
end
end)

addEventHandler("onResourceStart", resourceRoot, function()
for i,v in pairs(getElementsByType("player")) do
bindKey(v, "c", "down", otur)
end
end)

addEventHandler("onPlayerJoin", root, function()
bindKey(source, "c", "down", otur)
end)

client.lua
Kod: lua
-- orta yazi
local sx, sy = guiGetScreenSize ( )
local numara
local isEnabled = false

addEvent("removeRender", true)
addEventHandler("removeRender", root, function()
removeEventHandler ( "onClientRender", root, render )
end)

addEvent("addRender", true)
addEventHandler("addRender", root, function( n )
if n then
numara = n
end
if getElementType(source) == "player" and source == localPlayer then
removeEventHandler ( "onClientRender", root, render )
addEventHandler ( "onClientRender", root, render )
end
end)

function render ( )
    if not numara  then return end
dxDrawText (tostring(numara).." Numaralı koltuğa oturmak için 'C' tuşuna basınız.", 0, 0, (sx/1), (sy/1.5), tocolor ( 0, 0, 0, 255 ), 2.5, 'default-bold', 'center', 'bottom' )
dxDrawText (tostring(numara).." Numaralı koltuğa oturmak için 'C' tuşuna basınız.", 0, 0, sx/1, sy/1.5, tocolor ( 255, 255, 0, 255 ), 2.5, 'default-bold', 'center', 'bottom' )
end


bilesenler = {
"ammo", -- Mermi
"area_name", -- Alan ismi
"armour", -- Zırh
"breath", -- Nefes
"clock", -- Saat
"health", -- Can
"money", -- Para
"weapon", -- Silah
"radio",
"wanted", -- Aranma yıldızı
"radar", -- Aranma yıldızı
}

addEvent("herSeyiGizle", true)
addEventHandler("herSeyiGizle", root, function(durum)
if durum == "Gizle" then
isEnabled = true
addEventHandler ("onClientPreRender", root, updateCamera)
addEventHandler ("onClientCursorMove",root, freecamMouse)
hudRadarGizle(false)
elseif durum == "Gizleme" then
isEnabled = false
hudRadarGizle(true)
setCameraTarget (localPlayer, localPlayer)
removeEventHandler ("onClientPreRender", root, updateCamera)
removeEventHandler ("onClientCursorMove", root, freecamMouse)
end
end)


function hudRadarGizle(deger)
for _,v in ipairs(bilesenler)do
setPlayerHudComponentVisible( v, deger )
end
end


--fp modu

local root = getRootElement()
local localPlayer = getLocalPlayer()
local PI = math.pi

local wasInVehicle = isPedInVehicle(localPlayer)

local mouseSensitivity = 0.2
local rotX, rotY = 0,0
local mouseFrameDelay = 0
local idleTime = 2500
local fadeBack = false
local fadeBackFrames = 50
local executeCounter = 0
local recentlyMoved = false
local Xdiff,Ydiff
local radar = true

function toggleCockpitView ()
if (not isEnabled) then
isEnabled = true
addEventHandler ("onClientPreRender", root, updateCamera)
addEventHandler ("onClientCursorMove",root, freecamMouse)
radar = false
else --reset view
isEnabled = false
setCameraTarget (localPlayer, localPlayer)
removeEventHandler ("onClientPreRender", root, updateCamera)
removeEventHandler ("onClientCursorMove", root, freecamMouse)
radar = true
end
end
addCommandHandler("fp", toggleCockpitView)


function updateCamera ()
    if (isEnabled) then
    local nowTick = getTickCount()
if wasInVehicle and recentlyMoved and not fadeBack and startTick and nowTick - startTick > idleTime then
    recentlyMoved = false
    fadeBack = true
if rotX > 0 then
    Xdiff = rotX / fadeBackFrames
elseif rotX < 0 then
    Xdiff = rotX / -fadeBackFrames
end
if rotY > 0 then
    Ydiff = rotY / fadeBackFrames
elseif rotY < 0 then
    Ydiff = rotY / -fadeBackFrames
end
end

if fadeBack then
   
        executeCounter = executeCounter + 1

        if rotX > 0 then
        rotX = rotX - Xdiff
    elseif rotX < 0 then
        rotX = rotX + Xdiff
    end

    if rotY > 0 then
        rotY = rotY - Ydiff
    elseif rotY < 0 then
        rotY = rotY + Ydiff
    end

    if executeCounter >= fadeBackFrames then
        fadeBack = false
executeCounter = 0
    end

end

        local camPosXr, camPosYr, camPosZr = getPedBonePosition (localPlayer, 6)
        local camPosXl, camPosYl, camPosZl = getPedBonePosition (localPlayer, 7)
        local camPosX, camPosY, camPosZ = (camPosXr + camPosXl) / 2, (camPosYr + camPosYl) / 2, (camPosZr + camPosZl) / 2
        local roll = 0
       
        inVehicle = isPedInVehicle(localPlayer)
       
-- note the vehicle rotation
        if inVehicle then
    local rx,ry,rz = getElementRotation(getPedOccupiedVehicle(localPlayer))
           
    roll = -ry
    if rx > 90 and rx < 270 then
    roll = ry - 180
    end
           
            if not wasInVehicle then
                rotX = rotX + math.rad(rz) --prevent camera from rotation when entering a vehicle
                if rotY > -PI/15 then --force camera down if needed
                    rotY = -PI/15
                end
            end
           
    cameraAngleX = rotX - math.rad(rz)
    cameraAngleY = rotY + math.rad(rx)
           
            if getControlState("vehicle_look_behind") or ( getControlState("vehicle_look_right") and getControlState("vehicle_look_left") ) then
                cameraAngleX = cameraAngleX + math.rad(180)
                --cameraAngleY = cameraAngleY + math.rad(180)
            elseif getControlState("vehicle_look_left") then
                cameraAngleX = cameraAngleX - math.rad(90)
                --roll = rx doesn't work out well
            elseif getControlState("vehicle_look_right") then
                cameraAngleX = cameraAngleX + math.rad(90) 
                --roll = -rx
            end
        else
            local rx, ry, rz = getElementRotation(localPlayer)

            if wasInVehicle then
                rotX = rotX - math.rad(rz) --prevent camera from rotating when exiting a vehicle
            end
            cameraAngleX = rotX
            cameraAngleY = rotY
        end
       
        wasInVehicle = inVehicle

        --Taken from the freecam resource made by eAi
       
        -- work out an angle in radians based on the number of pixels the cursor has moved (ever)
       
        local freeModeAngleZ = math.sin(cameraAngleY)
        local freeModeAngleY = math.cos(cameraAngleY) * math.cos(cameraAngleX)
        local freeModeAngleX = math.cos(cameraAngleY) * math.sin(cameraAngleX)

        -- calculate a target based on the current position and an offset based on the angle
        local camTargetX = camPosX + freeModeAngleX * 100
        local camTargetY = camPosY + freeModeAngleY * 100
        local camTargetZ = camPosZ + freeModeAngleZ * 100

        -- Work out the distance between the target and the camera (should be 100 units)
        local camAngleX = camPosX - camTargetX
        local camAngleY = camPosY - camTargetY
        local camAngleZ = 0 -- we ignore this otherwise our vertical angle affects how fast you can strafe

        -- Calulcate the length of the vector
        local angleLength = math.sqrt(camAngleX*camAngleX+camAngleY*camAngleY+camAngleZ*camAngleZ)

        -- Normalize the vector, ignoring the Z axis, as the camera is stuck to the XY plane (it can't roll)
        local camNormalizedAngleX = camAngleX / angleLength
        local camNormalizedAngleY = camAngleY / angleLength
        local camNormalizedAngleZ = 0

        -- We use this as our rotation vector
        local normalAngleX = 0
        local normalAngleY = 0
        local normalAngleZ = 1

        -- Perform a cross product with the rotation vector and the normalzied angle
        local normalX = (camNormalizedAngleY * normalAngleZ - camNormalizedAngleZ * normalAngleY)
        local normalY = (camNormalizedAngleZ * normalAngleX - camNormalizedAngleX * normalAngleZ)
        local normalZ = (camNormalizedAngleX * normalAngleY - camNormalizedAngleY * normalAngleX)

        -- Update the target based on the new camera position (again, otherwise the camera kind of sways as the target is out by a frame)
        camTargetX = camPosX + freeModeAngleX * 100
        camTargetY = camPosY + freeModeAngleY * 100
        camTargetZ = camPosZ + freeModeAngleZ * 100

        -- Set the new camera position and target
        setCameraMatrix (camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ, roll)
    end
end

function freecamMouse (cX,cY,aX,aY)
if isCursorShowing() or isMTAWindowActive() then
mouseFrameDelay = 5
return
elseif mouseFrameDelay > 0 then
mouseFrameDelay = mouseFrameDelay - 1
return
end
startTick = getTickCount()
recentlyMoved = true
if fadeBack then
    fadeBack = false
executeCounter = 0
end
    local width, height = guiGetScreenSize()
    aX = aX - width / 2
    aY = aY - height / 2

    rotX = rotX + aX * mouseSensitivity * 0.01745
    rotY = rotY - aY * mouseSensitivity * 0.01745

    local pRotX, pRotY, pRotZ = getElementRotation (localPlayer)
    pRotZ = math.rad(pRotZ)
   
if rotX > PI then
rotX = rotX - 2 * PI
elseif rotX < -PI then
rotX = rotX + 2 * PI
end

if rotY > PI then
rotY = rotY - 2 * PI
elseif rotY < -PI then
rotY = rotY + 2 * PI
end
    if isPedInVehicle(localPlayer) then
        if rotY < -PI / 4 then
            rotY = -PI / 4
        elseif rotY > -PI/15 then
            rotY = -PI/15
        end
    else
        if rotY < -PI / 4 then
            rotY = -PI / 4
        elseif rotY > PI / 2.1 then
            rotY = PI / 2.1
        end
    end
end

Sorun olursa bu konu altından yazabilirsin  :P
« Son Düzenleme: 12 Mart 2018, 16:42:52 Gönderen: Mahlukat »
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


Çevrimdışı ulusoy

  • Yeni Üye
  • *
    • İleti: 50
Yanıtla #12 : 12 Mart 2018, 16:42:08
Linki görebilmek için Kayıt olun yada Giriş yapın.
server.lua
Kod: lua
koltuklar = {-- objeId, x, y, z, rotationX, rotationY, rotationZ
--Koltuklar tek sıra halinde olursa yani hepsinin rotasyonları aynı olursa daha iyi olur.
--Rotasyonları ayrı ayrı olursa oyuncu koltuğa oturduğunda rotasyonu düz olmayabilir :c
-- Aşşağılarda bir yer daha işaretledim. Objenin rotationZ değeri 0 ise o işaretlediğm yer 180 olcak
-- 0 dan başka ise kendin deneyerek bulmalısın oraya ne yazılcağını :c
{1562, 2308, 582, 7.5, 0, 0, 0},
{1562, 2308, 584, 7.5, 0, 0, 0},
{1562, 2308, 586, 7.5, 0, 0, 0},

{1562, 2310, 582, 7.5, 0, 0, 0},
{1562, 2310, 584, 7.5, 0, 0, 0},
{1562, 2310, 586, 7.5, 0, 0, 0},
}

tablo = {}

function alanaGirince(giren)
if getElementType(giren) == "player" then
triggerClientEvent(giren, "addRender", giren, tablo[source].numara)
toggleControl(giren, "crouch", false)
end
end

function alandanCikinca(cikan)
if getElementType(cikan) == "player" then
triggerClientEvent(cikan, "removeRender", cikan)
toggleControl(cikan, "crouch", true)
if tablo[source].oturan == cikan then
tablo[alan].oturan = "server"
triggerClientEvent(cikan,"herSeyiGizle", cikan, "Gizleme")
end
end
end

for i,v in pairs(koltuklar) do
local ID,x,y,z = unpack(v)
local koltuk = createObject(ID,x,y,z)
local alan = createColSphere(x,y,z, 1.1)
tablo[alan] = {}
tablo[alan].koltuk = koltuk
tablo[alan].numara = i
tablo[alan].oturan = "Bos"
addEventHandler("onColShapeHit", alan, alanaGirince)
addEventHandler("onColShapeLeave", alan, alandanCikinca)
end


function otur(oyuncu)
for i,alan in pairs(getElementsByType("colshape", resourceRoot)) do
if tablo[alan] then
if isElementWithinColShape(oyuncu, alan) then
if tablo[alan].oturan == oyuncu then
setPedAnimation(oyuncu)
tablo[alan].oturan = "Bos"
triggerClientEvent(oyuncu,"herSeyiGizle", oyuncu, "Gizleme")
executeCommandHandler ( "fp", oyuncu )
return
end
if tablo[alan].oturan == "Bos" then
local x,y,z = getElementPosition(tablo[alan].koltuk)
local px,py,pz = getElementPosition(oyuncu)
local rx,ry,rz = getElementRotation(oyuncu)
setElementPosition(oyuncu, x,y-0.5,z)
setElementRotation(oyuncu, rx,ry,180) -- Oyuncu koltuğa oturduğunda oyuncunun rotasyonunu ayarlıyoruz.
setPedAnimation( oyuncu, "ped", "SEAT_idle", false, false, false)
tablo[alan].oturan = oyuncu
tablo[oyuncu] = alan
triggerClientEvent(oyuncu,"removeRender", oyuncu)
triggerClientEvent(oyuncu,"herSeyiGizle", oyuncu, "Gizle")
end
end
end
end
end

addEventHandler("onPlayerQuit", root, function()
if tablo[oyuncu] then
local alan = tablo[oyuncu]
if tablo[alan].oturan == source then
tablo[alan].oturan = "Bos"
end
end
end)

addEventHandler("onResourceStart", resourceRoot, function()
for i,v in pairs(getElementsByType("player")) do
bindKey(v, "c", "down", otur)
end
end)

addEventHandler("onPlayerJoin", root, function()
bindKey(source, "c", "down", otur)
end)

client.lua
Kod: lua
-- orta yazi
local sx, sy = guiGetScreenSize ( )
local numara
local isEnabled = false

addEvent("removeRender", true)
addEventHandler("removeRender", root, function()
removeEventHandler ( "onClientRender", root, render )
end)

addEvent("addRender", true)
addEventHandler("addRender", root, function( n )
if n then
numara = n
end
if getElementType(source) == "player" and source == localPlayer then
removeEventHandler ( "onClientRender", root, render )
addEventHandler ( "onClientRender", root, render )
end
end)

function render ( )
    if not numara  then return end
dxDrawText (tostring(numara).." Numaralı koltuğa oturmak için 'C' tuşuna basınız.", 0, 0, (sx/1), (sy/1.5), tocolor ( 0, 0, 0, 255 ), 2.5, 'default-bold', 'center', 'bottom' )
dxDrawText (tostring(numara).." Numaralı koltuğa oturmak için 'C' tuşuna basınız.", 0, 0, sx/1, sy/1.5, tocolor ( 255, 255, 0, 255 ), 2.5, 'default-bold', 'center', 'bottom' )
end


bilesenler = {
"ammo", -- Mermi
"area_name", -- Alan ismi
"armour", -- Zırh
"breath", -- Nefes
"clock", -- Saat
"health", -- Can
"money", -- Para
"weapon", -- Silah
"radio",
"wanted", -- Aranma yıldızı
"radar", -- Aranma yıldızı
}

addEvent("herSeyiGizle", true)
addEventHandler("herSeyiGizle", root, function(durum)
if durum == "Gizle" then
isEnabled = true
addEventHandler ("onClientPreRender", root, updateCamera)
addEventHandler ("onClientCursorMove",root, freecamMouse)
hudRadarGizle(false)
elseif durum == "Gizleme" then
isEnabled = false
hudRadarGizle(true)
setCameraTarget (localPlayer, localPlayer)
removeEventHandler ("onClientPreRender", root, updateCamera)
removeEventHandler ("onClientCursorMove", root, freecamMouse)
end
end)


function hudRadarGizle(deger)
for _,v in ipairs(bilesenler)do
setPlayerHudComponentVisible( v, deger )
end
end


--fp modu

local root = getRootElement()
local localPlayer = getLocalPlayer()
local PI = math.pi

local wasInVehicle = isPedInVehicle(localPlayer)

local mouseSensitivity = 0.2
local rotX, rotY = 0,0
local mouseFrameDelay = 0
local idleTime = 2500
local fadeBack = false
local fadeBackFrames = 50
local executeCounter = 0
local recentlyMoved = false
local Xdiff,Ydiff
local radar = true

function toggleCockpitView ()
if (not isEnabled) then
isEnabled = true
addEventHandler ("onClientPreRender", root, updateCamera)
addEventHandler ("onClientCursorMove",root, freecamMouse)
radar = false
else --reset view
isEnabled = false
setCameraTarget (localPlayer, localPlayer)
removeEventHandler ("onClientPreRender", root, updateCamera)
removeEventHandler ("onClientCursorMove", root, freecamMouse)
radar = true
end
end
addCommandHandler("fp", toggleCockpitView)


function updateCamera ()
    if (isEnabled) then
    local nowTick = getTickCount()
if wasInVehicle and recentlyMoved and not fadeBack and startTick and nowTick - startTick > idleTime then
    recentlyMoved = false
    fadeBack = true
if rotX > 0 then
    Xdiff = rotX / fadeBackFrames
elseif rotX < 0 then
    Xdiff = rotX / -fadeBackFrames
end
if rotY > 0 then
    Ydiff = rotY / fadeBackFrames
elseif rotY < 0 then
    Ydiff = rotY / -fadeBackFrames
end
end

if fadeBack then
   
        executeCounter = executeCounter + 1

        if rotX > 0 then
        rotX = rotX - Xdiff
    elseif rotX < 0 then
        rotX = rotX + Xdiff
    end

    if rotY > 0 then
        rotY = rotY - Ydiff
    elseif rotY < 0 then
        rotY = rotY + Ydiff
    end

    if executeCounter >= fadeBackFrames then
        fadeBack = false
executeCounter = 0
    end

end

        local camPosXr, camPosYr, camPosZr = getPedBonePosition (localPlayer, 6)
        local camPosXl, camPosYl, camPosZl = getPedBonePosition (localPlayer, 7)
        local camPosX, camPosY, camPosZ = (camPosXr + camPosXl) / 2, (camPosYr + camPosYl) / 2, (camPosZr + camPosZl) / 2
        local roll = 0
       
        inVehicle = isPedInVehicle(localPlayer)
       
-- note the vehicle rotation
        if inVehicle then
    local rx,ry,rz = getElementRotation(getPedOccupiedVehicle(localPlayer))
           
    roll = -ry
    if rx > 90 and rx < 270 then
    roll = ry - 180
    end
           
            if not wasInVehicle then
                rotX = rotX + math.rad(rz) --prevent camera from rotation when entering a vehicle
                if rotY > -PI/15 then --force camera down if needed
                    rotY = -PI/15
                end
            end
           
    cameraAngleX = rotX - math.rad(rz)
    cameraAngleY = rotY + math.rad(rx)
           
            if getControlState("vehicle_look_behind") or ( getControlState("vehicle_look_right") and getControlState("vehicle_look_left") ) then
                cameraAngleX = cameraAngleX + math.rad(180)
                --cameraAngleY = cameraAngleY + math.rad(180)
            elseif getControlState("vehicle_look_left") then
                cameraAngleX = cameraAngleX - math.rad(90)
                --roll = rx doesn't work out well
            elseif getControlState("vehicle_look_right") then
                cameraAngleX = cameraAngleX + math.rad(90) 
                --roll = -rx
            end
        else
            local rx, ry, rz = getElementRotation(localPlayer)

            if wasInVehicle then
                rotX = rotX - math.rad(rz) --prevent camera from rotating when exiting a vehicle
            end
            cameraAngleX = rotX
            cameraAngleY = rotY
        end
       
        wasInVehicle = inVehicle

        --Taken from the freecam resource made by eAi
       
        -- work out an angle in radians based on the number of pixels the cursor has moved (ever)
       
        local freeModeAngleZ = math.sin(cameraAngleY)
        local freeModeAngleY = math.cos(cameraAngleY) * math.cos(cameraAngleX)
        local freeModeAngleX = math.cos(cameraAngleY) * math.sin(cameraAngleX)

        -- calculate a target based on the current position and an offset based on the angle
        local camTargetX = camPosX + freeModeAngleX * 100
        local camTargetY = camPosY + freeModeAngleY * 100
        local camTargetZ = camPosZ + freeModeAngleZ * 100

        -- Work out the distance between the target and the camera (should be 100 units)
        local camAngleX = camPosX - camTargetX
        local camAngleY = camPosY - camTargetY
        local camAngleZ = 0 -- we ignore this otherwise our vertical angle affects how fast you can strafe

        -- Calulcate the length of the vector
        local angleLength = math.sqrt(camAngleX*camAngleX+camAngleY*camAngleY+camAngleZ*camAngleZ)

        -- Normalize the vector, ignoring the Z axis, as the camera is stuck to the XY plane (it can't roll)
        local camNormalizedAngleX = camAngleX / angleLength
        local camNormalizedAngleY = camAngleY / angleLength
        local camNormalizedAngleZ = 0

        -- We use this as our rotation vector
        local normalAngleX = 0
        local normalAngleY = 0
        local normalAngleZ = 1

        -- Perform a cross product with the rotation vector and the normalzied angle
        local normalX = (camNormalizedAngleY * normalAngleZ - camNormalizedAngleZ * normalAngleY)
        local normalY = (camNormalizedAngleZ * normalAngleX - camNormalizedAngleX * normalAngleZ)
        local normalZ = (camNormalizedAngleX * normalAngleY - camNormalizedAngleY * normalAngleX)

        -- Update the target based on the new camera position (again, otherwise the camera kind of sways as the target is out by a frame)
        camTargetX = camPosX + freeModeAngleX * 100
        camTargetY = camPosY + freeModeAngleY * 100
        camTargetZ = camPosZ + freeModeAngleZ * 100

        -- Set the new camera position and target
        setCameraMatrix (camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ, roll)
    end
end

function freecamMouse (cX,cY,aX,aY)
if isCursorShowing() or isMTAWindowActive() then
mouseFrameDelay = 5
return
elseif mouseFrameDelay > 0 then
mouseFrameDelay = mouseFrameDelay - 1
return
end
startTick = getTickCount()
recentlyMoved = true
if fadeBack then
    fadeBack = false
executeCounter = 0
end
    local width, height = guiGetScreenSize()
    aX = aX - width / 2
    aY = aY - height / 2

    rotX = rotX + aX * mouseSensitivity * 0.01745
    rotY = rotY - aY * mouseSensitivity * 0.01745

    local pRotX, pRotY, pRotZ = getElementRotation (localPlayer)
    pRotZ = math.rad(pRotZ)
   
if rotX > PI then
rotX = rotX - 2 * PI
elseif rotX < -PI then
rotX = rotX + 2 * PI
end

if rotY > PI then
rotY = rotY - 2 * PI
elseif rotY < -PI then
rotY = rotY + 2 * PI
end
    if isPedInVehicle(localPlayer) then
        if rotY < -PI / 4 then
            rotY = -PI / 4
        elseif rotY > -PI/15 then
            rotY = -PI/15
        end
    else
        if rotY < -PI / 4 then
            rotY = -PI / 4
        elseif rotY > PI / 2.1 then
            rotY = PI / 2.1
        end
    end
end

Sorun olursa bu konu altından yazabilirsin  :P
usta sen efsanesin helal olsun çok saolasın hakkını helal et
 


Çevrimdışı Mahlukat

  • Uzman Üye
  • *
    • İleti: 637
Yanıtla #13 : 12 Mart 2018, 16:43:40
Linki görebilmek için Kayıt olun yada Giriş yapın.
usta sen efsanesin helal olsun çok saolasın hakkını helal et
Rica ederim :P ufak bir değişiklik server.lua kısmında yenisini alırsan daha iyi olur   ;D
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


Çevrimdışı ulusoy

  • Yeni Üye
  • *
    • İleti: 50
Yanıtla #14 : 12 Mart 2018, 16:47:15
Linki görebilmek için Kayıt olun yada Giriş yapın.
Rica ederim :P ufak bir değişiklik server.lua kısmında yenisini alırsan daha iyi olur   ;D

Bunu ellemi yazdın yoksa herhangi bir paneli varmı bende uğraşmak istiyorum bu tarz işlerle  ;D ilk gişirimim komutlu panelle f1 de bulunmayan arabayı spawmlayıp tek bir skinin kullanmasına izin vermek oldu ;D