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

Wysłany: 2019-02-13, 17:09


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot?z mam kod i chcia?bym, by gracz musia? mie? conajmniej 200rp, by wej?? do pojazdu z pracy. Pomo?e kt?? ?
kod
c.lua
smieciOb = {}
smieciMarker = {}
zaniesMarker = {}
smieci = {
    {162.33476, -58.11185, 1.57813},
    {161.90726, -49.79447, 1.57813},
    {162.96332, -20.19691, 1.57813},
}

modelSmiecia = 1265
iloscKasyZaSmieci = 35

oddawanieSmieciPos = {165.46448, -15.36996, 1.50203}
oddawanieMarker = createMarker( oddawanieSmieciPos[1], oddawanieSmieciPos[2], oddawanieSmieciPos[3] - 0.95, "cylinder", 5, 0, 255, 0, 25 )

niesieSmiec = false

function oddawanieSmieci( hitPlayer )
    if source ~= oddawanieMarker then return end
    if hitPlayer ~= localPlayer then return end
    veh = getPedOccupiedVehicle( hitPlayer )
    if not veh then return end
    iloscSmieci = 0
    for k,v in pairs( getAttachedElements( veh ) ) do
        if getElementModel( v ) == modelSmiecia then
            iloscSmieci = iloscSmieci + 1
            destroyElement( v )
            v = nil
        end
    end
    outputChatBox( "Za " .. iloscSmieci .. " smie?(/i) otrzymujesz " .. iloscSmieci * iloscKasyZaSmieci .. "$." )
    triggerServerEvent( "givePlayerMoneyS", resourceRoot, localPlayer, iloscSmieci * iloscKasyZaSmieci )
    odnowSmieci(  )
end

function podniesSmiec( hitPlayer )
    for k,v in pairs( smieciMarker ) do
        if v == source then
            if hitPlayer ~= localPlayer then return end
            obiektSmiecia = getElementData( source, "smiec" )
            if isElementAttached( obiektSmiecia ) then return end
            if not niesieSmiec then
                niesieSmiec = obiektSmiecia
                attachElements( obiektSmiecia, hitPlayer, 0, 0.5, 0.7 )
                setElementCollisionsEnabled( obiektSmiecia, false )
                setPedAnimation( hitPlayer, "carry", "crry_prtial", 1, false, true )
                destroyElement( source )
                toggleControl( "sprint", false )
                toggleControl( "jump", false )
                toggleControl( "crouch", false )

                for k,v in pairs( getElementsByType( "vehicle" ) ) do
                    if getElementModel( v ) == 478 then
                        zaniesMarker[v] = createMarker( 0, 0, 0, "cylinder", 1, 0, 255, 0, 50 )
                        setElementData( zaniesMarker[v], "pojazd", v )
                        attachElements( zaniesMarker[v], v, 0, -3, -0.95 )
                    end
                end
            end
        end
    end
end

function upuscSmiec( hitPlayer )
    for k,v in pairs( zaniesMarker ) do
        if v == source then
            if hitPlayer ~= localPlayer then return end
            if niesieSmiec then
                setPedAnimation( hitPlayer, "carry", "putdwn", 500, false, true )
                setTimer( function()
                    setPedAnimation( localPlayer, "ped", "atm", -1, false )
                    setTimer( function()
                        x, y, z = getElementPosition( localPlayer )
                        setElementPosition( localPlayer, x, y, z + 0.2 )
                    end, 1500, 1 )
                end, 500, 1 )
                veh = getElementData( source, "pojazd" )
                attachElements( niesieSmiec, veh, (math.random(-50, 50) / 100), -(math.random(100, 200) / 100), 0.3 )
                for k,v in pairs( zaniesMarker ) do
                    destroyElement( v )
                end
                toggleControl( "sprint", true )
                toggleControl( "jump", true )
                toggleControl( "crouch", true )
                niesieSmiec = false
            end
        end
    end
end

function odnowSmieci(  )
    for k,v in pairs( smieci ) do
        if not isElement(smieciOb[v]) then
            smieciOb[v] = createObject( modelSmiecia, v[1], v[2], v[3] - 0.5 )
            setElementFrozen( smieciOb[v], true )
            smieciMarker[v] = createMarker( v[1], v[2], v[3] - 0.95, "cylinder", 1, 0, 255, 0, 50 )
            setElementData( smieciMarker[v], "smiec", smieciOb[v] )
        end
    end
end
odnowSmieci(  )

addEventHandler( "onClientMarkerHit", root, podniesSmiec )
addEventHandler( "onClientMarkerHit", root, oddawanieSmieci )
addEventHandler( "onClientMarkerHit", root, upuscSmiec )


s.lua
miejscaPojazdow = {
    {166.43022, -37.73985, 1.57813, 0, 0, -90},
    {166.43022, -34.73985, 1.57813, 0, 0, -90},
    {166.43022, -31.73985, 1.57813, 0, 0, -90},
    {166.43022, -28.73985, 1.57813, 0, 0, -90},
    {166.43022, -25.73985, 1.57813, 0, 0, -90},
    {166.43022, -22.73985, 1.57813, 0, 0, -90},
}

for k,v in pairs( miejscaPojazdow ) do
    createVehicle( 478, v[1], v[2], v[3], v[4], v[5], v[6] )
end

addEvent( "givePlayerMoneyS", true )
addEventHandler( "givePlayerMoneyS", resourceRoot, function( player, ilosc )
    givePlayerMoney( player, ilosc )
end )


Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-13, 17:50


IgorPL222

LUA






Wiek: 26
Na forum: 3253 dni
Posty: 133
Nick w MP: mxgvr

Piwa: 746

Respekt: 55,3

To powinno dzia?a?:

S:


miejscaPojazdow = {
    {166.43022, -37.73985, 1.57813, 0, 0, -90},
    {166.43022, -34.73985, 1.57813, 0, 0, -90},
    {166.43022, -31.73985, 1.57813, 0, 0, -90},
    {166.43022, -28.73985, 1.57813, 0, 0, -90},
    {166.43022, -25.73985, 1.57813, 0, 0, -90},
    {166.43022, -22.73985, 1.57813, 0, 0, -90},
}

for k,v in pairs( miejscaPojazdow ) do
    local veh = createVehicle( 478, v[1], v[2], v[3], v[4], v[5], v[6] )
    setElementData(veh, 'min_rp', 200)
end

addEvent( "givePlayerMoneyS", true )
addEventHandler( "givePlayerMoneyS", resourceRoot, function( player, ilosc )
    givePlayerMoney( player, ilosc )
end )

addEventHandler('onVehicleStartEnter',root,function(player)
    if getElementData(source, 'min_rp') and getElementData(player, 'rp') < getElementData(source, 'min_rp') then 
   outputChatBox("Nie posiadasz 200RP",player)
   cancelEvent()
end)


Podpis
discord: mxgvr
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-13, 18:34


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

DB3 ERROR
Kod:

Loading script failed: ZbieranieSmieci/s.lua:24: unexpected symbol near ')'

Moja element data pod RP to player:movep
Tak to podstawi?em
miejscaPojazdow = {
    {166.43022, -37.73985, 1.57813, 0, 0, -90},
    {166.43022, -34.73985, 1.57813, 0, 0, -90},
    {166.43022, -31.73985, 1.57813, 0, 0, -90},
    {166.43022, -28.73985, 1.57813, 0, 0, -90},
    {166.43022, -25.73985, 1.57813, 0, 0, -90},
    {166.43022, -22.73985, 1.57813, 0, 0, -90},
}

for k,v in pairs( miejscaPojazdow ) do
    local veh = createVehicle( 478, v[1], v[2], v[3], v[4], v[5], v[6] )
    setElementData(veh, 'min_rp', 200)
end

addEvent( "givePlayerMoneyS", true )
addEventHandler( "givePlayerMoneyS", resourceRoot, function( player, ilosc )
    givePlayerMoney( player, ilosc )
end )

addEventHandler('onVehicleStartEnter',root,function(player)
    if getElementData(source, 'player:movep') and getElementData(player, 'player:movep') < getElementData(source, 'player:movep') then 
   outputChatBox("Nie posiadasz 200RP",player)
   cancelEvent()
end)


Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-13, 19:11


IgorPL222

LUA






Wiek: 26
Na forum: 3253 dni
Posty: 133
Nick w MP: mxgvr

Piwa: 746

Respekt: 55,3

Pyrek24, wybacz zapomnialem enda dodac XD

S:

miejscaPojazdow = {
    {166.43022, -37.73985, 1.57813, 0, 0, -90},
    {166.43022, -34.73985, 1.57813, 0, 0, -90},
    {166.43022, -31.73985, 1.57813, 0, 0, -90},
    {166.43022, -28.73985, 1.57813, 0, 0, -90},
    {166.43022, -25.73985, 1.57813, 0, 0, -90},
    {166.43022, -22.73985, 1.57813, 0, 0, -90},
}

for k,v in pairs( miejscaPojazdow ) do
    local veh = createVehicle( 478, v[1], v[2], v[3], v[4], v[5], v[6] )
    setElementData(veh, 'min_rp', 200)
end

addEvent( "givePlayerMoneyS", true )
addEventHandler( "givePlayerMoneyS", resourceRoot, function( player, ilosc )
    givePlayerMoney( player, ilosc )
end )

addEventHandler('onVehicleStartEnter',root,function(player)
    if getElementData(source, 'player:movep') and getElementData(player, 'player:movep') < getElementData(source, 'player:movep') then 
   outputChatBox("Nie posiadasz 200RP",player)
   cancelEvent()
    end
end)


Podpis
discord: mxgvr
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-13, 19:20


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Dalej mog? wsiada?, nie ma ?adnego b??du w DB3

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-13, 19:30


Emm

***** ***






Wiek: 32
Na forum: 4021 dni
Posty: 3191
Nick w MP: Emm

Piwa: 6171

Respekt: 1580
Respekt: 1580Respekt: 1580


   Administrator: Admin ma zawsze rację | REGULAMIN FORUM | REKLAMA/VIP | .
IgorPL222, ?e jak to mia?o dzia?a?? :D

Cytat:

    if getElementData(source, 'player:movep') and getElementData(player, 'player:movep') < getElementData(source, 'player:movep') then 



miejscaPojazdow = {
    {166.43022, -37.73985, 1.57813, 0, 0, -90},
    {166.43022, -34.73985, 1.57813, 0, 0, -90},
    {166.43022, -31.73985, 1.57813, 0, 0, -90},
    {166.43022, -28.73985, 1.57813, 0, 0, -90},
    {166.43022, -25.73985, 1.57813, 0, 0, -90},
    {166.43022, -22.73985, 1.57813, 0, 0, -90},
}

for k,v in pairs( miejscaPojazdow ) do
    local veh = createVehicle( 478, v[1], v[2], v[3], v[4], v[5], v[6] )
    setElementData(veh, 'min_rp', 200)
end

addEvent( "givePlayerMoneyS", true )
addEventHandler( "givePlayerMoneyS", resourceRoot, function( player, ilosc )
    givePlayerMoney( player, ilosc )
end )

addEventHandler('onVehicleStartEnter',root,function(player, seat)
if seat == 0 then -- je?li pr?buje wsi??? jako kierowca
    if getElementData(player, 'player:movep') < 200 then 
   outputChatBox("Nie posiadasz 200RP",player)
   cancelEvent()
    end
else return end
end)


Sprawdzaj, w razie problem?w pisz.

Podpis

Użytkownik: 20.10.2015r
GTAO Member: 06.03.2016r
Support-Team: 20.01.2016r
Moderator: 30.03.2016r
Mod-Team: 08.10.2016r
Vice Admin: 04.05.2018r
Administrator: 03.05.2022r


! Koniecznie zapoznaj się z regulaminem forum.
Pamiętaj, aby zawsze go przestrzegać, nie mniej ważne są również regulaminy działów, w których się wypowiadasz!
Zamiast zakładać temat po kilka razy, bo jest usuwany przez Administrację, przejrzyj regulamin i napisz poprawnie temat!
Sprawy z administracją możesz załatwiać anonimowo w tym dziale.
Najważniejsze informacje od Administracji możesz przeczytać tutaj oraz tutaj.
Ostatnio zmieniony przez Emm 2019-02-13, 20:07, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-13, 19:57


IgorPL222

LUA






Wiek: 26
Na forum: 3253 dni
Posty: 133
Nick w MP: mxgvr

Piwa: 746

Respekt: 55,3

Emm, to nie ja ?le podmieni?em elementDaty :D

M?j kod wygl?da? tak i jak najbardziej jest poprawny:


addEventHandler('onVehicleStartEnter',root,function(player)
    if getElementData(source, 'min_rp') and getElementData(player, 'rp') < getElementData(source, 'min_rp') then 
   outputChatBox("Nie posiadasz 200RP",player)
   cancelEvent()
   end
end)


Pozdrawiam ;)

Komentarz Emm dodany 2019-02-13, 19:59A faktycznie, nie zwróciłem uwagi na Twój post - pozdrawiam. :)
Podpis
discord: mxgvr
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Emm
Tagi: wejście :: pojazdu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Wejście do pojazdu 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