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

Wysłany: 2018-11-12, 21:28


Trainer







Wiek: 27
Na forum: 2767 dni
Posty: 16
Nick w MP: Trainer

Piwa: 148

Respekt: 50

Witam. Ot?? mam problem ze skryptem.
Napisa?em skrypt na turbin? do pojazdu. Skrypt ma nadawa? turbin? wtedy, gdy pojazd nie ma elementdaty "rodzaj" jako "Diesel".
Wszystko dzia?a dobrze tylko wtedy, gdy pojazd nie posiada tej elementdaty. Lecz jak ju? j? posiada i skrypt ma sprawdzi? i wy?wietli? notyfikacj?, ?e jej nie ma, to wywala mi b??d z getElementOccupedVehicle.

addEvent("TD"true)
addEventHandler("TD"getRootElement(), function()
    local hajs getPlayerMoney(source)
    local veh getPedOccupiedVehicle(source)
    local cena 800000
    if getElementData(veh,"vehicle:rodzaj") == "Diesel" then return end
    if getElementData(veh,"vehicle:ownedPlayer") == getElementData(client"player:uid"then
    if hajs cena then triggerClientEvent(client"onClientAddNotification"client"Nie sta? Ci? aby zakupi? to ulepszenie!""error") return end
    local id getElementData(veh"vehicle:id")
    if not id then triggerClientEvent(client"onClientAddNotification"client"To nie jest pojazd prywatny!""error") return end
    local qr exports['tiyl-db']:dbGet("SELECT * FROM tiyl_pojazdy WHERE id=? AND turbina='Turbo'",getElementData(veh"vehicle:id"))
    if #qr == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posiadasz ju? to ulepszenie!", "error") return end
    exports["tiyl-pojazdy"]:onSaveVehicle(veh)
    destroyElement(veh)
    exports["tiyl-db"]:dbSet("UPDATE tiyl_pojazdy SET parking=1,tp_to_parking=? WHERE id=?","Zamontowal turbin?"id)
    exports["tiyl-db"]:dbSet("UPDATE tiyl_pojazdy SET turbina='Turbo' WHERE id=?"id)
    triggerClientEvent(client"onClientAddNotification"client"Pomy?lnie zamontowano Turbin?!""success")
    takePlayerMoney(sourcecena)
    else
        triggerClientEvent(client"onClientAddNotification"client"To nie jest Tw?j pojazd!""warning")
    end
end


Z b??d?w w debugscripcie wynika na to, ?e:
veh getPedOccupiedVehicle(source)

i
if getElementData(veh,"vehicle:rodzaj") == "Diesel" then return end
    if getElementData(veh,"vehicle:ownedPlayer") == getElementData(client"player:uid"then 

s? przyczyn?.
Pomo?e kto?? Dam piwko.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-12, 21:36


Avenged

Młodszy Szkrypter






Wiek: 23
Na forum: 3510 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1570

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

spr?buj zamieni? source na client

Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-13, 08:29


Trainer







Wiek: 27
Na forum: 2767 dni
Posty: 16
Nick w MP: Trainer

Piwa: 148

Respekt: 50

Pr?bowa?em, nieudolnie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-13, 15:15


Kalizman







Wiek: 23
Na forum: 3652 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

addEvent("TD"true)
addEventHandler("TD"getRootElement(), function()
    --[[if (getElementType(source)~="player"then --dodaj togdy nie b?dzie dzia?a? (doda?em linijk8-10)
        return
    end]]
    local hajs getPlayerMoney(source)
    local veh getPedOccupiedVehicle(source)
    if (not vehthen
        return
    end
    local cena 800000
    if getElementData(veh,"vehicle:rodzaj") == "Diesel" then return end
    if getElementData(veh,"vehicle:ownedPlayer") == getElementData(client"player:uid"then
    if hajs cena then triggerClientEvent(client"onClientAddNotification"client"Nie sta? Ci? aby zakupi? to ulepszenie!""error") return end
    local id getElementData(veh"vehicle:id")
    if not id then triggerClientEvent(client"onClientAddNotification"client"To nie jest pojazd prywatny!""error") return end
    local qr exports['tiyl-db']:dbGet("SELECT * FROM tiyl_pojazdy WHERE id=? AND turbina='Turbo'",getElementData(veh"vehicle:id"))
    if #qr == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posiadasz ju? to ulepszenie!", "error") return end
    exports["tiyl-pojazdy"]:onSaveVehicle(veh)
    destroyElement(veh)
    exports["tiyl-db"]:dbSet("UPDATE tiyl_pojazdy SET parking=1,tp_to_parking=? WHERE id=?","Zamontowal turbin?"id)
    exports["tiyl-db"]:dbSet("UPDATE tiyl_pojazdy SET turbina='Turbo' WHERE id=?"id)
    triggerClientEvent(client"onClientAddNotification"client"Pomy?lnie zamontowano Turbin?!""success")
    takePlayerMoney(sourcecena)
    else
        triggerClientEvent(client"onClientAddNotification"client"To nie jest Tw?j pojazd!""warning")
    end
end)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Trainer
Wysłany: 2018-11-15, 19:39


Trainer







Wiek: 27
Na forum: 2767 dni
Posty: 16
Nick w MP: Trainer

Piwa: 148

Respekt: 50

Leci piwko, dzi?ki za pomoc ;)

Postaw piwo autorowi tego posta
 

 
Tagi: getpedoccupedvehicle
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