Szerző Téma: Parancs csak megadott sebesség alatt  (Megtekintve 1087 alkalommal)

Nem elérhető Lömpi

  • 1257
    • Profil megtekintése
Parancs csak megadott sebesség alatt
« Dátum: 2017. Május 28. - 08:53:25 »
0
Sziasztok! Miként tudnám megoldani azt, hogy egy parancsot csak akkor lehessen használni mikor a jármű amiben ül a megadott játékos álló helyzetben legyen, tehát ne guruljon vagy közlekedjen vele?!  getElementVelocity-t probáltam már, de nem igazán jött össze

Parancs csak megadott sebesség alatt
« Válasz #1 Dátum: 2017. Május 28. - 09:26:42 »
0
Hali!
 
 
 
Ezt az egyik modból szedtem, elvileg működik:
 

function getElementSpeed(element,unit)
if (unit == nil) then unit = 0 end
if (isElement(element)) then
   local x,y,z = getElementVelocity(element)
   if (unit==\"mph\" or unit==1 or unit ==\'1\') then
      return (x^2 + y^2 + z^2) ^ 0.5 * 100
   else
      return (x^2 + y^2 + z^2) ^ 0.5 * 161
   end
else
   return false
end
end

 
 

Nem elérhető Lömpi

  • 1257
    • Profil megtekintése
Parancs csak megadott sebesség alatt
« Válasz #2 Dátum: 2017. Május 28. - 11:54:39 »
0
Szia, ezt már én is megtaláltam wikipedian, viszont, unithoz milyen értéket kellene megadnom?

Parancs csak megadott sebesség alatt
« Válasz #3 Dátum: 2017. Május 28. - 13:16:19 »
0
\"kmh\"-t vagy \"mph\"-t. Milyen mértékegységgel jöjjön ki a sebesség a végén. (Igazából 0 vagy 1 -et is adhatnál meg mint igaz vagy hamis csak a szöveg beszédesebb pl \"kmh\")

Parancs csak megadott sebesség alatt
« Válasz #4 Dátum: 2017. Június 09. - 00:25:22 »
0

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

 
Példa:
getElementSpeed(getPedOccupiedVehicle(játékos), 1)
0/\"m/s\" returnolja a m/s értékét az elementnek
1/\"km/h\" returnolja a km/h értékét az elementnek
az element a példa esetében a játékos kocsija.
« Utoljára szerkesztve: 2017. Június 09. - 00:29:09 írta rusztamas »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal