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

Wysłany: 2020-03-29, 03:11


pawelz

CJ






Wiek: 43
Na forum: 3365 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

Witam pisz? skrypt kt?ry po wjechaniu w blip teleportuje do interioru gdzie sprawdza jeszcze element date, powie kto? jak mam post?pi? albo przy?le gotowy kod?

Kod:

local wjazdDOMEK = createMarker(-1632.10,685.19,7.19-1,"cylinder", 5,0, 122, 255, 50)

wjazdDOMEK=function(el)
setElementPosition(el, -2023.66,2051.01,2165.81)
setElementInterior(el, 2)
end
wjazdDOMEK=function(el)
setElementInterior(el, 0)
end

addEventHandler("onMarkerHit", wjazdDOMEK, function(hitElement)
if getElementData(hitElement, 'player:house')=='domek' then
wjazdDOMEK(hitElement)
else
wjazdDOMEK(hitElement)
outputChatbox("Nie jeste? w?a?cicielem domku",hitElement)
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 07:25


MrVip615

witam






Wiek: 22
Na forum: 4307 dni
Posty: 167
Nick w MP: ramzes

Piwa: 207

Respekt: 85,3

Najpierw musisz uzyc
Więcej informacji znajdziesz w Wikipedii MTA:

addEventHandler

Potem sprawdzic czy element ktory uderzyl w marker to gracz za pomoca
Więcej informacji znajdziesz w Wikipedii MTA:

getElementType
chociaz tego nie trzeba jakos specjalnie, ale warto dodac w twoim przypadku. Nastepnie musisz ustawic ElementDate za pomoca
Więcej informacji znajdziesz w Wikipedii MTA:

setElementData
oraz sprawdzic czy gracz posiada ElementDate za pomoca
Więcej informacji znajdziesz w Wikipedii MTA:

getElementData

Nastepnie ustawiasz interior za pomoca
Więcej informacji znajdziesz w Wikipedii MTA:

setElementInterior


Przyklad uzycia tego wszystkiego:

jakisTamMarker createMarker(-1632.10,685.19,7.19-1,"cylinder"5,012225550) -- tutaj definiuje marker jako "jakisTamMarker"

function jakasTamFunkcja(el,dim)
    if getElementType(el)==player then -- Tutaj sprawdza czy element ktory uderzyl w marker
        if getElementData(el,"player:house")=="domek" then
            setElementInterior(el,0,x,y,z) -- Tu ustawiasz interior 0 elementowi ktory uderzyl w markernatomiast xy i z nie sa wymagane wiec nie musisz tego wpisywac
        end 
    end
end
addEventHandler("onMarkerHit",jakisTamMarker,jakasTamFunkcja) -- Jesli cos "uderzy" w marker zdefiniowany jako jakisTamMarker wykona sie funkcja o nazwie "jakasTamFunkcja"


Mozna jeszcze inaczej to zrobic robiac w EventHandlerze funkcje a nie wywolywac wczesniej zrobiona funkcje, przyklad:


jakisTamMarker createMarker(-1632.10,685.19,7.19-1,"cylinder"5,012225550)

addEventHandler("onMarkerHit",jakisTamMarker,function(el,dim)
    if getElementType(el)==player then
        if getElementData(el,"player:house")=="domek" then
            setElementInterior(el,0,x,y,z) -- Tu ustawiasz interior 0 elementowi ktory uderzyl w markera xy i z nie sa wymagane wiec nie musisz tego wpisywac
        end 
    end
end)


[ Dodano: 2020-03-29, 07:33 ]
Jeszcze tylko dopowiem, ze tak:

local wjazdDOMEK createMarker(-1632.10,685.19,7.19-1,"cylinder"5,012225550wjazdDOMEK=function(elsetElementPosition(el, -2023.66,2051.01,2165.81setElementInterior(el2end 
wjazdDOMEK=function(elsetElementInterior(el0end 

Nie mozesz robic, pierw definiujesz marker jako wjazdDOMEK a potem definiujesz funkcje jako wjazdDOMEK. Dodatkowo powiem, ze nie mozesz tak robic, ze definiujesz funkcje robiac zapis:
wjazdDOMEK=function()


Funkcji okreslasz nazwe w taki sposob:

function wjazdDOMEK()

I mozesz ja pozniej wywolywac w sposob taki:
function innaFunkcja()
    wjazdDOMEK()
end


Czyli na przyklad:


function wjazdDomek()
    outputChatBox("funkcja wjazdDomek",source)
end

function innaFunkcja()
    wjazdDomek()
end


robiac takie cos wywolujesz funkcje wjazdDomek w funkcji innaFunkcja, w tym przypadku wywola sie outputChatBox jedynie i zobaczysz wiadomosc "funkcja wjazdDomek" ktora pokaze sie tylko Tobie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 15:03


pawelz

CJ






Wiek: 43
Na forum: 3365 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

@MrVip615

zrobi?em takie co? i teleportuje gracza tylko do danego interioru ale ju? nie do pozycji, co zrobi??

Kod:

wjazd = createMarker(-1631.61,684.84,7.19-1,"cylinder", 5,0, 122, 255, 50)

function isPlayerInHouseOwner(plr)
local sid=getElementData(plr,'player:sid')
if not sid then return end

local result=exports['pystories-db']:dbGet('SELECT 1 FROM pystories_homes WHERE code=? AND sid=? LIMIT 1;', "domek", sid)
if result[1] then
return true
else
return false
end
end

addEventHandler('onMarkerHit', wjazd, function(el,md)
if isPlayerInHouseOwner(el) then
local veh=getPedOccupiedVehicle(el)
if not veh then return end
if getVehicleController(veh) ~= el then return end
setElementInterior(el, 2, -2024.25,2052.07,2166.29)
setElementInterior(veh, 2)
else
outputChatBox('* Nie jeste? w?a?cicielem domku.', el, 255, 0, 0)
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 15:29


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Gracz jest w poje?dzie, wi?c ustawiaj pozycj? pojazdu. Wystarczy tylko ta jedna linijka, drug? usu?:

setElementInterior(veh2, -2024.25,2052.07,2166.29


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 15:37


MrVip615

witam






Wiek: 22
Na forum: 4307 dni
Posty: 167
Nick w MP: ramzes

Piwa: 207

Respekt: 85,3

Kod wpisuj w znaczniki [lua][/lua] a nie [code]

Na poczatku masz funkcje
"pawelz" napisał/a:



function isPlayerInHouseOwner(plr) 
    local sid=getElementData(plr,'player:sid') 
    if not sid then return end

Brakuje Ci tu zakonczenia funkcji, zrob:

function isPlayerInHouseOwner(plr) 
    local sid=getElementData(plr,'player:sid') 
    if not sid then return end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 15:47


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

MrVip615, przecie? autor w?tku ma tak??funkcj? i jest ona poprawna.

Gotowy kod, kt?ry powinien dzia?a?:

wjazd createMarker(-1631.61,684.84,7.19-1,"cylinder"5,012225550) 

function isPlayerInHouseOwner(plrlocal sid=getElementData(plr,'player:sid') 
if not sid then return end 

local result=exports['pystories-db']:dbGet('SELECT 1 FROM pystories_homes WHERE code=? AND sid=? LIMIT 1;'"domek"sid) 
if result[1then 
return true 
else 
return false 
end 
end 

addEventHandler('onMarkerHit'wjazd, function(el,md) 
if isPlayerInHouseOwner(elthen 
local veh=getPedOccupiedVehicle(el) 
if not veh then return end 
if getVehicleController(veh) ~= el then return end 
setElementInterior(veh2, -2024.25,2052.07,2166.29) 
else 
outputChatBox('* Nie jeste? w?a?cicielem domku.'el25500end 
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 15:51


MrVip615

witam






Wiek: 22
Na forum: 4307 dni
Posty: 167
Nick w MP: ramzes

Piwa: 207

Respekt: 85,3

Wilq, no tak ale
function isPlayerInHouseOwner(plrlocal sid=getElementData(plr,'player:sid') 
if not sid then return end

gdzie tu jest zakonczenie funkcji, ja tu widze tylko zakonczenie ifa

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 16:00


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

?

To jest ca?a funkcja:

function isPlayerInHouseOwner(plrlocal sid=getElementData(plr,'player:sid') 
if not sid then return end 

local result=exports['pystories-db']:dbGet('SELECT 1 FROM pystories_homes WHERE code=? AND sid=? LIMIT 1;'"domek"sid) 
if result[1then 
return true 
else 
return false 
end 
end 


Nie wklejaj tylko 3 linijek.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 16:19


pawelz

CJ






Wiek: 43
Na forum: 3365 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

wjazd createMarker(-1631.61,684.84,7.19-1,"cylinder"5,012225550) 

function isPlayerInHouseOwner(plr) 
    local sid=getElementData(plr,'player:sid') 
    if not sid then return end 

    local result=exports['pystories-db']:dbGet('SELECT 1 FROM pystories_homes WHERE code=? AND sid=? LIMIT 1;'"domek"sid) 
    if result[1then 
        return true 
    else 
        return false 
    end 
end 

addEventHandler('onMarkerHit'wjazd, function(el,md) 
    if isPlayerInHouseOwner(elthen 
        local veh=getPedOccupiedVehicle(el) 
        if not veh then return end 
        if getVehicleController(veh) ~= el then return end 
            setElementInterior(veh2, -2024.25,2052.07,2166.29) 
    else 
        outputChatBox('* Nie jeste? wlasiciclem domku.'el25500)
    end 
end)


teraz teleportuje w wyznaczone miejsce ale nie ustawia interioru na 2 co zrobi??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 16:35


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Spr?buj doda? t? linijk?

setElementInterior(el2


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-29, 18:40


MrVip615

witam






Wiek: 22
Na forum: 4307 dni
Posty: 167
Nick w MP: ramzes

Piwa: 207

Respekt: 85,3

"Wilq" napisał/a:

?

To jest ca?a funkcja:

function isPlayerInHouseOwner(plrlocal sid=getElementData(plr,'player:sid') 
if not sid then return end 

local result=exports['pystories-db']:dbGet('SELECT 1 FROM pystories_homes WHERE code=? AND sid=? LIMIT 1;'"domek"sid) 
if result[1then 
return true 
else 
return false 
end 
end 


Nie wklejaj tylko 3 linijek.


Aaa, faktycznue, przepraszam moj blad. Nie popatrzylem na to.

Postaw piwo autorowi tego posta
 

 
Tagi: request :: zniwelowanie :: bugu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Request o zniwelowanie bugu 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