Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2016-08-13, 20:28


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

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
--tutaj nie wiem czego u?y?


Ten kod
local sx,sy,sz getElementVelocity(veh)
    local spd math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)

konwertuje pr?dko?? pojazdu na km/h. Nie wiem czy to w og?le si? przyda/jest potrzebne, ale na wszelki wypadek, jest.
Za pomoc oczywi?cie poleci repka, bo to nie jest takie ?atwe do zrobienia.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-13, 21:38


=DC=







Wiek: 35
Na forum: 3944 dni
Posty: 223
Nick w MP: =DC=

Piwa: 72

Respekt: 150
Respekt: 150Respekt: 150


Więcej informacji znajdziesz w Wikipedii MTA:

setElementVelocity
to rozwi??e tw?j problem :)

 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(vehsx*0.95sy*0.95sz*0.95)


Podpis

Witaj
, jeśli Ci pomogłem postaw mi :piwo: lub R* Dzięki!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-14, 04:38


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

=DC=, wiem ?e tej funkcji trzeba u?y? :P (przepraszam, nie zawar?em tego w tre?ci mojego problemu) Tylko pytanie, jak to zrobi??;>

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-14, 21:40


=DC=







Wiek: 35
Na forum: 3944 dni
Posty: 223
Nick w MP: =DC=

Piwa: 72

Respekt: 150
Respekt: 150Respekt: 150

Zr?b tak - powinno ?miga? :P

Client-Side jakby co :)

function cvs()
    if not isPedInVehicle(localPlayerthen 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(vehsx*0.95sy*0.95sz*0.95)
    end
end
setTimer(cvs1000,0)


Podpis

Witaj
, jeśli Ci pomogłem postaw mi :piwo: lub R* Dzięki!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-15, 00:18


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

=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 :P )

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(vehsx*0.95sy*0.95sz*0.95)
    elseif getElementData(veh"poziom") == "2" and spd 60 then
        setElementVelocity(vehsx*0.99sy*0.99sz*0.99)
    elseif getElementData(veh"poziom") == "3" and spd 90 then
        setElementVelocity(vehsx*0.99sy*0.99sz*0.99)
    elseif getElementData(veh"poziom") == "4" and spd 140 then
        setElementVelocity(vehsx*0.99sy*0.99sz*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?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-15, 16:10


=DC=







Wiek: 35
Na forum: 3944 dni
Posty: 223
Nick w MP: =DC=

Piwa: 72

Respekt: 150
Respekt: 150Respekt: 150

Cytat:

PS. Gratuluje =DC=, w?a?nie Ci wybi?o r?wniutkie 365 dni obecno?ci na GTAO^^

Dzi?ki :P

A co do skryptu
Cytat:

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 :P )

Ledwo go przyhamuje bo musia?by? da? tam warto?ci mniejsze ni? 0.99

 setElementVelocity(vehsx*0.9sy*0.9sz*0.9) --sam takie cou?ywam :)

A co do skr?cania jak starem to nie zauwa?y?em u siebie takiego problemu :D 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.



Cytat:

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"

Więcej informacji znajdziesz w Wikipedii MTA:

onClientRender

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:
setTimer(cvs1000,0)
Cay kod po stronie clienta :P

Podpis

Witaj
, jeśli Ci pomogłem postaw mi :piwo: lub R* Dzięki!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-15, 16:43


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

"=DC=" napisał/a:

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 :D
Za chwilk? sprawdz?, tylko musze temu ch?opakowi pom?c. A ju? nie mam pomys??w

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-15, 18:19


=DC=







Wiek: 35
Na forum: 3944 dni
Posty: 223
Nick w MP: =DC=

Piwa: 72

Respekt: 150
Respekt: 150Respekt: 150

Spr?buj da? ten kod c-side i zobaczymy co dalej :P

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(vehsx*0.9sy*0.9sz*0.9)
    elseif getElementData(veh"poziom") == "2" and spd 60 then
        setElementVelocity(vehsx*0.9sy*0.9sz*0.9)
    elseif getElementData(veh"poziom") == "3" and spd 90 then
        setElementVelocity(vehsx*0.9sy*0.9sz*0.9)
    elseif getElementData(veh"poziom") == "4" and spd 140 then
        setElementVelocity(vehsx*0.9sy*0.9sz*0.9)
    end
end
setTimer(cvs1000,0)


Podpis

Witaj
, jeśli Ci pomogłem postaw mi :piwo: lub R* Dzięki!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-15, 18:48


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

=DC=, jak tu Cie nie lubi? :P 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.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-15, 19:01


=DC=







Wiek: 35
Na forum: 3944 dni
Posty: 223
Nick w MP: =DC=

Piwa: 72

Respekt: 150
Respekt: 150Respekt: 150

Trzymaj :P

function cvs()
    local veh getPedOccupiedVehicle(localPLlayer)
    if not getVehicleOccupant(veh0then 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(vehsx*0.9sy*0.9sz*0.9)
    elseif getElementData(veh"poziom") == "2" and spd 60 then
        setElementVelocity(vehsx*0.9sy*0.9sz*0.9)
    elseif getElementData(veh"poziom") == "3" and spd 90 then
        setElementVelocity(vehsx*0.9sy*0.9sz*0.9)
    elseif getElementData(veh"poziom") == "4" and spd 140 then
        setElementVelocity(vehsx*0.9sy*0.9sz*0.9)
    end
end
setTimer(cvs1000,0)


Podpis

Witaj
, jeśli Ci pomogłem postaw mi :piwo: lub R* Dzięki!

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-15, 19:24


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

Dzia?a, do zamkni?cia :)

Postaw piwo autorowi tego posta
 

 
Tagi: stopniowe :: spowalnianie
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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
Dodaj temat do Ulubionych
Wersja do druku