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

Wysłany: 2015-07-01, 18:31


Mateusz12301







Wiek: 29
Na forum: 4830 dni
Posty: 21
Nick w MP: Merson



Respekt: 50

Mam problem z prawo jazdy, chcia?bym doda? funkcje tak?, ?e jak stukn? wraca mnie z powrotem do miejsca gdzie si? robi prawko, a nie zostawia na ulicy.
Jakiej funkcji do tego u?y??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-01, 18:43


luki123luki123

Place Game






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

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Mateusz12301, nie funkcji a bardziej eventu.

Więcej informacji znajdziesz w Wikipedii MTA:

onVehicleDamage

i do tego u?yj funkcji:

Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleOccupant

pobieranie auta gracza

Więcej informacji znajdziesz w Wikipedii MTA:

setElementHealth

Dawanie elementu zdrowia

Więcej informacji znajdziesz w Wikipedii MTA:

setElementPosition

Ustawia pozycje elemntu na mapie

Więcej informacji znajdziesz w Wikipedii MTA:

setElementRotation

Ustawia rotacje elementu

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-01, 19:31


Mateusz12301







Wiek: 29
Na forum: 4830 dni
Posty: 21
Nick w MP: Merson



Respekt: 50

ale to tylko gracza cofa , tak? Czy i auto?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-01, 19:37


#404







Wiek: 26
Na forum: 4771 dni
Posty: 1438

Piwa: 2512

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

Ostrzeżeń: 60%
"Mateusz12301" napisał/a:

ale to tylko gracza cofa , tak? Czy i auto?

Najlepiej podaj funkcj? w kt?rej po otrzymaniu obra?e? ko?czy si? egzamin na prawo jazdy, wtedy najlepiej da si? wyt?umaczy? czego musisz u?y? aby? otrzyma? dany efekt.

@Down, my?la?em, ?e ma ju? chocia? jakie? szcz?tki zacz?tej funkcji, a nie zaczynamy od zera

Ostatnio zmieniony przez #404 2015-07-01, 22:30, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-01, 20:00


luki123luki123

Place Game






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

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

DestroY, co ty gadasz sam autor napisa? ?e chce mie? cofaj?cego auto jak kto? w niego stuknie wi?c anulowanie egzaminu nie ma.

Masz pe?ny kod tylko uzupe?nij:
local xyz, = pozycjaxpozycjaypozycjaz
local rxryrz rotacjaxrotacjayrotacjaz

function cancelegzamin()
    local thePlayer getVehicleOccupant(source)
    if(thePlayerthen
    fixVehicle source )
    setElementPosition sourcexyztrue )
    setElementRotation sourcerxryrz )  
    end
end
addEventHandler("onVehicleDamage"getRootElement(), cancelegzamin)

Uzupe?nij tylko warto?ci w zmiennej

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-01, 21:53


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

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

Proponuje uzyc spawn player na s-side, gdy? warpPedIntoVehicle buguje sie z setElementPosition, sam do?wiadczy?em tego.

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-07-04, 14:04


Mateusz12301







Wiek: 29
Na forum: 4830 dni
Posty: 21
Nick w MP: Merson



Respekt: 50

addEventHandler("onVehicleDamage",root,function(loss)
if getElementData(source,"vehicle:prawko") then
if loss>0.1 then
outputChatBox("Uszkodzi?e? pojazd tak bardzo, ?e egzaminator zabra? Ci pojazd.",getVehicleOccupant(source),255,255,255)
triggerClientEvent("Prawko:Koniec",getVehicleOccupant(source))
destroyElement(veh[getVehicleOccupant(source)])
end
end
end)


Jak w tym miejscu ustawi? , ?eby wraca?o samego gracza po stukni?ciu w miejsce robienia egzaminu:

O to Warto?ci:-2032.4000244141, -99.599998474121, 34.900001525879

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-04, 21:32


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

addEventHandler("onVehicleDamage",root,function(loss) 
if getElementData(source,"vehicle:prawko"then 
if loss>0.1 then 
outputChatBox("Uszkodzi?e? pojazd tak bardzo, ?e egzaminator zabra? Ci pojazd.",getVehicleOccupant(source),255,255,255triggerClientEvent("Prawko:Koniec",getVehicleOccupant(source)) 
setElementPosition getVehicleController(source), -2032.4000244141, -99.59999847412134.900001525879 )
destroyElement(veh[getVehicleOccupant(source)]) 
end 
end 
end)

Spr?buj, aczkolwiek nie jestem pewien...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-04, 21:43


luki123luki123

Place Game






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

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Maximerr, ?le b?dzie bo ko?czy on egzamin i marker ostatni zostanie ten sam by musia? od nowa egzamin w??czy?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-04, 22:36


Mateusz12301







Wiek: 29
Na forum: 4830 dni
Posty: 21
Nick w MP: Merson



Respekt: 50

Nadal nie dzia?a, pomo?e kto?? :C

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-05, 00:28


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3


addEventHandler("onVehicleDamage",root,function(loss)
if?getElementData(source,"vehicle:prawko")?then
if?loss>0.1?then
outputChatBox("Uszkodzi?e??pojazd?tak?bardzo,??e?egzaminator?zabra??Ci?pojazd.",getVehicleOccupant(source),255,255,255)
local gracz getPlayerFromName ""..getPlayerName(getVehicleController(source)).."")
triggerClientEvent("Prawko:Koniec",getVehicleOccupant(source))
setElementPosition?(?gracz,?-2032.4000244141,?-99.599998474121,?34.900001525879?)
destroyElement(veh[getVehicleOccupant(source)])
end
end?
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-05, 13:37


Mateusz12301







Wiek: 29
Na forum: 4830 dni
Posty: 21
Nick w MP: Merson



Respekt: 50

Nadal nie dzia?a

local pol dbConnect("mysql""dbname="..dbname..";host="..host..""""..username.."",""..pass.."","share=1")
marker=createMarker(-2032.97, -118.121034.17,"cylinder",1,255,255,255,100)
setElementInterior(marker,3)
setElementData(marker,"message","**Podejd?, aby rozpocz?? teorie prawa jazdy Kat.B**")
i3 createPed (163, -2035.04, -118.401035.17,-90)
setElementInterior(i3,3)
setElementData(i3,"message","Egzaminator")
i4 createPed (164, -2032.43, -114.021035.17,180)
setElementInterior(i4,3)
setElementData(i4,"message","Egzaminator")
ma=createMarker(-2026.92, -103.481034,"cylinder",7,255,255,255,0)
setElementInterior(ma,3)
setElementData(ma,"message","Prawo Jazdy\nKat.B\nWyj?cie")


addEventHandler("onMarkerHit",root,function(e)
    if source==marker then
        if getAccountData(getPlayerAccount(e),"PJ") or getAccountData(getPlayerAccount(e),"Praktyka"then return end
        setElementData(e,"trues",0)
        local pyt=getElementData(e,"IDPytania") or 0
        local pyt=pyt+1
        if pyt>2 then
            pyt=1
        end
        setElementData(e,"IDPytania",pyt)
        local q=dbQuery(pol,"SELECT * FROM `MTATS_Prawko` WHERE `id`=?",pyt)
        local w=dbPoll(q,-1)
        dbFree(q)
        triggerClientEvent("Next",e,w[1].pytanie,w[1].odp1,w[1].odp2,w[1].odp3,w[1].poprawne,pyt)
    end
end)



addEvent("Next2",true)
addEventHandler("Next2",root,function()
    local q=dbQuery(pol,"SELECT * FROM `MTATS_Prawko`")
    local w=dbPoll(q,-1)
    dbFree(q)
    local pyt=getElementData(source,"IDPytania") or 0
    local pyt=pyt+1
    if pyt>#w then
        local pr=getElementData(source,"trues") or 0
        if pr==3 then
            outputChatBox("Odpowiedzia?e? dobrze na "..pr.." pytania z "..#w..". Gratulujemy zdania cz??ci teoretycznej. Przeloguj si? i zacznij test praktyczny.",source,255,255,255)
            setAccountData(getPlayerAccount(source),"Praktyka",true)
            setElementData(source,"Praktyka",true)
        elseif pr<3 then
            outputChatBox("Odpowiedzia?e? dobrze na "..pr.." pytania z "..#w..". Niestety, ?yczymy szcz??cia innym razem!",source,255,255,255)
        end
        return triggerClientEvent("Close",source)
    end
    setElementData(source,"IDPytania",pyt)
    local q=dbQuery(pol,"SELECT * FROM `MTATS_Prawko` WHERE `id`=?",pyt)
    local w=dbPoll(q,-1)
    dbFree(q)
    triggerClientEvent("Next",source,w[1].pytanie,w[1].odp1,w[1].odp2,w[1].odp3,w[1].poprawne,pyt)
end)






veh={}


addEvent("Prawko:Pojazd",true)
addEventHandler("Prawko:Pojazd",root,function()
        veh[source]=createVehicle(589,-2032.4000244141, -99.59999847412134.900001525879)
        setElementRotation(veh[source],0,0,90)
        setElementInterior(source,0)
        warpPedIntoVehicle(source,veh[source])
        setVehicleHandling(veh[source],"maxVelocity",50)
        setElementData(veh[source],"message","Pojazd egzaminacyjny\n**Zakaz uszkadzania**")
        setElementData(veh[source],"vehicle:dontsave",true)
        setElementData(veh[source],"vehicle:prawko",true)
        setElementData(source,"player:zdajacy",true)
end)

addEvent("Prawko:Zakoncz",true)
addEventHandler("Prawko:Zakoncz",root,function()
        destroyElement(veh[source])
        givePlayerMoney(source,50)
        setElementData(source,"player:zdajacy",false)
        for _,v in ipairs(getElementsByType("player")) do
        end
end)

addEventHandler("onVehicleDamage",root,function(loss)
if getElementData(source,"vehicle:prawko"then
if loss>0.1 then
outputChatBox("Uszkodzi?e? pojazd tak bardzo, ?e egzaminator zabra? Ci pojazd.",getVehicleOccupant(source),255,255,255)
local gracz getPlayerFromName ""..getPlayerName(getVehicleController(source)).."")
triggerClientEvent("Prawko:Koniec",getVehicleOccupant(source))
setElementPosition gracz, -2032.4000244141, -99.59999847412134.900001525879 )
destroyElement(veh[getVehicleOccupant(source)])
end
end 
end)

addEventHandler("onPlayerVehicleExit",root,function(vehicle,seat)
        if seat==0 then
            if getElementData(vehicle,"vehicle:prawko"then
                outputChatBox("Wyszed?e? z pojazdu ko?cz?c sw?j kurs. Nie r?b tego na przysz?o??.",source,255,255,255)
                destroyElement(veh[source])
                triggerClientEvent("Prawko:Koniec",source)
            end
        end
end)


addEventHandler("onPlayerLogin",root,function(_,konto)
    if getAccountData(konto,"PJ"then
        setElementData(source,"PJ",true)
    end
    if getAccountData(konto,"Praktyka"then
        setElementData(source,"Praktyka",true)
    end
end)

addEventHandler("onVehicleStartEnter",root,function(e,seat)
    if seat==0 then
        if not getAccountData(getPlayerAccount(e),"PJ"then
            cancelEvent()
            outputChatBox("Nie posiadasz kluczy do tego pojazdu.",e,255,255,255)
        end
    end
end)



To jest pod server wszystko, pomo?e kto? z tym bo mam i to wielki problem, ?ecy gracza przywr?ci?o po stukni?ciu :C

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-05, 16:33


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

local pol dbConnect("mysql""dbname="..dbname..";host="..host..""""..username.."",""..pass.."","share=1")
marker=createMarker(-2032.97, -118.121034.17,"cylinder",1,255,255,255,100)
setElementInterior(marker,3)
setElementData(marker,"message","**Podejd?, aby rozpocz?? teorie prawa jazdy Kat.B**")
i3 createPed (163, -2035.04, -118.401035.17,-90)
setElementInterior(i3,3)
setElementData(i3,"message","Egzaminator")
i4 createPed (164, -2032.43, -114.021035.17,180)
setElementInterior(i4,3)
setElementData(i4,"message","Egzaminator")
ma=createMarker(-2026.92, -103.481034,"cylinder",7,255,255,255,0)
setElementInterior(ma,3)
setElementData(ma,"message","Prawo Jazdy\nKat.B\nWyj?cie")


addEventHandler("onMarkerHit",root,function(e)
    if source==marker then
        if getAccountData(getPlayerAccount(e),"PJ") or getAccountData(getPlayerAccount(e),"Praktyka"then return end
        setElementData(e,"trues",0)
        local pyt=getElementData(e,"IDPytania") or 0
        local pyt=pyt+1
        if pyt>2 then
            pyt=1
        end
        setElementData(e,"IDPytania",pyt)
        local q=dbQuery(pol,"SELECT * FROM `MTATS_Prawko` WHERE `id`=?",pyt)
        local w=dbPoll(q,-1)
        dbFree(q)
        triggerClientEvent("Next",e,w[1].pytanie,w[1].odp1,w[1].odp2,w[1].odp3,w[1].poprawne,pyt)
    end
end)



addEvent("Next2",true)
addEventHandler("Next2",root,function()
    local q=dbQuery(pol,"SELECT * FROM `MTATS_Prawko`")
    local w=dbPoll(q,-1)
    dbFree(q)
    local pyt=getElementData(source,"IDPytania") or 0
    local pyt=pyt+1
    if pyt>#w then
        local pr=getElementData(source,"trues") or 0
        if pr==3 then
            outputChatBox("Odpowiedzia?e? dobrze na "..pr.." pytania z "..#w..". Gratulujemy zdania cz??ci teoretycznej. Przeloguj si? i zacznij test praktyczny.",source,255,255,255)
            setAccountData(getPlayerAccount(source),"Praktyka",true)
            setElementData(source,"Praktyka",true)
        elseif pr<3 then
            outputChatBox("Odpowiedzia?e? dobrze na "..pr.." pytania z "..#w..". Niestety, ?yczymy szcz??cia innym razem!",source,255,255,255)
        end
        return triggerClientEvent("Close",source)
    end
    setElementData(source,"IDPytania",pyt)
    local q=dbQuery(pol,"SELECT * FROM `MTATS_Prawko` WHERE `id`=?",pyt)
    local w=dbPoll(q,-1)
    dbFree(q)
    triggerClientEvent("Next",source,w[1].pytanie,w[1].odp1,w[1].odp2,w[1].odp3,w[1].poprawne,pyt)
end)






veh={}


addEvent("Prawko:Pojazd",true)
addEventHandler("Prawko:Pojazd",root,function()
        veh[source]=createVehicle(589,-2032.4000244141, -99.59999847412134.900001525879)
        setElementRotation(veh[source],0,0,90)
        setElementInterior(source,0)
        warpPedIntoVehicle(source,veh[source])
        setVehicleHandling(veh[source],"maxVelocity",50)
        setElementData(veh[source],"message","Pojazd egzaminacyjny\n**Zakaz uszkadzania**")
        setElementData(veh[source],"vehicle:dontsave",true)
        setElementData(veh[source],"vehicle:prawko",true)
        setElementData(source,"player:zdajacy",true)
end)

addEvent("Prawko:Zakoncz",true)
addEventHandler("Prawko:Zakoncz",root,function()
        destroyElement(veh[source])
        givePlayerMoney(source,50)
        setElementData(source,"player:zdajacy",false)
end)

addEventHandler("onVehicleDamage",root,function(loss)
if getElementData(source,"vehicle:prawko"then
if loss>0.1 then
outputChatBox("Uszkodzi?e? pojazd tak bardzo, ?e egzaminator zabra? Ci pojazd.",getVehicleOccupant(source),255,255,255)
local gracz getPlayerFromName ""..getPlayerName(getVehicleController(source)).."")
triggerClientEvent("Prawko:Koniec",getVehicleOccupant(source))
destroyElement(veh[getVehicleOccupant(source)])

for _,v in ipairs(getElementsByType("player")) do
    if getElementData v"player:zdajacy" then
        setElementPosition v, -2032.4000244141, -99.59999847412134.900001525879 )
    end
end

end
end 
end)

addEventHandler("onPlayerVehicleExit",root,function(vehicle,seat)
        if seat==0 then
            if getElementData(vehicle,"vehicle:prawko"then
                outputChatBox("Wyszed?e? z pojazdu ko?cz?c sw?j kurs. Nie r?b tego na przysz?o??.",source,255,255,255)
                destroyElement(veh[source])
                triggerClientEvent("Prawko:Koniec",source)
            end
        end
end)


addEventHandler("onPlayerLogin",root,function(_,konto)
    if getAccountData(konto,"PJ"then
        setElementData(source,"PJ",true)
    end
    if getAccountData(konto,"Praktyka"then
        setElementData(source,"Praktyka",true)
    end
end)

addEventHandler("onVehicleStartEnter",root,function(e,seat)
    if seat==0 then
        if not getAccountData(getPlayerAccount(e),"PJ"then
            cancelEvent()
            outputChatBox("Nie posiadasz kluczy do tego pojazdu.",e,255,255,255)
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-07, 17:21


Mateusz12301







Wiek: 29
Na forum: 4830 dni
Posty: 21
Nick w MP: Merson



Respekt: 50

Nadal nie dzia?a.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-07, 17:46


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

Mateusz12301, jest jaki? DB3?

Postaw piwo autorowi tego posta
 

 
Tagi: prawo :: jazdy.
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