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

Wysłany: 2014-02-28, 20:39


XDavido







Wiek: 27
Na forum: 4865 dni
Posty: 6
Nick w MP: #Maggas



Respekt: 50

Witam, pisz?c skrypt odpowiadaj?cy za prawo jazdy napotka?em pewien problem.
Chodzi o to, ?e je?li oboj?tnie jaki element ( gracz, pojazd ) wejdzie markera to skrypt wykonuje dan? funkcje 2 razy. W tym skrypcie tworzy w?a?nie po 2/ wi?cej marker?w.

Kod do danej funkcji
server
Kod:

function pojazd ( source, cmd )
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
if not getAccountData ( playeraccount, "prawko4543" ) then
if isElementWithinMarker ( source, marker ) then
if cmd == "akceptuj" then
auto = createVehicle ( 410, -83, 1076, 19 )
instruktor = createPed ( 17, 0, 0, 1 )
warpPedIntoVehicle ( instruktor, auto )
warpPedIntoVehicle ( source, auto )
outputChatBox ( "#ffffffUdaj si? na miejsce startu ! ( #ff0000Czerwony punkt#ffffff )", source, 255, 255, 255, true )
outputChatBox ( "#ffffffPami?taj, ?e je?li uszkodzisz sw?j pojazd wi?cej niz 10% w d?? - #ff0000NIE ZDASZ!", source, 255, 255, 255, true )
pojazd ( player, hitElement, matchingDimension, vehicle )
end
end
else
outputChatBox ( "#ffffffZdawa?e? ju? prawo jazdy i zako?czy?e? je wynikiem #00ff00Pozytywnym#ffffff ! Id? szukaj pracy.", source, 255, 255, 255, true )
end
end
end
addCommandHandler ( "akceptuj", pojazd )

function pojazd ( player, hitElement, matchingDimension, vehicle )
setVehicleColor ( auto, 255, 255, 255 )
marker1 = createMarker ( -86, 1095, 19, "checkpoint", 2.5, 255, 0, 0 )
blip1 = createBlip ( -86, 1095, 19, 0 )
addEventHandler ( "onMarkerHit", marker1, function()
destroyElement ( marker1 )
destroyElement ( blip1 )
marker2 = createMarker ( -68.283203125, 1053.1494140625, 19.218013763428, "checkpoint", 2.5, 255, 0, 0 )
blip2 = createBlip ( -68.283203125, 1053.1494140625, 19.218013763428, 0 )
addEventHandler ( "onMarkerHit", marker2, function()
destroyElement ( marker2 )
destroyElement ( blip2 )
marker3 = createMarker ( -25.533203125, 1020.68359375, 19.218778610229, "checkpoint", 2.5, 255, 0, 0 )
blip3 = createBlip ( -25.533203125, 1020.68359375, 19.218778610229, 0 )
addEventHandler ( "onMarkerHit", marker3, function()
destroyElement ( marker3 )
destroyElement ( blip3 )
marker4 = createMarker ( -13.583984375, 1084.5068359375, 19.215364456177, "checkpoint", 2.5, 255, 0, 0 )
blip4 = createBlip ( -13.583984375, 1084.5068359375, 19.215364456177, 0 )
addEventHandler ( "onMarkerHit", marker4, function()
destroyElement ( marker4 )
destroyElement ( blip4 )
marker5 = createMarker ( 31.990234375, 1130.9306640625, 19.218774795532, "checkpoint", 2.5, 255, 0, 0 )
blip5 = createBlip ( 31.990234375, 1130.9306640625, 19.218774795532, 0 )
addEventHandler ( "onMarkerHit", marker5, function()
destroyElement ( marker5 )
destroyElement ( blip5 )
marker6 = createMarker ( -48.17578125, 1150.49609375, 19.213083267212, "checkpoint", 2.5, 255, 0, 0 )
blip6 = createBlip ( -48.17578125, 1150.49609375, 19.213083267212, 0 )
addEventHandler ( "onMarkerHit", marker6, function()
destroyElement ( marker6 )
destroyElement ( blip6 )
marker7 = createMarker ( -63.0732421875, 1188.244140625, 19.152198791504, "checkpoint", 2.5, 255, 0, 0 )
blip7 = createBlip ( -63.0732421875, 1188.244140625, 19.152198791504, 0 )
addEventHandler ( "onMarkerHit", marker7, function()
destroyElement ( marker7 )
destroyElement ( blip7 )
marker8 = createMarker ( 104.095703125, 1195.6494140625, 17.903852462769, "checkpoint", 2.5, 255, 0, 0 )
blip8 = createBlip ( 104.095703125, 1195.6494140625, 17.903852462769, 0 )
addEventHandler ( "onMarkerHit", marker8, function()
destroyElement ( marker8 )
destroyElement ( blip8 )
marker9 = createMarker ( 44.56640625, 1254.591796875, 14.145935058594, "checkpoint", 2.5, 255, 0, 0 )
blip9 = createBlip ( 44.56640625, 1254.591796875, 14.145935058594, 0 )
addEventHandler ( "onMarkerHit", marker9, function()
destroyElement ( marker9 )
destroyElement ( blip9 )
marker10 = createMarker ( -192.61328125, 1244.2451171875, 21.983798980713, "checkpoint", 2.5, 255, 0, 0 )
blip10 = createBlip ( -192.61328125, 1244.2451171875, 21.983798980713, 0 )
addEventHandler ( "onMarkerHit", marker10, function()
destroyElement ( marker10 )
destroyElement ( blip10 )
marker11 = createMarker ( -432.6298828125, 1424.0400390625, 32.503204345703, "checkpoint", 2.5, 255, 0, 0 )
blip11 = createBlip ( -432.6298828125, 1424.0400390625, 32.503204345703, 0 )
addEventHandler ( "onMarkerHit", marker11, function()
destroyElement ( marker11 )
destroyElement ( blip11 )
marker12 = createMarker ( -380.6396484375, 1379.56640625, 43.741275787354, "checkpoint", 2.5, 255, 0, 0 )
blip12 = createBlip ( -380.6396484375, 1379.56640625, 43.741275787354, 0 )
addEventHandler ( "onMarkerHit", marker12, function()
destroyElement ( marker12 )
destroyElement ( blip12 )
marker13 = createMarker ( -369.1357421875, 1460.01953125, 62.370532989502, "checkpoint", 2.5, 255, 0, 0 )
blip13 = createBlip ( -369.1357421875, 1460.01953125, 62.370532989502, 0 )
addEventHandler ( "onMarkerHit", marker13, function()
destroyElement ( marker13 )
destroyElement ( blip13 )
marker14 = createMarker ( -298.6953125, 1394.626953125, 71.996292114258, "checkpoint", 2.5, 255, 0, 0 )
blip14 = createBlip ( -298.6953125, 1394.626953125, 71.996292114258, 0 )
addEventHandler ( "onMarkerHit", marker14, function()
destroyElement ( marker14 )
destroyElement ( blip14 )
marker15 = createMarker ( -330.4521484375, 1515.564453125, 74.984230041504, "checkpoint", 2.5, 255, 0, 0 )
blip15 = createBlip ( -330.4521484375, 1515.564453125, 74.984230041504, 0 )
outputChatBox ( "#ffffffZaparkuj pojazd w #ff0000czerwonym #ffffffmiejscu.", player, 255, 255, 255, true )
addEventHandler ( "onMarkerHit", marker15, function()
destroyElement ( marker15 )
destroyElement ( blip15 )
marker16 = createMarker ( -84.0791015625, 1077.4931640625, 19.7421875, "checkpoint", 2.5, 255, 0, 0 )
blip16 = createBlip ( -84.0791015625, 1077.4931640625, 19.7421875, 0 )
outputChatBox ( "#ffffffWr?c pod szko?e jazdy i zaparkuj pojazd w #ff0000czerwonym #ffffffpunkcie", player, 0, 255, 0, true )
addEventHandler ( "onMarkerHit", marker16, function()
destroyElement ( marker16 )
destroyElement ( blip16 )
wynik ( player )
end)
end)
end)
end)
end)
end)
end)
end)
end)
end)
end)
end)
end)
end)
end)
end)
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-03-04, 17:28


monio







Wiek: 30
Na forum: 4887 dni
Posty: 319
Nick w MP: Monio99

Piwa: 3565

Respekt: 120,5
Respekt: 120,5

a do czego Ci tele end'?w ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-03-04, 20:49


XDavido







Wiek: 27
Na forum: 4865 dni
Posty: 6
Nick w MP: #Maggas



Respekt: 50

Nie ma to zwi?zku z k?opotem

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-03-04, 22:25


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

XDavido, ch?opie naucz si? programowania lua.
Tak powinno by?
addEventHandler "onMarkerHit"marker12, function()
....kod....
,)

U cb.
addEventHandler "onMarkerHit"marker12, function()
..kod..
end)


end dzia?a jak przecinek usuwa b??d w kodzie ale tak i tak jest niepoprawny zamiast tych ca?ych end daj ","

PS:
jak robisz w ten spos?b to konczysz funkcje w tym kodzie addEventHandler po zakoczeniu co ma tworzy? w nim.
np.

function pojazd playerhitElementmatchingDimensionvehicle )
setVehicleColor auto255255255 )
marker1 createMarker ( -86109519"checkpoint"2.52550)
blip1 createBlip ( -86109519)
addEventHandler "onMarkerHit"marker1, function()
destroyElement marker1 )
destroyElement blip1 ),)
marker2 createMarker ( -68.2832031251053.149414062519.218013763428"checkpoint"2.52550)
blip2 createBlip ( -68.2832031251053.149414062519.218013763428)
addEventHandler "onMarkerHit"marker2, function()
destroyElement marker2 )
destroyElement blip2 )
,)
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-03-05, 10:45


Piorun







Wiek: 32
Na forum: 6712 dni
Posty: 1837
Nick w MP: Piorun

Piwa: 516

Respekt: 480,7
Respekt: 480,7

luki123luki123, ch?opcze, co ty pleciesz :P ?

Ka?dy element uk?adanki w Lua powinien mie? zako?czenie "end", czy? nie?
Dlatego te? pisanie funkcji rozpoczynamy od "function", ko?czymy na "end". Przecinek jest zb?dny (a na pewno ?le wprowadzony). To czy ty rozpoczniesz funkcj? bezpo?rednio w deklarowaniu zaczepu zdarzenia czy poza nim nie ma znaczenia. I tu i tu end musi by?. Tak?e poprawnie to wygl?da? powinno tak:

addEventHandler(nazwa_zdarzenia,dla_kogo,function
...
...
end)


Nie ma za co :)

Podpis
Możesz mnie znaleźć na: Facebook
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-03-05, 21:13


Riot

3X






Wiek: 29
Na forum: 5729 dni
Posty: 1123
Nick w MP: Riot/3X

Piwa: 286

Respekt: 123
Respekt: 123

"luki123luki123" napisał/a:

XDavido, ch?opie naucz si? programowania lua.


To ?e masz fajny podpisik i nazwiesz si? programist? LUA nie czyni Ci? nim. Nikt nie ma prawa si? wywy?sza?, szczeg?lnie Ty - te? lubisz prosi? o pomoc a widzia?e? kiedy? by kto? pisa? tak w stosunku do Ciebie? Nie s?dz?.

--
Strasznie nieczytelny ten kod. Ja pokusi?bym si? o stworzenie tablicy w kt?rej mia?by? trzyma?by? dane.

Dzi?ki temu mia?by? z ca?? pewno?ci? wi?ksza czytelno?? bo ten kod to straszny chaos ;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-03-09, 15:49


XDavido







Wiek: 27
Na forum: 4865 dni
Posty: 6
Nick w MP: #Maggas



Respekt: 50

Mo?na jaki? przyk?ad ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-03-09, 17:37


Jacob

Głupiomądry






Wiek: 28
Na forum: 5502 dni
Posty: 967
Nick w MP: Jacob

Piwa: 786

Respekt: 212,3
Respekt: 212,3Respekt: 212,3

markery = {
{xyz}, --zamiast x,y,z podajesz coordy
{xyz}
}

for _,markers in ipairs markery ) do
    local marker createMarker v[1], v[2], v[3], "checkpoint"2.5255255)
    addEventHandler "onMarkerHit"marker,
        function ( )
            destroyElement marker )
        end
    )
end

Taki ma?y przyk?ad.

Postaw piwo autorowi tego posta
 

 
Tagi: [element :: onmarkerhit]
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » [Element,onMarkerHit] 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