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
Musisz mie? jeszcze funkcj?
Wysłany: 2017-06-21, 21:42
Artystek
Wiek: 23 Na forum: 3520 dni Posty: 143
Nick w MP: Artystek
Piwa : 74
function setElementSpeed ( element , unit , speed )
if ( unit == nil ) then unit = 0 end
if ( speed == nil ) then speed = 0 end
speed = tonumber ( speed )
local acSpeed = getElementSpeed ( element , unit )
if ( acSpeed ~= false ) then -- if true - element is valid , no 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 , z = getElementVelocity ( element )
setElementVelocity ( element , x * diff , y * diff , z * diff )
return true
end
return false
end
local pojazd_1 = {
{ 1746.35 ,- 1957.75 , 15.10 , 537 },
{ 740.64 , 2023.47 , 7.15 , 449 },
{ 742.53 , 1779.43 , 5.96 , 569 },
--[[{ 642.31 , 1308.85 , 12.25 , 537 },
{ 257.28 , 1224.27 , 23.25 , 537 },
{- 248.28 , 1267.44 , 28.33 , 537 },
{- 834.85 , 1068.77 , 34.99 , 537 },
{- 1571.64 , 533.22 , 33.22 , 537 },
{- 1943.75 , 148.01 , 26.12 , 537 },
{- 1973.18 , - 437.06 , 26.12 , 537 },
{- 1925.04 , - 1175.62 , 14.60 , 537 },
{- 1543.58 , - 1499.80 , 17.90 , 537 },
{- 1236.99 , - 1515.11 , 30.47 , 537 },
{- 829.63 , - 1299.73 , 80.32 , 537 },
{- 558.93 , - 1190.65 , 42.50 , 537 },
{- 83.33 , - 1018.00 , 16.84 , 537 },
{ 538.05 , - 1155.44 , 8.27 , 537 },
{ 791.35 , - 1345.59 , - 1.00 , 537 },
{ 1189.56 , - 1770.30 , - 3.79 , 537 },
{ 1556.37 , - 1953.71 , 14.00 , 537 },
{ 2175.76 , - 1954.40 , 14.53 , 537 },
{ 2204.34 , - 1699.10 , 14.08 , 537 },
{ 2257.77 , - 1537.64 , 20.53 , 537 },
{ 2288.88 , - 1286.33 , 24.37 , 537 },
{ 2288.89 , - 994.98 , 27.14 , 537 },
{ 2155.91 , - 668.54 , 52.71 , 537 },
{ 2202.36 , - 361.16 , 47.50 , 537 },
{ 2535.74 , - 286.95 , 16.52 , 537 },]]--
}
for i , v in pairs ( pojazd_1 ) do
local vehicle = createVehicle ( v [ 4 ], v [ 1 ], v [ 2 ], v [ 3 ])
setElementSpeed ( vehicle , "kph" , 200 )
end
Wysłany: 2017-06-21, 21:47
neku^
Wiek: 24 Na forum: 3522 dni Posty: 461
Nick w MP: neku^
Piwa : 1186
No i teraz powinno nada? ci pr?dko??.
Wysłany: 2017-06-21, 21:48
Artystek
Wiek: 23 Na forum: 3520 dni Posty: 143
Nick w MP: Artystek
Piwa : 74
Powinno, a wyrzuca b??d tym razem dla getElementSpeed
Wysłany: 2017-06-21, 21:50
neku^
Wiek: 24 Na forum: 3522 dni Posty: 461
Nick w MP: neku^
Piwa : 1186
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
Nad funkcja setElementSpeed
Wysłany: 2017-06-21, 21:56
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
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.
Wysłany: 2017-06-21, 21:59
Artystek
Wiek: 23 Na forum: 3520 dni Posty: 143
Nick w MP: Artystek
Piwa : 74
Warning: Ban argument @ 'setElementVelocity' -Expected number, got NaN
Linia:
setElementVelocity ( element , x * diff , y * diff , z * diff )
Wysłany: 2017-06-21, 22:01
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Artystek , podaj sw?j kod jaki obecnie posiadasz.
Wysłany: 2017-06-21, 22:03
Artystek
Wiek: 23 Na forum: 3520 dni Posty: 143
Nick w MP: Artystek
Piwa : 74
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
function setElementSpeed ( element , unit , speed )
if ( unit == nil ) then unit = 0 end
if ( speed == nil ) then speed = 0 end
speed = tonumber ( speed )
local acSpeed = getElementSpeed ( element , unit )
if ( acSpeed ~= false ) then -- if true - element is valid , no 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 , z = getElementVelocity ( element )
setElementVelocity ( element , x * diff , y * diff , z * diff )
return true
end
return false
end
local pojazd_1 = {
{ 1746.35 ,- 1957.75 , 15.10 , 537 },
{ 740.64 , 2023.47 , 7.15 , 449 },
{ 742.53 , 1779.43 , 5.96 , 569 },
--[[{ 642.31 , 1308.85 , 12.25 , 537 },
{ 257.28 , 1224.27 , 23.25 , 537 },
{- 248.28 , 1267.44 , 28.33 , 537 },
{- 834.85 , 1068.77 , 34.99 , 537 },
{- 1571.64 , 533.22 , 33.22 , 537 },
{- 1943.75 , 148.01 , 26.12 , 537 },
{- 1973.18 , - 437.06 , 26.12 , 537 },
{- 1925.04 , - 1175.62 , 14.60 , 537 },
{- 1543.58 , - 1499.80 , 17.90 , 537 },
{- 1236.99 , - 1515.11 , 30.47 , 537 },
{- 829.63 , - 1299.73 , 80.32 , 537 },
{- 558.93 , - 1190.65 , 42.50 , 537 },
{- 83.33 , - 1018.00 , 16.84 , 537 },
{ 538.05 , - 1155.44 , 8.27 , 537 },
{ 791.35 , - 1345.59 , - 1.00 , 537 },
{ 1189.56 , - 1770.30 , - 3.79 , 537 },
{ 1556.37 , - 1953.71 , 14.00 , 537 },
{ 2175.76 , - 1954.40 , 14.53 , 537 },
{ 2204.34 , - 1699.10 , 14.08 , 537 },
{ 2257.77 , - 1537.64 , 20.53 , 537 },
{ 2288.88 , - 1286.33 , 24.37 , 537 },
{ 2288.89 , - 994.98 , 27.14 , 537 },
{ 2155.91 , - 668.54 , 52.71 , 537 },
{ 2202.36 , - 361.16 , 47.50 , 537 },
{ 2535.74 , - 286.95 , 16.52 , 537 },]]--
}
for i , v in pairs ( pojazd_1 ) do
local vehicle = createVehicle ( v [ 4 ], v [ 1 ], v [ 2 ], v [ 3 ])
setElementSpeed ( vehicle , "mph" , 200 )
end
Wysłany: 2017-06-22, 12:35
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Artystek , spr?buj tak:
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
function setElementSpeed ( element , unit , speed )
if ( unit == nil ) then unit = 0 end
if ( speed == nil ) then speed = 0 end
speed = tonumber ( speed )
local acSpeed = getElementSpeed ( element , unit )
if ( acSpeed ~= false ) then -- if true - element is valid , no 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 , z = getElementVelocity ( element )
setElementVelocity ( element , x * diff , y * diff , z * diff )
return true
end
return false
end
local pojazd_1 = {
{ 1746.35 ,- 1957.75 , 15.10 , 537 },
{ 740.64 , 2023.47 , 7.15 , 449 },
{ 742.53 , 1779.43 , 5.96 , 569 },
--[[{ 642.31 , 1308.85 , 12.25 , 537 },
{ 257.28 , 1224.27 , 23.25 , 537 },
{- 248.28 , 1267.44 , 28.33 , 537 },
{- 834.85 , 1068.77 , 34.99 , 537 },
{- 1571.64 , 533.22 , 33.22 , 537 },
{- 1943.75 , 148.01 , 26.12 , 537 },
{- 1973.18 , - 437.06 , 26.12 , 537 },
{- 1925.04 , - 1175.62 , 14.60 , 537 },
{- 1543.58 , - 1499.80 , 17.90 , 537 },
{- 1236.99 , - 1515.11 , 30.47 , 537 },
{- 829.63 , - 1299.73 , 80.32 , 537 },
{- 558.93 , - 1190.65 , 42.50 , 537 },
{- 83.33 , - 1018.00 , 16.84 , 537 },
{ 538.05 , - 1155.44 , 8.27 , 537 },
{ 791.35 , - 1345.59 , - 1.00 , 537 },
{ 1189.56 , - 1770.30 , - 3.79 , 537 },
{ 1556.37 , - 1953.71 , 14.00 , 537 },
{ 2175.76 , - 1954.40 , 14.53 , 537 },
{ 2204.34 , - 1699.10 , 14.08 , 537 },
{ 2257.77 , - 1537.64 , 20.53 , 537 },
{ 2288.88 , - 1286.33 , 24.37 , 537 },
{ 2288.89 , - 994.98 , 27.14 , 537 },
{ 2155.91 , - 668.54 , 52.71 , 537 },
{ 2202.36 , - 361.16 , 47.50 , 537 },
{ 2535.74 , - 286.95 , 16.52 , 537 },]]--
}
for i , v in pairs ( pojazd_1 ) do
local vehicle = createVehicle ( v [ 4 ], v [ 1 ], v [ 2 ], v [ 3 ])
if vehicle then
setElementSpeed ( vehicle , 1 , 50 )
end
end
Wysłany: 2017-06-22, 12:49
Artystek
Wiek: 23 Na forum: 3520 dni Posty: 143
Nick w MP: Artystek
Piwa : 74
Wysłany: 2017-06-22, 13:19
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Artystek , zobacz tak:
for i , v in pairs ( pojazd_1 ) do
local vehicle = createVehicle ( v [ 4 ], v [ 1 ], v [ 2 ], v [ 3 ])
setTrainSpeed ( vehicle , 1 ) -- Set the train speed to 1 - 100mph , 160kmh
end
Wysłany: 2017-06-22, 13:22
Artystek
Wiek: 23 Na forum: 3520 dni Posty: 143
Nick w MP: Artystek
Piwa : 74
A funkcje wy?ej te? zmienia? na setTrainSpeed?
Wysłany: 2017-06-22, 13:30
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
local pojazd_1 = {
{ 1746.35 ,- 1957.75 , 15.10 , 537 },
{ 740.64 , 2023.47 , 7.15 , 449 },
{ 742.53 , 1779.43 , 5.96 , 569 },
--[[{ 642.31 , 1308.85 , 12.25 , 537 },
{ 257.28 , 1224.27 , 23.25 , 537 },
{- 248.28 , 1267.44 , 28.33 , 537 },
{- 834.85 , 1068.77 , 34.99 , 537 },
{- 1571.64 , 533.22 , 33.22 , 537 },
{- 1943.75 , 148.01 , 26.12 , 537 },
{- 1973.18 , - 437.06 , 26.12 , 537 },
{- 1925.04 , - 1175.62 , 14.60 , 537 },
{- 1543.58 , - 1499.80 , 17.90 , 537 },
{- 1236.99 , - 1515.11 , 30.47 , 537 },
{- 829.63 , - 1299.73 , 80.32 , 537 },
{- 558.93 , - 1190.65 , 42.50 , 537 },
{- 83.33 , - 1018.00 , 16.84 , 537 },
{ 538.05 , - 1155.44 , 8.27 , 537 },
{ 791.35 , - 1345.59 , - 1.00 , 537 },
{ 1189.56 , - 1770.30 , - 3.79 , 537 },
{ 1556.37 , - 1953.71 , 14.00 , 537 },
{ 2175.76 , - 1954.40 , 14.53 , 537 },
{ 2204.34 , - 1699.10 , 14.08 , 537 },
{ 2257.77 , - 1537.64 , 20.53 , 537 },
{ 2288.88 , - 1286.33 , 24.37 , 537 },
{ 2288.89 , - 994.98 , 27.14 , 537 },
{ 2155.91 , - 668.54 , 52.71 , 537 },
{ 2202.36 , - 361.16 , 47.50 , 537 },
{ 2535.74 , - 286.95 , 16.52 , 537 },]]--
}
for i , v in pairs ( pojazd_1 ) do
local vehicle = createVehicle ( v [ 4 ], v [ 1 ], v [ 2 ], v [ 3 ])
setTrainSpeed ( vehicle , 1 ) -- Set the train speed to 1 - 100mph , 160kmh
end
Wysłany: 2017-06-22, 13:37
Artystek
Wiek: 23 Na forum: 3520 dni Posty: 143
Nick w MP: Artystek
Piwa : 74
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
function setElementSpeed ( element , unit , speed )
if ( unit == nil ) then unit = 0 end
if ( speed == nil ) then speed = 0 end
speed = tonumber ( speed )
local acSpeed = getElementSpeed ( element , unit )
if ( acSpeed ~= false ) then -- if true - element is valid , no 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 , z = getElementVelocity ( element )
setElementVelocity ( element , x * diff , y * diff , z * diff )
return true
end
return false
end
local pojazd_1 = {
{ 1746.35 ,- 1957.75 , 15.10 , 537 },
{ 740.64 , 2023.47 , 7.15 , 449 },
{ 742.53 , 1779.43 , 5.96 , 569 },
--[[{ 642.31 , 1308.85 , 12.25 , 537 },
{ 257.28 , 1224.27 , 23.25 , 537 },
{- 248.28 , 1267.44 , 28.33 , 537 },
{- 834.85 , 1068.77 , 34.99 , 537 },
{- 1571.64 , 533.22 , 33.22 , 537 },
{- 1943.75 , 148.01 , 26.12 , 537 },
{- 1973.18 , - 437.06 , 26.12 , 537 },
{- 1925.04 , - 1175.62 , 14.60 , 537 },
{- 1543.58 , - 1499.80 , 17.90 , 537 },
{- 1236.99 , - 1515.11 , 30.47 , 537 },
{- 829.63 , - 1299.73 , 80.32 , 537 },
{- 558.93 , - 1190.65 , 42.50 , 537 },
{- 83.33 , - 1018.00 , 16.84 , 537 },
{ 538.05 , - 1155.44 , 8.27 , 537 },
{ 791.35 , - 1345.59 , - 1.00 , 537 },
{ 1189.56 , - 1770.30 , - 3.79 , 537 },
{ 1556.37 , - 1953.71 , 14.00 , 537 },
{ 2175.76 , - 1954.40 , 14.53 , 537 },
{ 2204.34 , - 1699.10 , 14.08 , 537 },
{ 2257.77 , - 1537.64 , 20.53 , 537 },
{ 2288.88 , - 1286.33 , 24.37 , 537 },
{ 2288.89 , - 994.98 , 27.14 , 537 },
{ 2155.91 , - 668.54 , 52.71 , 537 },
{ 2202.36 , - 361.16 , 47.50 , 537 },
{ 2535.74 , - 286.95 , 16.52 , 537 },]]--
}
for i , v in pairs ( pojazd_1 ) do
local vehicle = createVehicle ( v [ 4 ], v [ 1 ], v [ 2 ], v [ 3 ])
setTrainSpeed ( vehicle , 1 ) -- Set the train speed to 1 - 100mph , 160kmh
end
Nie wyrzuca b??d?w, ale poci?g stoi
Tagi: pociągi
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: