Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2023-10-30, 18:34


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

Czesć!
Zrobiłem taki kod na mój serwer strażacki, na razie prosty. Sluży on do tworzenia pojazdu przyczepionego do gracza na poziomie ręki. Założenie? armatka wodna dla strażaków :)

function tsts()
local x2,y2,z2 getElementPosition(localPlayer)
local veh createVehicle(407x2,y2,z2)
ped createPed(279x2,y2,z2)
warpPedIntoVehicle(pedveh0)
attachElements(vehlocalPlayer0.4, -1.2, -1.8)
setVehicleEngineState(vehfalse)
setVehicleOverrideLights(veh1)
setVehicleDamageProof(veh,true)
setElementAlpha(veh0)
setElementAlpha(ped0)
setElementFrozen(vehtrue)
setElementCollisionsEnabled(vehfalse)
setElementCollisionsEnabled(pedfalse)
function woda(cmd)
    setPedControlState(ped"vehicle_fire"true)
    end
addCommandHandler("wo1"woda)
function woda2(cmd)
    setPedControlState(ped"vehicle_fire"false)
end
addCommandHandler("wo0"woda2)
end
addCommandHandler("dupa"tsts)

wszystko działa, armatka strzela. Problemy:
1. armatka strzela cały czas tylko w jednym kierunku, nie porusza się wraz z kamerą gracza
2. słychać dźwięk silnika stworzonego pojazdu
3. Jak połąćzyć ten skrypt w jeden z tym?:

elseif source == sliniag then
    for i,v in ipairs(getElementsByType("marker")) do 
    at getElementAttachedTo(v)
    if (at) and getElementData(at"STRAZ") == true then
    axayaz getElementPosition (at)
    firehose[1] = {x=ax,  y=ay,  z=az}
    triggerServerEvent("guiliniagas"localPlayer)
    end
function linaf()
    local bxbybz getPedBonePosition(localPlayer25)
    local position firehose[#firehose]
    local x,y,position.xposition.yposition.z
    
    if getDistanceBetweenPoints3D(bxbybzxyz) > and getPlayerWeapon(localPlayer) == 32 then
        table.insert(firehose, {x=bxy=byz=getGroundPosition(bxbybz)})
    elseif getDistanceBetweenPoints3D(bxbybzxyz) < 1.3 and getPlayerWeapon(localPlayer) == 0 then
        table.remove(firehose)
    end

    for i=1,#firehose do
        if not firehose[i+1then
            local p firehose[i]
            dxDrawLine3D(p.xp.yp.z+0.2bxbybz+0.2tocolor255200230), 9false)
        end
            
        if firehose[i] and firehose[i+1then
            local p firehose[i]
            local b firehose[i+1]
            dxDrawLine3D(p.xp.yp.z+0.2b.xb.yb.z+0.2tocolor255200230), 9false)
    end
end
end
addEventHandler("onClientRender"rootlinaf)
end
end
end
addEventHandler("onClientGUIClick"getRootElement(), wylaczokno)


[ Dodano: 2023-10-30, 18:57 ]
elseif source == sliniag then
    for i,v in ipairs(getElementsByType("marker")) do 
    at getElementAttachedTo(v)
    if (at) and getElementData(at"STRAZ") == true then
    axayaz getElementPosition (at)
    x2,y2,z2 getElementPosition(localPlayer)
    firehose[1] = {x=ax,  y=ay,  z=az}
    triggerServerEvent("guiliniagas"localPlayer)
    veh createVehicle(407x2,y2,z2)
    ped createPed(279x2,y2,z2)
    warpPedIntoVehicle(pedveh0)
    attachElements(vehlocalPlayer0.4, -1.2, -1.8)
    setVehicleEngineState(vehfalse)
    setVehicleOverrideLights(veh1)
    setVehicleDamageProof(veh,true)
    setElementAlpha(veh0)
    setElementAlpha(ped0)
    setElementFrozen(vehtrue)
    setElementCollisionsEnabled(vehfalse)
    setElementCollisionsEnabled(pedfalse)
    end
function linaf()
    local bxbybz getPedBonePosition(localPlayer25)
    local position firehose[#firehose]
    local x,y,position.xposition.yposition.z
    
    if getDistanceBetweenPoints3D(bxbybzxyz) > and getPlayerWeapon(localPlayer) == 32 then
        table.insert(firehose, {x=bxy=byz=getGroundPosition(bxbybz)})
    elseif getDistanceBetweenPoints3D(bxbybzxyz) < 1.3 and getPlayerWeapon(localPlayer) == 0 then
        table.remove(firehose)
    end

    for i=1,#firehose do
        if not firehose[i+1then
            local p firehose[i]
            dxDrawLine3D(p.xp.yp.z+0.2bxbybz+0.2tocolor255200230), 9false)
        end
            
        if firehose[i] and firehose[i+1then
            local p firehose[i]
            local b firehose[i+1]
            dxDrawLine3D(p.xp.yp.z+0.2b.xb.yb.z+0.2tocolor255200230), 9false)
    end
end
end
addEventHandler("onClientRender"rootlinaf)
function woda(cmd)
    setPedControlState(ped"vehicle_fire"true)
    end
addCommandHandler("wo1"woda)
function woda2(cmd)
    setPedControlState(ped"vehicle_fire"false)
end
addCommandHandler("wo0"woda2)
end
addCommandHandler("dupa"tsts)
end
end


działa. pojazd się tworzy pry wyborze z GUI "linia gaśnicza". Pozostaje tylko kwestia armatki, żeby obracała się wraz z kamerą, aby można było strzelać boki oraz góra/dół.
Oraz, chciał bym aby pojazd Tworzyłsię po stronie serwera, tylko że niektóre fubkcje do niego sąpo stronie clienta. Robiłem triggery, ale nie bardzo wiem jak to rozwiązać, Tworzyć pojazd i nadawać mu coś

veh createVehicle(407x2,y2,z2)
    ped createPed(279x2,y2,z2)
    warpPedIntoVehicle(pedveh0)
    attachElements(vehlocalPlayer0.4, -1.2, -1.8)
    setVehicleEngineState(vehfalse)
    setVehicleOverrideLights(veh1)
    setVehicleDamageProof(veh,true)
    setElementAlpha(veh0)
    setElementAlpha(ped0)
    setElementFrozen(vehtrue)
    setElementCollisionsEnabled(vehfalse)
    setElementCollisionsEnabled(pedfalse)
w evencie, i striggerować to na serwer??

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Tagi: armatka :: wodna
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku