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

Wysłany: 2019-12-25, 19:38


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3059 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

Siemka, mam problem z triggerowaniem funkcji z servera do clienta.
Tworz? kod po cliencie i chcia?bym aby po wykonaniu czynno?ci o kt?rej jest mowa w c.lua zmieni?o mi handling, i musz? to zrobi? po s.lua i triggerem do clienta.

Lecz nie za bardzo wychodzi mi zrobienie triggera.
Tutaj daje potrzebny kod:

s.lua:

function getVehicleHandlingProperty elementproperty )
    if isElement element ) and getElementType element ) == "vehicle" and type property ) == "string" then
        local handlingTable getVehicleHandling element ) 
        local value handlingTable[property] 
 
        if value then
            return value
        end
    end
 
    return false
end


addEvent("handling"true)
addEventHandler("handling"resourceRoot, function()
        local fast getVehicleHandlingProperty(pVehicle,"engineAcceleration")
        local maxfast getVehicleHandlingProperty(pVehicle,"maxVelocity")
        setVehicleHandling(pVehicle,"engineAcceleration",fast+15)
        setVehicleHandling(pVehicle"maxVelocity",maxfast+500)
end)




c.lua:

    if isPedInVehicle(localPlayerthen 
        local pVehicle getPedOccupiedVehicle(localPlayer)
                triggerServerEvent("handling"pVehiclelocalPlayer)


W cliencie jest jeszcze wcze?niej kod, ale nie jest on potrzebny ?eby go tu poda?, bo chodzi tylko o wykonaniu triggera.

[ Dodano: 2019-12-25, 19:38 ]
endy i wszystko jest dobrze napisane, b?ed?w db3 nie ma

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-25, 23:28


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Zamie? gracza i zmienn? pojazdu miejscem, potem w evencie po serwerze dodaje argument funkcji z tak? sam? zmienn? jak? potem wykorzystujesz.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-26, 00:18


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3059 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

Zrobi?em tak i nie dzia?a dalej
Zapewne zrobi?em co? ?le, m?g?by? powiedzie? co dok?adnie?

server

function getVehicleHandlingProperty elementproperty )
    if isElement element ) and getElementType element ) == "vehicle" and type property ) == "string" then
        local handlingTable getVehicleHandling element ) 
        local value handlingTable[property] 
 
        if value then
            return value
        end
    end
 
    return false
end


addEvent("handling"true)
addEventHandler("handling"resourceRoot, function(pVehicleplr)
        local pVehicle getPedOccupiedVehicle(plr)
        local fast getVehicleHandlingProperty(pVehicle,"engineAcceleration")
        local maxfast getVehicleHandlingProperty(pVehicle,"maxVelocity")
        setVehicleHandling(pVehicle,"engineAcceleration",fast+15)
        setVehicleHandling(pVehicle"maxVelocity",maxfast+500)
end)



client

triggerServerEvent("handling"localPlayerpVehicle)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-26, 21:14


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Nie musisz pobiera? pojazdu, w kt?rym gracz siedzi bo nie zwracasz tego gracza. Je?eli ju? to musisz u?y? 'client', kt?ry wywo?a? event. Ale pojazd u?ywasz od razu 'pVehicle', usu? linijk?
        local pVehicle getPedOccupiedVehicle(plr)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-26, 23:06


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3059 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

Mam tak i nie dzia?a:

client

triggerServerEvent("handling"localPlayerpVehicle)



server

addEvent("handling"true)
addEventHandler("handling"resourceRoot, function(theVehicleplr)
        local fast getVehicleHandlingProperty(theVehicle,"engineAcceleration")
        local maxfast getVehicleHandlingProperty(theVehicle,"maxVelocity")
        setVehicleHandling(theVehicle,"engineAcceleration",fast+15)
        setVehicleHandling(theVehicle"maxVelocity",maxfast+500)
end)


Tam gdzie w serwerze jest theVehicle jak by?o pVehicle to te? nie dzia?a.

Nie rozumiem za bardzo co mam ?le

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-26, 23:19


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150

Tutaj jest b??d:

triggerServerEvent("handling"localPlayerpVehicle)


Jak powinno wygl?da?:

triggerServerEvent("handling"resourceRootpVehiclelocalPlayer)


domy?lam si? ?e triggerem chcia?e? wys?a? pojazd, jednak?e musisz zwraca? uwag? na kolejno?? - w evencie "handling" handling nak?adasz do pierwszego argumentu, tak?e w triggerServerEvent to w?a?nie pojazd musisz wys?a? jako pierwszy. W drugim argumencie masz "plr" - player, czyli gracza wysy?asz jako drugiego.

resourceRoot - powiem napro?ciej, miejsce lokalizacji eventu kt?rego wysy?amy, je?li ten sam skrypt odbiera i wysy?a event najlepiej stosowa? "resourceRoot", je?li inny skrypt wtedy "root"

Poczytaj:


Więcej informacji znajdziesz w Wikipedii MTA:

triggerServerEvent


mam nadziej? ?e jasno wyja?ni?em

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-26, 23:48


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Po co wprowadza? zmienn? localPlayer w triggerze, skoro po serwerze mo?emy u?y? zmiennej globalnej 'client'? Na Wiki, kt?re wklei?e?, jest to w czerwonej ramce.

Ostatnio zmieniony przez Wilq 2019-12-26, 23:50, w całości zmieniany 2 razy  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-26, 23:48


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3059 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

A po stronie servera zmienna w tym handlingu musi byc pVehicle czy theVehicle?

[ Dodano: 2019-12-26, 23:49 ]
Jak to ma wygl?da??
Bo Szypki_exe, mowi inaczej i ty Wilq, te? i ju? nie wiem.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-26, 23:50


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

triggerServerEvent("handling",?resourceRoot,?pVehicle)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 00:01


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3059 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

Dzi?ki
A po stronie servera jak to powinno wygl?dac?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 00:04


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Jak poprzednio, mo?esz usun?? argument plr z funkcji.

Postaw piwo autorowi tego posta
 

 
Tagi: trigger
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » trigger Odpowiedz do tematu

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