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

Wysłany: 2020-06-07, 15:17


roteN.







Wiek: 22
Na forum: 2188 dni
Posty: 18
Nick w MP: marek3

Piwa: 1

Respekt: 50

Witam, chce zrobi? otwieranie i zamykanie dachu w poje?dzie pod shiftem. Posiadam podmiank?, kt?ra posiada wariant z dachem i bez dachu. Wiem, ?e to b?dzie setVehicleVariant czy jako? tak, ale prosz? o dok?adniejsze wyt?umaczenie. Stawiam zimne :piwo: z g?ry dzi?ki za pomoc.

Kod:

local screenW, screenH = guiGetScreenSize()
local sx, sy = guiGetScreenSize()
local w, h = (sx/1680),(sy/1050)
local tick = getTickCount()
opcjaWybrana = 1
alpha1 = 255
alpha2 = 255

dachy = {

[480] = true,

}

local motorki_hehe = {[463] = true,[462] = true,[461] = true,[581] = true,[448] = true,[468] = true,[471] = true,[521] = true,[522] = true,[523] = true}

function stworzListe()
opcje = {}
local veh = getPedOccupiedVehicle(localPlayer)
if veh then
local rh_lvl = getElementData(veh, "rh:up") or 0
local naped = getElementData(veh, "naped:lvl") or "WYBIERZ NAP?D"
if not getVehicleEngineState(veh) then
table.insert(opcje, {"Odpal silnik", 1})
else
table.insert(opcje, {"Zga? silnik", 2})
end


if getVehicleOverrideLights(veh) ~= 2 then
table.insert(opcje, {"W??cz ?wiat?a", 3})
else
table.insert(opcje, {"Zga? ?wiat?a", 4})
end

if motorki_hehe[getElementModel(veh)] then
if isElementFrozen(veh) then
table.insert(opcje, {"Podnie? n?zke", 7})
else
table.insert(opcje, {"Opu?? n?zke", 8})
end
else
if isElementFrozen(veh) then
table.insert(opcje, {"Spu?? r?czny", 7})
else
table.insert(opcje, {"Zaci?gnij r?czny", 8})
end
end


if isVehicleLocked(veh) then
table.insert(opcje, {"Otw?rz pojazd", 5})
else
table.insert(opcje, {"Zamknij pojazd", 6})
end


if getVehicleDoorOpenRatio(veh,0) == 0 then
table.insert(opcje, {"Otw?rz mask?", 9})
else
table.insert(opcje, {"Zamknij mask?", 10})
end

if getVehicleDoorOpenRatio(veh,1) == 0 then
table.insert(opcje, {"Otw?rz baga?nik", 11})
else
table.insert(opcje, {"Zamknij baga?nik", 12})
end

if getElementData(veh, "vehicle:rh") then
table.insert(opcje, {"RH: "..rh_lvl.."", 15})
end

if getElementData(veh, "vehicle:chgDrive") then
table.insert(opcje, {"Naped: "..naped.."", 16})
end

if getElementModel(veh) == 506 then
if getElementData(veh, "vehicle:latanie") then
table.insert(opcje, {"Wy??cz tryb latania", 20})
else
table.insert(opcje, {"W??cz tryb latania", 21})
end
end


end
if #opcje > 0 then
if not show then
bindKey("arrow_u", "down", onSuwakZmien)
bindKey("arrow_d", "down", onSuwakZmien)
bindKey("arrow_r", "down", editRHUp)
bindKey("arrow_l", "down", editRHDown)
bindKey("arrow_r", "down", editNapedZmien)
bindKey("arrow_l", "down", editNapedZmien)
bindKey("space", "down", onSuwakWybierz)
showChat(false)
setElementData(localPlayer, "notshowhud", true)
triggerEvent("radar:onClientHudComponent", localPlayer, "radar", false)
setPlayerHudComponentVisible("radar", false)
tick = getTickCount()
addEventHandler("onClientRender", getRootElement(), dxDrawPanelInterakcji)
show = true
end
end
end

addEvent("wlaczlatanie", true)
addEventHandler("wlaczlatanie", resourceRoot,function()
setWorldSpecialPropertyEnabled("aircars", true)
end)

addEvent("wylaczlatanie", true)
addEventHandler("wylaczlatanie", root, function()
setWorldSpecialPropertyEnabled("aircars", false)
end)


function ostatniPojazd()
local veh = getElementData(localPlayer, "lastVeh")
if veh then
if isElement(veh) then
local driver = getElementData(veh, "lastDriver")
if driver == localPlayer then
local dx, dy, dz = getElementPosition(localPlayer)
local vx, vy, vz = getElementPosition(veh)
if 10 >= getDistanceBetweenPoints3D(dx, dy, dz, vx, vy, vz) then
saveV = veh
return veh
end
end
end
end
end


rowery = {

[481] = true

}

function wlaczPanelInterakcji()
local veh = getPedOccupiedVehicle(localPlayer)
if veh then
if rowery[getElementModel(veh)] then return end
if getVehicleController(veh) == localPlayer then
stworzListe()
end
else
local veh = ostatniPojazd()
if veh then
if rowery[getElementModel(veh)] then return end
stworzListe()
end
end
end

function wylaczPanelInterakcji()
if show then
show = false
unbindKey("arrow_u", "down", onSuwakZmien)
unbindKey("arrow_d", "down", onSuwakZmien)
unbindKey("arrow_r", "down", editRHUp)
unbindKey("arrow_l", "down", editRHDown)
unbindKey("arrow_r", "down", editNapedZmien)
unbindKey("arrow_l", "down", editNapedZmien)

unbindKey("space", "down", onSuwakWybierz)
showChat(true)
setElementData(localPlayer, "notshowhud", false)
setPlayerHudComponentVisible("radar", true)
opcjaWybrana = 1
removeEventHandler("onClientRender", getRootElement(), dxDrawPanelInterakcji)
saveV = nil
end
end

bindKey("lshift", "down", wlaczPanelInterakcji)
bindKey("lshift", "up", wylaczPanelInterakcji)



function dxDrawPanelInterakcji()
alpha12 = interpolateBetween(0, 0, 0, 235, 0, 0, (getTickCount()-tick)/100, "Linear")
alpha13 = interpolateBetween(0, 0, 0, 255, 0, 0, (getTickCount()-tick)/100, "Linear")
dxDrawRectangle(0*w, 0*h, 2000*w, 2000*h, tocolor(15, 15, 15, alpha12), false)


for i,v in pairs(opcje) do
if i == opcjaWybrana then
dxDrawText(v[1], 401*w, 532*h, 1277*w, 585*h, tocolor(255, 255, 255, alpha13), 2.5*w, "default", "center", "center", false, false, false, false, false)
else
dxDrawText(v[1], 401*w, 532*h, 1277*w, 585*h, tocolor(255, 255, 255, 0), 2.5*w, "default", "center", "center", false, false, false, false, false)
end
end


if getKeyState("arrow_l") then
alpha1 = 155
else
alpha1 = 255
end

if getKeyState("arrow_r") then
alpha2 = 155
else
alpha2 = 255
end


if opcje[opcjaWybrana][2] == 15 or opcje[opcjaWybrana][2] == 16 or opcje[opcjaWybrana][2] == 19 then
dxDrawText("U?yj strza?ek (g?ra, d??) do zmiany opcji, strza?ek (prawo, lewo) do edycji RH", 401*w, 515*h, 1277*w, 532*h, tocolor(17, 128, 106, alpha13), 1.5*w, "default", "center", "center", false, false, false, false, false)
dxDrawText("Aby edytowa? modu?y, zatrzymaj pojazd", 401*w, 585*h, 1277*w, 608*h, tocolor(17, 128, 106, alpha13), 1.5*w, "default", "center", "center", false, false, false, false, false)
dxDrawImage(50*w, 535*h, 47*w, 51*h, "STRZALKA.png", 0, 0, 0, tocolor(255,255,255, alpha1), true)
dxDrawImage(1570*w, 535*h, 47*w, 51*h, "STRZALKA2.png", 0, 0, 0, tocolor(255,255,255, alpha2), true)
else
dxDrawText("U?yj strza?ek (g?ra, d??) do zmiany opcji", 401*w, 515*h, 1277*w, 532*h, tocolor(17, 128, 106, alpha13), 1.5*w, "default", "center", "center", false, false, false, false, false)
end



if #opcje == 1 then
opcjaWybrana = 1
end

stworzListe()
end


function onSuwakZmien(k,ks)
if k == "arrow_d" then --na dol
opcjaWybrana = opcjaWybrana - 1
if opcjaWybrana == 0 then
opcjaWybrana = #opcje
end
else
opcjaWybrana = opcjaWybrana + 1
if opcjaWybrana == #opcje + 1 then
opcjaWybrana = 1
end
end
end

function onSuwakZmien(k,ks)
if k == "arrow_u" then --na dol
opcjaWybrana = opcjaWybrana - 1
if opcjaWybrana == 0 then
opcjaWybrana = #opcje
end
else
opcjaWybrana = opcjaWybrana + 1
if opcjaWybrana == #opcje + 1 then
opcjaWybrana = 1
end
end
end

function editRHDown(k,ks)
local veh = getPedOccupiedVehicle(localPlayer)
if getElementSpeed(veh, 1) > 5 then return end
local rh_lvl = getElementData(veh, "rh:up") or 0
if opcje[opcjaWybrana][1] == "RH: "..rh_lvl.."" then
if k == "arrow_l" then --na dol
triggerServerEvent("rh:nizej", localPlayer, localPlayer)
end
end
end

function editRHUp(k,ks)
local veh = getPedOccupiedVehicle(localPlayer)
if getElementSpeed(veh, 1) > 5 then return end
local rh_lvl = getElementData(veh, "rh:up") or 0
if opcje[opcjaWybrana][1] == "RH: "..rh_lvl.."" then
if k == "arrow_r" then --na gore
triggerServerEvent("rh:wyzej", localPlayer, localPlayer)
end
end
end

function editNapedZmien(k,ks)
local veh = getPedOccupiedVehicle(localPlayer)
if getElementSpeed(veh, 1) > 5 then return end
local naped = getElementData(veh, "naped:lvl") or "WYBIERZ NAP?D"
if opcje[opcjaWybrana][1] == "Naped: "..naped.."" then
if k == "arrow_r" or k == "arrow_l" then
triggerServerEvent("Naped:Zmien", localPlayer, localPlayer)
end
end
end

function onSuwakWybierz()
local veh = getPedOccupiedVehicle(localPlayer)

if opcje[opcjaWybrana][2] == 17 or opcje[opcjaWybrana][2] == 18 then
if getElementSpeed(veh, 1) > 5 then return end
end

if #opcje == 1 then
triggerServerEvent("onInterakcjeWybierzAkcje", localPlayer, false, saveV)
return
end

if opcjaWybrana then
local id = opcje[opcjaWybrana][2]
if id then
if id == 7 and getElementSpeed(veh, 1) > 5 then return end
if id == 8 and getElementSpeed(veh, 1) > 5 then return end
triggerServerEvent("onInterakcjeWybierzAkcje", localPlayer, id, saveV)
end
end
end


function getVehicleHandlingProperty ( element, property )
if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then
local handlingTable = getVehicleHandling ( element )
local value = handlingTable[property]

if value then
return value
end
end

return false
end


function getElementSpeed(theElement, unit)
-- Check arguments for errors
assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
local elementType = getElementType(theElement)
assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
-- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number
unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
-- Setup our multiplier to convert the velocity to the specified unit
local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
-- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit
return (Vector3(getElementVelocity(theElement)) * mult).length
end


fileDelete("c.lua") -- usuwamy


Ostatnio zmieniony przez roteN. 2020-06-07, 15:47, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-06-07, 15:31


_jvneczek







Wiek: 22
Na forum: 4325 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

:kula:

skoro w interakcji to potrzeba kodu z interakcji.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-06-07, 15:40


roteN.







Wiek: 22
Na forum: 2188 dni
Posty: 18
Nick w MP: marek3

Piwa: 1

Respekt: 50

Cytat:

skoro w interakcji to potrzeba kodu z interakcji.


Na discordzie masz.

Komentarz Dawidos. dodany 2020-06-07, 15:49Pomagamy na forum, kod wstaw w tym wątku.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-06-07, 16:03


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wariant pojazd?w ustawiasz na 1 je?li jest on pod nazw? extra1 w modelu. Je?li to domy?lny pojazd GTA, to skorzystaj z poni?szej tabelki z wariantami:

Więcej informacji znajdziesz w Wikipedii MTA:

Vehicle_variants


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
roteN.
Wysłany: 2020-06-07, 20:29


roteN.







Wiek: 22
Na forum: 2188 dni
Posty: 18
Nick w MP: marek3

Piwa: 1

Respekt: 50

Cytat:

Wariant pojazd?w ustawiasz na 1 je?li jest on pod nazw? extra1 w modelu. Je?li to domy?lny pojazd GTA, to skorzystaj z poni?szej tabelki z wariantami:


Mo?esz mi to dok?adniej wyt?umaczy?? Najlepiej wklej mi to do tego kodu tak, aby ?miga?o. Jest to zwyk?y pojazd z GTA, mam skrypt na zmiane wariantu komend? (/ustawwariant <1-7>) i chce, ?eby sz?o otwiera? i zamyka? dach pojazdu pod interakcj?, by nie zmienia? tego komend?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-06-07, 20:48


PatryKK.

Emeryt LUA






Wiek: 26
Na forum: 3060 dni
Posty: 1060
Nick w MP: PatryKK.

Piwa: 2322

Respekt: 331,5
Respekt: 331,5Respekt: 331,5Respekt: 331,5

Gotowiec nie zawsze jest dobry. Wa?ne, ?eby? co? z tej pomocy wyci?gn?? a nie jedynie gotowy kod. Przewi? na sam d?? i b?dziesz mia? wyt?umaczenie

Więcej informacji znajdziesz w Wikipedii MTA:

Vehicle_variants


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
roteN.
Wysłany: 2020-06-07, 20:56


roteN.







Wiek: 22
Na forum: 2188 dni
Posty: 18
Nick w MP: marek3

Piwa: 1

Respekt: 50

Cytat:

Gotowiec nie zawsze jest dobry. Wa?ne, ?eby? co? z tej pomocy wyci?gn?? a nie jedynie gotowy kod. Przewi? na sam d?? i b?dziesz mia? wyt?umaczenie


Dobra, ale mi chodzi o dodanie tej funkcji do interakcji, reszt? raczej sobie ogarn?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-06-07, 21:42


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Owszem, mog? podrzuci? przyk?ad z wiki MTA:SA:

function setMyVehiclesVariant(theUsercommandvar1var2)
    local var1var2 tonumber(var1), tonumber(var2) -- If anything was passed make sure its number or nil
    local myVeh getPedOccupiedVehicle(theUser) -- Get the vehicle that they're in
    if (myVeh and getVehicleController(myVeh) == theUser) then -- Make sure they're in control
        local wasSet setVehicleVariant(myVehvar1var2) -- Set what they wanted
        if (wasSetthen
            outputChatBox("Vehicle variant successfully set!"theUser02550)
        else
            outputChatBox("Vehicle variant unsuccessfully set."theUser2552550)
        end
    end
end
addCommandHandler("setvehvar"setMyVehiclesVariant) -- Add the command


Po wpisaniu /setvehvar i wprowadzeniu 2 liczb od wariantu ustawi Ci konkretny wariant.

Jako moderatorowi nie wypada ?ama? regulaminu, a 7 punkt tego dzia?u m?wi jasno:
Cytat:

7. Dzia? przeznaczony jest do rozm?w na temat programowania w j?zyku Lua, tak wi?c zakazuje si? umieszczania gotowych skrypt?w, gamemod?w itp - od tego s? odr?bne dzia?y.


Postaw piwo autorowi tego posta
 

 
Tagi: zmiana :: wariantu :: interakcji
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Zmiana wariantu w interakcji 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