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

Wysłany: 2017-06-21, 21:34


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4150 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

Musisz mie? jeszcze funkcj?
Więcej informacji znajdziesz w Wikipedii MTA:

getElementSpeed


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-21, 21:42


Artystek







Wiek: 23
Na forum: 3520 dni
Posty: 143
Nick w MP: Artystek

Piwa: 74

Respekt: 55,3


function setElementSpeed(elementunitspeed)
    if (unit == nilthen unit 0 end
    if (speed == nilthen speed 0 end
    speed tonumber(speed)
    local acSpeed getElementSpeed(elementunit)
    if (acSpeed~=falsethen -- if true element is validno need to check again
        local diff speed/acSpeed
        if diff ~= diff then return end -- if the number is a 'NaN' return end.
        local x,y,getElementVelocity(element)
        setElementVelocity(element,x*diff,y*diff,z*diff)
        return true
    end

    return false
end

local pojazd_1 = {
{1746.35,-1957.75,15.10537},
{740.642023.477.15449},
{742.531779.435.96569},
--[[{642.311308.8512.25537},
{257.281224.2723.25537},
{-248.281267.4428.33537},
{-834.851068.7734.99537},
{-1571.64533.2233.22537},
{-1943.75148.0126.12537},
{-1973.18, -437.0626.12537},
{-1925.04, -1175.6214.60537},
{-1543.58, -1499.8017.90537},
{-1236.99, -1515.1130.47537},
{-829.63, -1299.7380.32537},
{-558.93, -1190.6542.50537},
{-83.33, -1018.0016.84537},
{538.05, -1155.448.27537},
{791.35, -1345.59, -1.00537},
{1189.56, -1770.30, -3.79537},
{1556.37, -1953.7114.00537},
{2175.76, -1954.4014.53537},
{2204.34, -1699.1014.08537},
{2257.77, -1537.6420.53537},
{2288.88, -1286.3324.37537},
{2288.89, -994.9827.14537},
{2155.91, -668.5452.71537},
{2202.36, -361.1647.50537},
{2535.74, -286.9516.52537},]]--

}
for i,v in pairs(pojazd_1) do
    local vehicle=createVehicle(v[4], v[1], v[2], v[3])
    setElementSpeed(vehicle"kph",  200)
   end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-21, 21:47


neku^







Wiek: 24
Na forum: 3522 dni
Posty: 461
Nick w MP: neku^

Piwa: 1186

Respekt: 320,5
Respekt: 320,5Respekt: 320,5Respekt: 320,5

No i teraz powinno nada? ci pr?dko??.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-21, 21:48


Artystek







Wiek: 23
Na forum: 3520 dni
Posty: 143
Nick w MP: Artystek

Piwa: 74

Respekt: 55,3

Powinno, a wyrzuca b??d tym razem dla getElementSpeed

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-21, 21:50


neku^







Wiek: 24
Na forum: 3522 dni
Posty: 461
Nick w MP: neku^

Piwa: 1186

Respekt: 320,5
Respekt: 320,5Respekt: 320,5Respekt: 320,5


function getElementSpeed(theElementunit)
    -- 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) == or tonumber(unit) == 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/if no unit specified and 'ignore' argument type if the string contains a number
    unit unit == nil and or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == or unit == "m/s") and 50 or ((unit == or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vectorafter converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

Nad funkcja setElementSpeed

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-21, 21:56


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

dbn69, mo?e by? wyt?umaczy? co ty jemu podajesz? Bo taka nauka co ty stosujesz nie ma sensu, bo i tak kto? co szuka pomocy a ty dalejsz mu gotowe kodu i m?wisz co ma zrobi? to nic go to nie nauczy. Polecam aby? rozpisywa? co dajesz i do czego s?u?y i co oznacza dany b??d.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-21, 21:59


Artystek







Wiek: 23
Na forum: 3520 dni
Posty: 143
Nick w MP: Artystek

Piwa: 74

Respekt: 55,3

Warning: Ban argument @ 'setElementVelocity' -Expected number, got NaN
Linia:
          setElementVelocity(element,x*diff,y*diff,z*diff)

 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-21, 22:01


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Artystek, podaj sw?j kod jaki obecnie posiadasz.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-21, 22:03


Artystek







Wiek: 23
Na forum: 3520 dni
Posty: 143
Nick w MP: Artystek

Piwa: 74

Respekt: 55,3


function getElementSpeed(theElementunit)
    -- 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) == or tonumber(unit) == 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/if no unit specified and 'ignore' argument type if the string contains a number
    unit unit == nil and or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == or unit == "m/s") and 50 or ((unit == or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vectorafter converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end
function setElementSpeed(elementunitspeed)
    if (unit == nilthen unit 0 end
    if (speed == nilthen speed 0 end
    speed tonumber(speed)
    local acSpeed getElementSpeed(elementunit)
    if (acSpeed~=falsethen -- if true element is validno need to check again
        local diff speed/acSpeed
        if diff ~= diff then return end -- if the number is a 'NaN' return end.
        local x,y,getElementVelocity(element)
        setElementVelocity(element,x*diff,y*diff,z*diff)
        return true
    end

    return false
end

local pojazd_1 = {
{1746.35,-1957.75,15.10537},
{740.642023.477.15449},
{742.531779.435.96569},
--[[{642.311308.8512.25537},
{257.281224.2723.25537},
{-248.281267.4428.33537},
{-834.851068.7734.99537},
{-1571.64533.2233.22537},
{-1943.75148.0126.12537},
{-1973.18, -437.0626.12537},
{-1925.04, -1175.6214.60537},
{-1543.58, -1499.8017.90537},
{-1236.99, -1515.1130.47537},
{-829.63, -1299.7380.32537},
{-558.93, -1190.6542.50537},
{-83.33, -1018.0016.84537},
{538.05, -1155.448.27537},
{791.35, -1345.59, -1.00537},
{1189.56, -1770.30, -3.79537},
{1556.37, -1953.7114.00537},
{2175.76, -1954.4014.53537},
{2204.34, -1699.1014.08537},
{2257.77, -1537.6420.53537},
{2288.88, -1286.3324.37537},
{2288.89, -994.9827.14537},
{2155.91, -668.5452.71537},
{2202.36, -361.1647.50537},
{2535.74, -286.9516.52537},]]--

}
for i,v in pairs(pojazd_1) do
    local vehicle=createVehicle(v[4], v[1], v[2], v[3])
    setElementSpeed(vehicle"mph",  200)
   end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-22, 12:35


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Artystek, spr?buj tak:
function getElementSpeed(theElementunit)
    -- 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) == or tonumber(unit) == 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/if no unit specified and 'ignore' argument type if the string contains a number
    unit unit == nil and or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == or unit == "m/s") and 50 or ((unit == or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vectorafter converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

function setElementSpeed(elementunitspeed)
    if (unit == nilthen unit 0 end
    if (speed == nilthen speed 0 end
    speed tonumber(speed)
    local acSpeed getElementSpeed(elementunit)
    if (acSpeed~=falsethen -- if true element is validno need to check again
        local diff speed/acSpeed
        if diff ~= diff then return end -- if the number is a 'NaN' return end.
        local x,y,getElementVelocity(element)
        setElementVelocity(element,x*diff,y*diff,z*diff)
        return true
    end

    return false
end

local pojazd_1 = {
{1746.35,-1957.75,15.10537},
{740.642023.477.15449},
{742.531779.435.96569},
--[[{642.311308.8512.25537},
{257.281224.2723.25537},
{-248.281267.4428.33537},
{-834.851068.7734.99537},
{-1571.64533.2233.22537},
{-1943.75148.0126.12537},
{-1973.18, -437.0626.12537},
{-1925.04, -1175.6214.60537},
{-1543.58, -1499.8017.90537},
{-1236.99, -1515.1130.47537},
{-829.63, -1299.7380.32537},
{-558.93, -1190.6542.50537},
{-83.33, -1018.0016.84537},
{538.05, -1155.448.27537},
{791.35, -1345.59, -1.00537},
{1189.56, -1770.30, -3.79537},
{1556.37, -1953.7114.00537},
{2175.76, -1954.4014.53537},
{2204.34, -1699.1014.08537},
{2257.77, -1537.6420.53537},
{2288.88, -1286.3324.37537},
{2288.89, -994.9827.14537},
{2155.91, -668.5452.71537},
{2202.36, -361.1647.50537},
{2535.74, -286.9516.52537},]]--
}


for i,v in pairs(pojazd_1) do
    local vehicle=createVehicle(v[4], v[1], v[2], v[3])
    if vehicle then
        setElementSpeed(vehicle1,  50)
    end
   end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-22, 12:49


Artystek







Wiek: 23
Na forum: 3520 dni
Posty: 143
Nick w MP: Artystek

Piwa: 74

Respekt: 55,3

Nadal ten sam b??d

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-22, 13:19


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Artystek, zobacz tak:
for i,v in pairs(pojazd_1) do
    local vehicle=createVehicle(v[4], v[1], v[2], v[3])
        setTrainSpeed(vehicle1) -- Set the train speed to 1 100mph160kmh
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-22, 13:22


Artystek







Wiek: 23
Na forum: 3520 dni
Posty: 143
Nick w MP: Artystek

Piwa: 74

Respekt: 55,3

A funkcje wy?ej te? zmienia? na setTrainSpeed?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-22, 13:30


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

local pojazd_1 = {
{1746.35,-1957.75,15.10537},
{740.642023.477.15449},
{742.531779.435.96569},
--[[{642.311308.8512.25537},
{257.281224.2723.25537},
{-248.281267.4428.33537},
{-834.851068.7734.99537},
{-1571.64533.2233.22537},
{-1943.75148.0126.12537},
{-1973.18, -437.0626.12537},
{-1925.04, -1175.6214.60537},
{-1543.58, -1499.8017.90537},
{-1236.99, -1515.1130.47537},
{-829.63, -1299.7380.32537},
{-558.93, -1190.6542.50537},
{-83.33, -1018.0016.84537},
{538.05, -1155.448.27537},
{791.35, -1345.59, -1.00537},
{1189.56, -1770.30, -3.79537},
{1556.37, -1953.7114.00537},
{2175.76, -1954.4014.53537},
{2204.34, -1699.1014.08537},
{2257.77, -1537.6420.53537},
{2288.88, -1286.3324.37537},
{2288.89, -994.9827.14537},
{2155.91, -668.5452.71537},
{2202.36, -361.1647.50537},
{2535.74, -286.9516.52537},]]--
}


for i,v in pairs(pojazd_1) do
    local vehicle=createVehicle(v[4], v[1], v[2], v[3])
    setTrainSpeed(vehicle1) -- Set the train speed to 1 100mph160kmh
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-22, 13:37


Artystek







Wiek: 23
Na forum: 3520 dni
Posty: 143
Nick w MP: Artystek

Piwa: 74

Respekt: 55,3


function getElementSpeed(theElementunit)
    -- 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) == or tonumber(unit) == 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/if no unit specified and 'ignore' argument type if the string contains a number
    unit unit == nil and or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == or unit == "m/s") and 50 or ((unit == or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vectorafter converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

function setElementSpeed(elementunitspeed)
    if (unit == nilthen unit 0 end
    if (speed == nilthen speed 0 end
    speed tonumber(speed)
    local acSpeed getElementSpeed(elementunit)
    if (acSpeed~=falsethen -- if true element is validno need to check again
        local diff speed/acSpeed
        if diff ~= diff then return end -- if the number is a 'NaN' return end.
        local x,y,getElementVelocity(element)
        setElementVelocity(element,x*diff,y*diff,z*diff)
        return true
    end

    return false
end

local pojazd_1 = {
{1746.35,-1957.75,15.10537},
{740.642023.477.15449},
{742.531779.435.96569},
--[[{642.311308.8512.25537},
{257.281224.2723.25537},
{-248.281267.4428.33537},
{-834.851068.7734.99537},
{-1571.64533.2233.22537},
{-1943.75148.0126.12537},
{-1973.18, -437.0626.12537},
{-1925.04, -1175.6214.60537},
{-1543.58, -1499.8017.90537},
{-1236.99, -1515.1130.47537},
{-829.63, -1299.7380.32537},
{-558.93, -1190.6542.50537},
{-83.33, -1018.0016.84537},
{538.05, -1155.448.27537},
{791.35, -1345.59, -1.00537},
{1189.56, -1770.30, -3.79537},
{1556.37, -1953.7114.00537},
{2175.76, -1954.4014.53537},
{2204.34, -1699.1014.08537},
{2257.77, -1537.6420.53537},
{2288.88, -1286.3324.37537},
{2288.89, -994.9827.14537},
{2155.91, -668.5452.71537},
{2202.36, -361.1647.50537},
{2535.74, -286.9516.52537},]]--
}


for i,v in pairs(pojazd_1) do
    local vehicle=createVehicle(v[4], v[1], v[2], v[3])
    setTrainSpeed(vehicle1) -- Set the train speed to 1 100mph160kmh
end


Nie wyrzuca b??d?w, ale poci?g stoi

Postaw piwo autorowi tego posta
 

 
Tagi: pociągi
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Pociągi Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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