Hej;) Potrzebuje ma?ej pomocy, mianowici? jetsem w trakcie rozbudowywania skryptu na Limiter pr?dko?ci. Obecnie dzia?a on na zasadzie zmiany maksymalnej pr?dko?ci pojazdu poprzez setVehicleHandling, jednak zauwa?y?em ?e ten handling lubi si? bugowa?.
W zwi?zku z tym chc? zrobi? tak, by po przekroczeniu np poziomu 1go, czyli 20kmh, skrypt p?ynnie zmniejsza? pr?dko?? aby pojazd nie jecha? wi?cej. Fragment kodu:
function cvs(player)
if getElementData(veh, "poziom") == "0" then return end
local sx,sy,sz = getElementVelocity(veh)
local spd = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
if getElementData(veh, "poziom") == "1" and spd > 20 then
setElementVelocity(veh, sx*0.95, sy*0.95, sz*0.95)
function cvs()
if not isPedInVehicle(localPlayer) then return end
local veh = getPedOccupierdVehicle(localPlayer)
if getElementData(veh, "poziom") == "0" then return end
local sx,sy,sz = getElementVelocity(veh)
local spd = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
if getElementData(veh, "poziom") == "1" and spd > 20 then
setElementVelocity(veh, sx*0.95, sy*0.95, sz*0.95)
end
end
setTimer(cvs, 1000,0)
=DC=, jeste? wielki:P
Pojawi?o si? jednak kilka problem?w:
-w podrasowanych pojazdach(zmieniony handling) ten kod ledwie przyhamuje pojazd
-przy ograniczeniu na 90, pojazdem prawie nie da si? sterowa? (setElementVelocity pcha go do przodu, przez co skr?ca jak stary jelcz )
PS. Gratuluje =DC=, w?a?nie Ci wybi?o r?wniutkie 365 dni obecno?ci na GTAO^^
[ Dodano: 2016-08-15, 01:13 ]
Tzn, mam taki kod, ale jest on po stronie serwera. I moje pytanie dodatkowe, czy lepiej taki kod spowalniaj?cy pojazd da? po s-side czy c-side?
function cvs(player)
if not veh or getElementData(veh, "poziom") == "0" then return end
local sx,sy,sz = getElementVelocity(veh)
local spd = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
if getElementData(veh, "poziom") == "1" and spd > 20 then
setElementVelocity(veh, sx*0.95, sy*0.95, sz*0.95)
elseif getElementData(veh, "poziom") == "2" and spd > 60 then
setElementVelocity(veh, sx*0.99, sy*0.99, sz*0.99)
elseif getElementData(veh, "poziom") == "3" and spd > 90 then
setElementVelocity(veh, sx*0.99, sy*0.99, sz*0.99)
elseif getElementData(veh, "poziom") == "4" and spd > 140 then
setElementVelocity(veh, sx*0.99, sy*0.99, sz*0.99)
end
end
do tej funkcji cvs s? oczywi?cie timery, kt?re laguj?, wi?c 2 pytanie, jest jaki? inny spos?b ni? timery?
PS. Gratuluje =DC=, w?a?nie Ci wybi?o r?wniutkie 365 dni obecno?ci na GTAO^^
Dzi?ki
A co do skryptu
Pojawi?o si? jednak kilka problem?w:
-w podrasowanych pojazdach(zmieniony handling) ten kod ledwie przyhamuje pojazd
-przy ograniczeniu na 90, pojazdem prawie nie da si? sterowa? (setElementVelocity pcha go do przodu, przez co skr?ca jak stary jelcz )
Ledwo go przyhamuje bo musia?by? da? tam warto?ci mniejsze ni? 0.99
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9) --sam takie co? u?ywam :)
A co do skr?cania jak starem to nie zauwa?y?em u siebie takiego problemu By? mo?e pogrzebanie w handlingu co? zmieni, jednak najpierw spr?buj zamieni? t? linijk? co ci poda?em. I wed?ug mnie lepiej da? to po stronie client bo nie trzeba filtrowa? ka?dego gracza z osobna czy jest w poje?dzie i czy ma ograniczenie itp.
do tej funkcji cvs s? oczywi?cie timery, kt?re laguj?, wi?c 2 pytanie, jest jaki? inny spos?b ni? timery?
Oczywi?cie, ?e jest inny spos?b ale to te? mo?e generowa? "lagi"
W opisie tej funkcji jest napisane:
This event is triggered every time GTA renders a new frame czyli wydarzenie b?dzie wykonywane za ka?dym razem kiedy GTA wyrenderuje now? klatk? co zale?y ju? od seta komputera gracza. Im wi?cej generuje fps tym cz??ciej wywo?uje funkcje.
Ja na swoim serwerze nie zauwa?y?em specjalnych lag?w spowodowanych u?ywaniem timera i tobie te? polecam uzywanie tego:
Ledwo go przyhamuje bo musia?by? da? tam warto?ci mniejsze ni? 0.99
Albo u?y? setVehicleTurnVelocity, na 100% by rozwi?za?o problem, tylko ?e tego ja nigdy w ?yciu nie u?ywa?em wcze?niej, nie wiem z czym to si? gryzie
Za chwilk? sprawdz?, tylko musze temu ch?opakowi pom?c. A ju? nie mam pomys??w
function cvs()
local veh = getPedOccupiedVehicle(localPLlayer)
if (not veh) or getElementData(veh, "poziom") == "0" then return end
local sx,sy,sz = getElementVelocity(veh)
local spd = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*151)
if getElementData(veh, "poziom") == "1" and spd > 20 then
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9)
elseif getElementData(veh, "poziom") == "2" and spd > 60 then
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9)
elseif getElementData(veh, "poziom") == "3" and spd > 90 then
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9)
elseif getElementData(veh, "poziom") == "4" and spd > 140 then
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9)
end
end
setTimer(cvs, 1000,0)
=DC=, jak tu Cie nie lubi? Wszystko dzia?a elegancko.
+Rep
+10 do zajebisto?ci
+5 do inteligencji
+3 do umiej?tno?ci lua
Dodam Ci? jako wsp??autora cz??ci kodu, rzecz jasna Wiem,napiszesz ?e nie musz?, bo dla Ciebie to ma?y kod ale. CHodzi o sam fakt:) Gdyby nie ten kod to skrypt w og?le by nie dzia?a?
[ Dodano: 2016-08-15, 18:56 ]
aha, s?uchaj :>
Jak np, w pojezdzie jest kierowca i pasa?er, prawda? ograniczenie jest ustawione na 90 np, i kierowca wyskoczy, to ?eby pojazd sam, lub z pasa?erem si? nie spowalnia?, to taki kod
if getVehicleController(veh) == player then
powinien pom?c?
wiem ?e rzadko kiedy kto? takie rzeczy robi, i ?e to wydaje si? ?mieszne, ale wiesz...Ja tak ju? mam;) ?e zanim co? wydam, to staram si? usun?? jak najwi?cej bug?w.
function cvs()
local veh = getPedOccupiedVehicle(localPLlayer)
if not getVehicleOccupant(veh, 0) then return end
if (not veh) or getElementData(veh, "poziom") == "0" then return end
local sx,sy,sz = getElementVelocity(veh)
local spd = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*151)
if getElementData(veh, "poziom") == "1" and spd > 20 then
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9)
elseif getElementData(veh, "poziom") == "2" and spd > 60 then
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9)
elseif getElementData(veh, "poziom") == "3" and spd > 90 then
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9)
elseif getElementData(veh, "poziom") == "4" and spd > 140 then
setElementVelocity(veh, sx*0.9, sy*0.9, sz*0.9)
end
end
setTimer(cvs, 1000,0)
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