Wysłany: 2020-09-14, 17:42
TheSebaPL
Mod-team
Wiek: 21 Na forum: 3098 dni Posty: 964
Piwa : 3102
Witam, mam pytanie mam zrobione ograniczenie pr?dko?ci zrobione w danym miejscu aczkolwiek chcia?bym aby frakcje nie mia?y ograniczenia.
M?g?by kto? poda? przyk?ad ?
Wysłany: 2020-09-14, 18:16
NotPaladyn
Wiek: 23 Na forum: 2790 dni Posty: 866
Nick w MP: NotPaladyn
Piwa : 3135
Vice Admin: Jeśli potrzebujesz pomocy w sprawach organizacyjnych lub technicznych - skontaktuj się ze mną .
Fajnie jakby? poda? kod, no ale co?
Skoro definiowany jest w kodzie pojazd to mo?esz ustali? aby np. danemu z element dat? nie dzia?a?o
Nadaj pojazdom frakcyjn? eldate jak?? i potem w kodzie
if getElementData ( vehicle , "pojazdfrakcja" ) == true then return end
Wysłany: 2020-09-14, 18:50
TheSebaPL
Mod-team
Wiek: 21 Na forum: 3098 dni Posty: 964
Piwa : 3102
Kod: function getElementSpeed(theElement, unit)
assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
assert(getElementType(theElement) == "player" or getElementType(theElement) == "ped" or getElementType(theElement) == "object" or getElementType(theElement) == "vehicle", "Invalid element type @ getElementSpeed (player/ped/object/vehicle expected, got " .. getElementType(theElement) .. ")")
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)")
unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
return (Vector3(getElementVelocity(theElement)) * mult).length
end -- kod na pobrane predkosci
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 shape=createColCuboid(949.93, -1483.48, 12.54, 100.64, 67.54, 17.26)
local shape=createColCuboid(1055.04, -1501.99, 12.55, 134.99, 114.11, 42.59)
setDevelopmentMode(true)
setElementData(shape,"maxpredkosc",55)
setTimer(function()
for k,v in ipairs (getElementsWithinColShape (shape,"vehicle" ) ) do
if getElementSpeed(v,1)>getElementData(shape,"maxpredkosc") then
setElementSpeed(v,1,getElementData(shape,"maxpredkosc")-5)
end
end
end,50,0)
Podaj? kod tak?e je?eli chodzi o eldat? nie mo?na da? ?e je?li dana osoba jest na s?u?bie to nie obowi?zuje j? to?
Wysłany: 2020-09-14, 21:36
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
No to pobieraj t? element dat? i sprawdzaj czy jest na s?u?bie.
Tagi: ograniczenie :: prędkości
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: