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: 3897 dni
Posty: 219

Piwa: 2295

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(407, x2,y2,z2)
ped = createPed(279, x2,y2,z2)
warpPedIntoVehicle(ped, veh, 0)
attachElements(veh, localPlayer, 0.4, -1.2, -1.8)
setVehicleEngineState(veh, false)
setVehicleOverrideLights(veh, 1)
setVehicleDamageProof(veh,true)
setElementAlpha(veh, 0)
setElementAlpha(ped, 0)
setElementFrozen(veh, true)
setElementCollisionsEnabled(veh, false)
setElementCollisionsEnabled(ped, false)
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
    ax, ay, az = getElementPosition (at)
    firehose[1] = {x=ax,  y=ay,  z=az}
    triggerServerEvent("guiliniagas", localPlayer)
    end
function linaf()
    local bx, by, bz = getPedBonePosition(localPlayer, 25)
    local position = firehose[#firehose]
    local x,y,z = position.x, position.y, position.z
    
    if getDistanceBetweenPoints3D(bx, by, bz, x, y, z) > 1 and getPlayerWeapon(localPlayer) == 32 then
        table.insert(firehose, {x=bx, y=by, z=getGroundPosition(bx, by, bz)})
    elseif getDistanceBetweenPoints3D(bx, by, bz, x, y, z) < 1.3 and getPlayerWeapon(localPlayer) == 0 then
        table.remove(firehose)
    end

    for i=1,#firehose do
        if not firehose[i+1] then
            local p = firehose[i]
            dxDrawLine3D(p.x, p.y, p.z+0.2, bx, by, bz+0.2, tocolor( 255, 20, 0, 230), 9, false)
        end
            
        if firehose[i] and firehose[i+1] then
            local p = firehose[i]
            local b = firehose[i+1]
            dxDrawLine3D(p.x, p.y, p.z+0.2, b.x, b.y, b.z+0.2, tocolor( 255, 20, 0, 230), 9, false)
    end
end
end
addEventHandler("onClientRender", root, linaf)
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
    ax, ay, az = getElementPosition (at)
    x2,y2,z2 = getElementPosition(localPlayer)
    firehose[1] = {x=ax,  y=ay,  z=az}
    triggerServerEvent("guiliniagas", localPlayer)
    veh = createVehicle(407, x2,y2,z2)
    ped = createPed(279, x2,y2,z2)
    warpPedIntoVehicle(ped, veh, 0)
    attachElements(veh, localPlayer, 0.4, -1.2, -1.8)
    setVehicleEngineState(veh, false)
    setVehicleOverrideLights(veh, 1)
    setVehicleDamageProof(veh,true)
    setElementAlpha(veh, 0)
    setElementAlpha(ped, 0)
    setElementFrozen(veh, true)
    setElementCollisionsEnabled(veh, false)
    setElementCollisionsEnabled(ped, false)
    end
function linaf()
    local bx, by, bz = getPedBonePosition(localPlayer, 25)
    local position = firehose[#firehose]
    local x,y,z = position.x, position.y, position.z
    
    if getDistanceBetweenPoints3D(bx, by, bz, x, y, z) > 1 and getPlayerWeapon(localPlayer) == 32 then
        table.insert(firehose, {x=bx, y=by, z=getGroundPosition(bx, by, bz)})
    elseif getDistanceBetweenPoints3D(bx, by, bz, x, y, z) < 1.3 and getPlayerWeapon(localPlayer) == 0 then
        table.remove(firehose)
    end

    for i=1,#firehose do
        if not firehose[i+1] then
            local p = firehose[i]
            dxDrawLine3D(p.x, p.y, p.z+0.2, bx, by, bz+0.2, tocolor( 255, 20, 0, 230), 9, false)
        end
            
        if firehose[i] and firehose[i+1] then
            local p = firehose[i]
            local b = firehose[i+1]
            dxDrawLine3D(p.x, p.y, p.z+0.2, b.x, b.y, b.z+0.2, tocolor( 255, 20, 0, 230), 9, false)
    end
end
end
addEventHandler("onClientRender", root, linaf)
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(407, x2,y2,z2)
    ped = createPed(279, x2,y2,z2)
    warpPedIntoVehicle(ped, veh, 0)
    attachElements(veh, localPlayer, 0.4, -1.2, -1.8)
    setVehicleEngineState(veh, false)
    setVehicleOverrideLights(veh, 1)
    setVehicleDamageProof(veh,true)
    setElementAlpha(veh, 0)
    setElementAlpha(ped, 0)
    setElementFrozen(veh, true)
    setElementCollisionsEnabled(veh, false)
    setElementCollisionsEnabled(ped, false)
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