Wysłany: 2017-02-24, 20:07
Krzemo1234
Wiek: 26 Na forum: 3751 dni Posty: 387
Nick w MP: Krzemo
Piwa : 16
Mam 60 fps w??czam to i nagle 27-30fps
Kod: createBlip(-1624.73, 690.99, 7.19, 30,2,0,0,0,0,0,275)
function getPointFrontOfElement(element,distance)
if not element then return end
local x, y, z = getElementPosition ( element )
local rx, ry, rz = getElementRotation ( element )
x = x + (distance * (math.sin(math.rad(-rz))) )
y = y + (distance * (math.cos(math.rad(-rz))) )
return x,y,z
end
function getPositionFromElementAtOffset(element,x,y,z)
if not element then return end
if not x or not y or not z then
return x, y, z
end
local matrix = getElementMatrix ( element )
local offX = x * matrix[1][1] + y * matrix[2][1] + z * matrix[3][1] + matrix[4][1]
local offY = x * matrix[1][2] + y * matrix[2][2] + z * matrix[3][2] + matrix[4][2]
local offZ = x * matrix[1][3] + y * matrix[2][3] + z * matrix[3][3] + matrix[4][3]
return offX, offY, offZ
end
function getVehicleWheelPosition(vehicle,wheel)
local x, y, z = 0, 0, 0
local minX, minY, minZ, maxX, maxY, maxZ = getElementBoundingBox(vehicle)
if wheel == 1 then
x, y, z = getPositionFromElementAtOffset(vehicle, minX, maxY, minZ)
elseif wheel == 2 then
x, y, z = getPositionFromElementAtOffset(vehicle, minX, -maxY, minZ)
elseif wheel == 3 then
x, y, z = getPositionFromElementAtOffset(vehicle, maxX, maxY, minZ)
elseif wheel == 4 then
x, y, z = getPositionFromElementAtOffset(vehicle, maxX, -maxY, minZ)
end
return x, y, z
end
function onClientRender()
if isPedInVehicle(localPlayer) then
local vehicle = getPedOccupiedVehicle(localPlayer)
if not vehicle then return end
local stinger = getElementsByType("object")
--local wx0, wy0, wz0 = getVehicleWheelPosition(vehicle,0)
local wx1, wy1, wz1 = getVehicleWheelPosition(vehicle,1)
local wx2, wy2, wz2 = getVehicleWheelPosition(vehicle,2)
local wx3, wy3, wz3 = getVehicleWheelPosition(vehicle,3)
local wx4, wy4, wz4 = getVehicleWheelPosition(vehicle,4)
-- for visual debug wheel positions
--dxDrawLine3D(wx1, wy1, wz1, wx2, wy2, wz2, tocolor(0,255,0))
--dxDrawLine3D(wx3, wy3, wz3, wx4, wy4, wz4, tocolor(0,255,0))
for k, v in pairs(stinger) do
if getElementData(v,"isStinger") == true then
local vx, vy, vz = getElementPosition(v)
if getDistanceBetweenPoints3D(wx1, wy1, wz1, vx, vy, vz) <= 2.0 then
setVehicleWheelStates(vehicle, 1, -1, -1, -1)
end
if getDistanceBetweenPoints3D(wx2, wy2, wz2, vx, vy, vz) <= 2.0 then
setVehicleWheelStates(vehicle, -1, 1, -1, -1)
end
if getDistanceBetweenPoints3D(wx3, wy3, wz3, vx, vy, vz) <= 2.0 then
setVehicleWheelStates(vehicle, -1, -1, 1, -1)
end
if getDistanceBetweenPoints3D(wx4, wy4, wz4, vx, vy, vz) <= 2.0 then
setVehicleWheelStates(vehicle, -1, -1, -1, 1)
end
end
end
end
end
addEventHandler("onClientRender",getRootElement(), onClientRender)
function onCreateStinger(x, y, z)
if(getDistanceBetweenPoints3D(x, y, z, getElementPosition(localPlayer)) <= 10 ) then
local sound = playSound3D("plant.wav", x, y, z)
setSoundMaxDistance(sound, 10)
end
end
addEvent("onCreateStinger", true)
addEventHandler("onCreateStinger", getRootElement(), onCreateStinger)
Wysłany: 2017-02-24, 20:16
_Haze
Peace Yo!
Wiek: 24 Na forum: 4184 dni Posty: 1648
Nick w MP: Haze
Piwa : 2628
Krzemo1234 , onClientRender i na ify to jest a nie na elseify
Wysłany: 2017-02-24, 20:20
Krzemo1234
Wiek: 26 Na forum: 3751 dni Posty: 387
Nick w MP: Krzemo
Piwa : 16
My?lisz ,?e to powoduje spadki ?
[ Dodano : 2017-02-24, 20:23 ]
HazeMaFaze mo?esz mi to troch? wyt?umaczy? jako? inaczej najlepiej na steamie czy co? ?eby nie robi? spamu
[ Dodano : 2017-02-25, 13:35 ]
Pomo?e kto? co w tym kodzie jest nie tak ?
Za pomoc stawiam zimne
Podpis
Jeśli ci pomogłem zostaw zimne
Wysłany: 2017-02-25, 14:27
KukiX
Wiek: 34 Na forum: 6718 dni Posty: 567
Piwa : 17560
"HazeMaFaze" napisał/a :Krzemo1234, onClientRender i na ify to jest a nie na elseify
?e co?
"Krzemo1234" napisał/a :Mam 60 fps w??czam to i nagle 27-30fps
https://wiki.multitheftauto.com/wiki/OnClientRender
Warning
This event and onClientPreRender will trigger whatever function it is attached to with every frame. Depending on the server's maximum FPS and what your computer might handle - you might end up triggering the function 30-60 times per second .
As a result, this event may cause severe lag and/or even crashes if not used cautiously.
W skr?cie to wszystko co da?e? w event onClientRender wykonuje si? oko?o 30-60 razy na sekund? (zale?y od FPS).
Nic dziwnego ?e p?ynno?? gry spada.
Wysłany: 2017-02-25, 14:45
_Haze
Peace Yo!
Wiek: 24 Na forum: 4184 dni Posty: 1648
Nick w MP: Haze
Piwa : 2628
KukiX , moglby zrobic jednego ifa i kilka or
Wysłany: 2017-02-25, 16:29
Krzemo1234
Wiek: 26 Na forum: 3751 dni Posty: 387
Nick w MP: Krzemo
Piwa : 16
takie cu? function onClientRender ()
if isPedInVehicle ( localPlayer ) then
local vehicle = getPedOccupiedVehicle ( localPlayer )
if not vehicle then return end
local stinger = getElementsByType ( "object" )
local wx1 , wy1 , wz1 = getVehicleWheelPosition ( vehicle , 1 )
local wx2 , wy2 , wz2 = getVehicleWheelPosition ( vehicle , 2 )
local wx3 , wy3 , wz3 = getVehicleWheelPosition ( vehicle , 3 )
local wx4 , wy4 , wz4 = getVehicleWheelPosition ( vehicle , 4 )
-- for visual debug wheel positions
-- dxDrawLine3D ( wx1 , wy1 , wz1 , wx2 , wy2 , wz2 , tocolor ( 0 , 255 , 0 ))
-- dxDrawLine3D ( wx3 , wy3 , wz3 , wx4 , wy4 , wz4 , tocolor ( 0 , 255 , 0 ))
for k , v in pairs ( stinger ) do
if getElementData ( v , "isStinger" ) == true then
local vx , vy , vz = getElementPosition ( v )
if getDistanceBetweenPoints3D ( wx1 , wy1 , wz1 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , 1 , - 1 , - 1 , - 1 )
or
getDistanceBetweenPoints3D ( wx2 , wy2 , wz2 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , 1 , - 1 , - 1 )
or
getDistanceBetweenPoints3D ( wx3 , wy3 , wz3 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , - 1 , 1 , - 1 )
or
getDistanceBetweenPoints3D ( wx4 , wy4 , wz4 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , - 1 , - 1 , 1 )
end
end
end
end
end
Podpis
Jeśli ci pomogłem zostaw zimne
Wysłany: 2017-02-25, 16:41
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4150 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
I je?li dajesz onClientRender do tego to co 30/60 razy na sekund? pobiera dystans, pozycje i ustawia stan k??. Co powoduje lagi.
Wysłany: 2017-02-25, 17:59
Krzemo1234
Wiek: 26 Na forum: 3751 dni Posty: 387
Nick w MP: Krzemo
Piwa : 16
Czy m?g?by? mi to zmieni? bo ja zielony
[ Dodano : 2017-02-25, 18:00 ]
createBlip (- 1624.73 , 690.99 , 7.19 , 30 , 2 , 0 , 0 , 0 , 0 , 0 , 275 )
function getPointFrontOfElement ( element , distance )
if not element then return end
local x , y , z = getElementPosition ( element )
local rx , ry , rz = getElementRotation ( element )
x = x + ( distance * ( math . sin ( math . rad (- rz ))) )
y = y + ( distance * ( math . cos ( math . rad (- rz ))) )
return x , y , z
end
function getPositionFromElementAtOffset ( element , x , y , z )
if not element then return end
if not x or not y or not z then
return x , y , z
end
local matrix = getElementMatrix ( element )
local offX = x * matrix [ 1 ][ 1 ] + y * matrix [ 2 ][ 1 ] + z * matrix [ 3 ][ 1 ] + matrix [ 4 ][ 1 ]
local offY = x * matrix [ 1 ][ 2 ] + y * matrix [ 2 ][ 2 ] + z * matrix [ 3 ][ 2 ] + matrix [ 4 ][ 2 ]
local offZ = x * matrix [ 1 ][ 3 ] + y * matrix [ 2 ][ 3 ] + z * matrix [ 3 ][ 3 ] + matrix [ 4 ][ 3 ]
return offX , offY , offZ
end
function getVehicleWheelPosition ( vehicle , wheel )
local x , y , z = 0 , 0 , 0
local minX , minY , minZ , maxX , maxY , maxZ = getElementBoundingBox ( vehicle )
if wheel == 1 then
x , y , z = getPositionFromElementAtOffset ( vehicle , minX , maxY , minZ )
elseif wheel == 2 then
x , y , z = getPositionFromElementAtOffset ( vehicle , minX , - maxY , minZ )
elseif wheel == 3 then
x , y , z = getPositionFromElementAtOffset ( vehicle , maxX , maxY , minZ )
elseif wheel == 4 then
x , y , z = getPositionFromElementAtOffset ( vehicle , maxX , - maxY , minZ )
end
return x , y , z
end
function onClientRender ()
if isPedInVehicle ( localPlayer ) then
local vehicle = getPedOccupiedVehicle ( localPlayer )
if not vehicle then return end
local stinger = getElementsByType ( "object" )
-- local wx0 , wy0 , wz0 = getVehicleWheelPosition ( vehicle , 0 )
local wx1 , wy1 , wz1 = getVehicleWheelPosition ( vehicle , 1 )
local wx2 , wy2 , wz2 = getVehicleWheelPosition ( vehicle , 2 )
local wx3 , wy3 , wz3 = getVehicleWheelPosition ( vehicle , 3 )
local wx4 , wy4 , wz4 = getVehicleWheelPosition ( vehicle , 4 )
-- for visual debug wheel positions
-- dxDrawLine3D ( wx1 , wy1 , wz1 , wx2 , wy2 , wz2 , tocolor ( 0 , 255 , 0 ))
-- dxDrawLine3D ( wx3 , wy3 , wz3 , wx4 , wy4 , wz4 , tocolor ( 0 , 255 , 0 ))
for k , v in pairs ( stinger ) do
if getElementData ( v , "isStinger" ) == true then
local vx , vy , vz = getElementPosition ( v )
if getDistanceBetweenPoints3D ( wx1 , wy1 , wz1 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , 1 , - 1 , - 1 , - 1 )
end
if getDistanceBetweenPoints3D ( wx2 , wy2 , wz2 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , 1 , - 1 , - 1 )
end
if getDistanceBetweenPoints3D ( wx3 , wy3 , wz3 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , - 1 , 1 , - 1 )
end
if getDistanceBetweenPoints3D ( wx4 , wy4 , wz4 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , - 1 , - 1 , 1 )
end
end
end
end
end
addEventHandler ( "onClientRender" , getRootElement (), onClientRender )
function onCreateStinger ( x , y , z )
if( getDistanceBetweenPoints3D ( x , y , z , getElementPosition ( localPlayer )) <= 10 ) then
local sound = playSound3D ( "plant.wav" , x , y , z )
setSoundMaxDistance ( sound , 10 )
end
end
addEvent ( "onCreateStinger" , true )
addEventHandler ( "onCreateStinger" , getRootElement (), onCreateStinger )
[ Dodano : 2017-02-25, 22:03 ]
Prosz? za pomoc zimne
[ Dodano : 2017-02-26, 13:20 ]
?
[ Dodano : 2017-02-26, 13:21 ]
pomo?e kto? ?
[ Dodano : 2017-02-26, 15:11 ]
marcin778 , pomo?esz ?
Podpis
Jeśli ci pomogłem zostaw zimne
Tagi: powoduje :: spadki :: fps.
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: