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

Wysłany: 2015-08-16, 00:50


NoNi3zle

Uczeń LUA






Wiek: 25
Na forum: 4319 dni
Posty: 42
Nick w MP: NoNi3zle

Piwa: 78

Respekt: 60

Strona serwera

Kod:

MarkerZielony = createMarker( -2048.30908, 157.13739, 27.9, 'cylinder', 0.75, 17, 255, 0, 255 )
MarkerCzerwony = createMarker( -2048.31665, 155.99012, 27.9, 'cylinder', 0.75, 255, 0, 0, 255 )
MarkerZolty = createMarker( -2048.29638, 154.72756, 27.9, 'cylinder', 0.75, 255, 247, 0, 255 )
MarkerBlekitny = createMarker( -2048.35034, 153.44259, 27.9, 'cylinder', 0.75, 0, 247, 255, 255 )
MarkerRozowy = createMarker( -2048.30883, 152.26870, 27.9, 'cylinder', 0.75, 255, 0, 196, 255 )
MarkerNiebieski = createMarker( -2048.31933, 158.26602, 27.9, 'cylinder', 0.75, 9, 0, 255, 255 )
MarkerNiewidzialny = createMarker ( -2052.80444, 155.28987, 27.9, 'cylinder', 8, 197, 196, 210, 100 )
function zieloneswiatla ()
function zmiennazielone ()
setVehicleHeadLightColor ( Vehicle, 17, 255, 0)
end
end
addEventHandler ("swiatlazielone", getRootElement (), zmiennazielone)


Strona Klienta

Kod:

function zieloneswiatlaclient ()
if isElementWithinMarker (Vehicle, MarkerNiewidzialny) and
if isElementWithinMarker (ThePlayer, MarkerZielony ) then
triggerServerEvent ("swiatlazielone", getRootElement ())
else
outputChatBox ("Na stanowisku nir ma pojazdu, lub kod jest *****", source)
end
end
addEventHandler ("onClientMarkerHit", getRootElement (), zieloneswiatlaclient)


Meta:

Kod:

<meta>
<script src="swiatlatuning.lua" type="server" />
<script src="swiatlatuning_c.lua" type="client" />
</meta>


Po restarcie w konsoli wyskakuje

Kod:

[2015-08-16 00] restart: Requested by Console
[2015-08-16 00] restart: Resource restarting...
[2015-08-16 00] Stopping tuningswiatel
[2015-08-16 00] Starting tuningswiatel
[2015-08-16 00] WARNING: tuningswiatel/swiatlatuning.lua:13: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil]
[2015-08-16 00] tuningswiatel restarted successfully


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 08:51


Fanciak

BOT






Wiek: 26
Na forum: 4587 dni
Posty: 728
Nick w MP: Fanciak

Piwa: 1572

Respekt: 500
Respekt: 500

Aha...?

Sk?d wziales eventhandler swiatlazielone? XDDDDD

Aby dodac sw?j eventhandler dodaj najpierw to:


Więcej informacji znajdziesz w Wikipedii MTA:

addEvent


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 14:08


NoNi3zle

Uczeń LUA






Wiek: 25
Na forum: 4319 dni
Posty: 42
Nick w MP: NoNi3zle

Piwa: 78

Respekt: 60

Aktualnie kod z strony serwera wygl?da tak:
Kod:

MarkerZielony = createMarker( -2048.30908, 157.13739, 27.9, 'cylinder', 0.75, 17, 255, 0, 255 )
MarkerCzerwony = createMarker( -2048.31665, 155.99012, 27.9, 'cylinder', 0.75, 255, 0, 0, 255 )
MarkerZolty = createMarker( -2048.29638, 154.72756, 27.9, 'cylinder', 0.75, 255, 247, 0, 255 )
MarkerBlekitny = createMarker( -2048.35034, 153.44259, 27.9, 'cylinder', 0.75, 0, 247, 255, 255 )
MarkerRozowy = createMarker( -2048.30883, 152.26870, 27.9, 'cylinder', 0.75, 255, 0, 196, 255 )
MarkerNiebieski = createMarker( -2048.31933, 158.26602, 27.9, 'cylinder', 0.75, 9, 0, 255, 255 )
MarkerNiewidzialny = createMarker ( -2052.80444, 155.28987, 27.9, 'cylinder', 8, 197, 196, 210, 100 )
function zmiennazielone ()
setVehicleHeadLightColor ( Vehicle, 17, 255, 0)
end
addEventHandler ("onClientMarkerHit", getRootElement (), zmiennazielone)
i nadal nie dzia?a :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 14:22


Tostuch







Wiek: 28
Na forum: 5072 dni
Posty: 483
Nick w MP: Tost

Piwa: 137

Respekt: 110
Respekt: 110

addEventHandler ("onMarkerHit", getRootElement (), zmiennazielone)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 14:48


NoNi3zle

Uczeń LUA






Wiek: 25
Na forum: 4319 dni
Posty: 42
Nick w MP: NoNi3zle

Piwa: 78

Respekt: 60

nadal nie dzia?a :/

[ Dodano: 2015-08-16, 14:52 ]
Aktualnie to wygl?da tak:

Serwer:
Kod:

MarkerZielony = createMarker( -2048.30908, 157.13739, 27.9, 'cylinder', 0.75, 17, 255, 0, 255 )
MarkerCzerwony = createMarker( -2048.31665, 155.99012, 27.9, 'cylinder', 0.75, 255, 0, 0, 255 )
MarkerZolty = createMarker( -2048.29638, 154.72756, 27.9, 'cylinder', 0.75, 255, 247, 0, 255 )
MarkerBlekitny = createMarker( -2048.35034, 153.44259, 27.9, 'cylinder', 0.75, 0, 247, 255, 255 )
MarkerRozowy = createMarker( -2048.30883, 152.26870, 27.9, 'cylinder', 0.75, 255, 0, 196, 255 )
MarkerNiebieski = createMarker( -2048.31933, 158.26602, 27.9, 'cylinder', 0.75, 9, 0, 255, 255 )
MarkerNiewidzialny = createMarker ( -2052.80444, 155.28987, 27.9, 'cylinder', 8, 197, 196, 210, 100 )
function zmiennazielone ()
setVehicleHeadLightColor ( Vehicle, 17, 255, 0)
end
addEventHandler ("onMarkerHit", getRootElement (), zmiennazielone)


Klient
Kod:

function zieloneswiatlaclient ()
if isElementWithinMarker (Vehicle, MarkerNiewidzialny) and
if isElementWithinMarker (ThePlayer, MarkerZielony ) then
triggerServerEvent ("zmiennazielone", getRootElement ())
else
outputChatBox ("Na stanowisku nir ma pojazdu, lub kod jest *****", source)
end
end
addEventHandler ("onMarkerHit", getRootElement (), zieloneswiatlaclient)


[ Dodano: 2015-08-16, 14:54 ]
i w konsoli podczas restartu wyskakuje:
Kod:

[2015-08-16 14:53] WARNING: tuningswiatel/swiatlatuning.lua:9: Bad argument @ 'setVehicleHeadLightColor' [Expected vehicle at argument 1, got nil]


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 17:13


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%

function zmiennazielone () 
setVehicleHeadLightColor ( Vehicle, 17, 255, 0) 


No wlasnie, jak ma dzia?a?, skoro "Vehicle" tak na dobr? sprawe nie istnieje...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 17:42


NoNi3zle

Uczeń LUA






Wiek: 25
Na forum: 4319 dni
Posty: 42
Nick w MP: NoNi3zle

Piwa: 78

Respekt: 60

To znaczy, ?e musz? jako? z argumentowa? co to jest theVehicle tak? Jak mam to zrobi??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 18:09


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
Czekaj czekaj, co ty chcesz zdzia?a? tutaj, bo ja sam si? ju? pogubi?em, jestem teraz na pc i po analizie kodu mam w?tpliwo?ci co ty tym chcesz zdzia?a?. I przez jak? form? ? GUI ? Jedynie markery czy o co dok?adnie Ci chodzi ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 18:17


NoNi3zle

Uczeń LUA






Wiek: 25
Na forum: 4319 dni
Posty: 42
Nick w MP: NoNi3zle

Piwa: 78

Respekt: 60

Samoch?d musi by? w niewidzialnym Markerze. Nast?pnie gracz musi wyj?? samochodu i wej?? w zielony marker aby ?wiat?a zmieni?y kolor na zielony itd.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 18:24


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%

MarkerZielony = createMarker( -2048.30908, 157.13739, 27.9, 'cylinder', 0.75, 17, 255, 0, 255 ) 
MarkerCzerwony = createMarker( -2048.31665, 155.99012, 27.9, 'cylinder', 0.75, 255, 0, 0, 255 ) 
MarkerZolty = createMarker( -2048.29638, 154.72756, 27.9, 'cylinder', 0.75, 255, 247, 0, 255 ) 
MarkerBlekitny = createMarker( -2048.35034, 153.44259, 27.9, 'cylinder', 0.75, 0, 247, 255, 255 ) 
MarkerRozowy = createMarker( -2048.30883, 152.26870, 27.9, 'cylinder', 0.75, 255, 0, 196, 255 ) 
MarkerNiebieski = createMarker( -2048.31933, 158.26602, 27.9, 'cylinder', 0.75, 9, 0, 255, 255 ) 


MarkerNiewidzialny = createMarker ( -2052.80444, 155.28987, 27.9, 'cylinder', 8, 197, 196, 210, 100 ) 

function ZmienSwiatla (hitElement)
if pojazdwmarkerze(markerNiewidzialny) > 1 then return outputChatBox("Za duzo pojazd?w", hitElement) end
if pojazdwmarkerze(markerNiewidzialny) < 1 then return outputChatBox("Za ma?o pojazd?w", hitElement) end
            if source == MarkerZielony then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny), 17, 255, 0)
            elseif source == MarkerCzerwony then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny), 17, 255, 0)
            elseif source == MarkerZolty then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny), 17, 255, 0)
            elseif source == MarkerBlekitny then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny), 17, 255, 0)
            elseif source == MarkerRozowy then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny), 17, 255, 0)
            elseif source == MarkerNiebieski then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny), 17, 255, 0)
            end
end 
addEventHandler ("onMarkerHit", getRootElement (), ZmienSwiatla)



function pojazdwmarkerze(marker)
    if (not isElement(marker) or getElementType(marker) ~= "marker") then
        return false
    end
    local markerColShape = getElementColShape(marker)
    local elements = getElementsWithinColShape(markerColShape)
    return elements
end


Po stronie serwer'a, powinno dzia?a?, tylko kolor?w ?wiate? nie zmienia?em (nie testowane jak by co?)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 18:35


NoNi3zle

Uczeń LUA






Wiek: 25
Na forum: 4319 dni
Posty: 42
Nick w MP: NoNi3zle

Piwa: 78

Respekt: 60

Nie dzia?a oto b??d kt?ry wyskakuje:

Kod:

[2015-08-16 18] ERROR: tuningswiatel/swiatlatuning.lua:12: attempt to compare number with boolean


Podmie? 12 i 13 linijk?


if tonumber(pojazdwmarkerze(markerNiewidzialny)) > 1 then return outputChatBox("Za duzo pojazd?w", hitElement) end
if tonumber(pojazdwmarkerze(markerNiewidzialny)) < 1 then return outputChatBox("Za ma?o pojazd?w", hitElement) end



Niestety nie dzia?a i pokazywany jest inny b??d

Kod:

[2015-08-16 18] ERROR: tuningswiatel/swiatlatuning.lua:12: attempt to compare number with nil


Ostatnio zmieniony przez #404 2015-08-16, 18:37, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 20:28


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4979 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

Hmm, a mo?e by tak zamiast createMarker w niewidzialnym markerze, stw?rz :


createColSphere(x,y,z, radius) ? ^^

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 21:32


NoNi3zle

Uczeń LUA






Wiek: 25
Na forum: 4319 dni
Posty: 42
Nick w MP: NoNi3zle

Piwa: 78

Respekt: 60

Tak to ma wygl?da?? MarkerNiewidzialny = createColSphere( -2052.80444, 155.28987, 27.9, 8)
Zrobi?em tak i nie dzia?a :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 21:35


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4979 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

db 3

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-16, 21:35


NoNi3zle

Uczeń LUA






Wiek: 25
Na forum: 4319 dni
Posty: 42
Nick w MP: NoNi3zle

Piwa: 78

Respekt: 60

I pytanie: co mam zrobi? z klientem usun?? zedytowa? czy co?

[ Dodano: 2015-08-16, 22:25 ]
db3:

[2015-08-16 22] ERROR: tuningswiatel/swiatlatuning.lua:11: attempt to compare number with nil


Aktualnie kod wygl?da tak:

MarkerZielony = createMarker( -2048.30908, 157.13739, 28.0, 'cylinder', 0.75, 17, 255, 0, 255 ) 
MarkerCzerwony = createMarker( -2048.31665, 155.99012, 28.0, 'cylinder', 0.75, 255, 0, 0, 255 ) 
MarkerZolty = createMarker( -2048.29638, 154.72756, 28.0, 'cylinder', 0.75, 255, 247, 0, 255 ) 
MarkerBlekitny = createMarker( -2048.35034, 153.44259, 28.0, 'cylinder', 0.75, 0, 247, 255, 255 ) 
MarkerRozowy = createMarker( -2048.30883, 152.26870, 28.0, 'cylinder', 0.75, 255, 0, 196, 255 ) 
MarkerNiebieski = createMarker( -2048.31933, 158.26602, 28.0, 'cylinder', 0.75, 9, 0, 255, 255 ) 

MarkerNiewidzialny = createMarker ( -2052.80444, 155.28987, 27.9, 'cylinder', 8, 197, 196, 210, 100 ) 

function ZmienSwiatla (hitElement)
if tonumber(pojazdwmarkerze(markerNiewidzialny)) > 1 then return outputChatBox("Za duzo pojazd?w", hitElement) end
if tonumber(pojazdwmarkerze(markerNiewidzialny)) < 1 then return outputChatBox("Za ma?o pojazd?w", hitElement) end
            if source == MarkerZielony then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny)[1], 17, 255, 0)
            elseif source == MarkerCzerwony then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny)[1], 255, 0, 0)
            elseif source == MarkerZolty then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny)[1], 255, 247, 0)
            elseif source == MarkerBlekitny then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny)[1], 0, 247, 0)
            elseif source == MarkerRozowy then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny)[1], 255, 0, 196)
            elseif source == MarkerNiebieski then
                setVehicleHeadLightColor ( pojazdwmarkerze(markerNiewidzialny)[1], 9, 0, 255)
            end
end 
addEventHandler ("onMarkerHit", getRootElement (), ZmienSwiatla)



function pojazdwmarkerze(marker)
    if (not isElement(marker) or getElementType(marker) ~= "marker") then
        return false
    end
    local markerColShape = getElementColShape(marker)
    local elements = getElementsWithinColShape(markerColShape)
    return elements
end


Postaw piwo autorowi tego posta
 

 
Tagi: zmienianie :: koloru :: świateł
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Zmienianie koloru świateł 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