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

Wysłany: 2018-06-21, 18:52


Navro







Wiek: 26
Na forum: 2948 dni
Posty: 2
Nick w MP: Navro



Respekt: 50

Witam

Ostatnio wgra?em sobie na serwer par? skrypt?w 2 odpowiadaj? za prac? Taxi a 1 za zapis skina itp. Mam taki problem, ?e gdy ko?cz? prac? taxi i wychodz? z
serwera to zapisuje si? ten skin z taxi czy kto? mo?e mi wyt?umaczy? co mam zrobi? aby po wyj?ciu z Taxi wr?ci? skin kt?ry mia?em wcze?niej wybrany a praca zako?czy?a si? (SKRYPTY NIE S? MOJE)

Zapis:

handler dbConnect("sqlite""gracze.db") 

--Gracze
dbExec(handler"CREATE TABLE IF NOT EXISTS gracze (id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT, money INTEGER, skin INTEGER )")


addEventHandler("onPlayerLogin",root,
function (_,account)
    if not handler then
        outputServerLog("Nie ma po??czenia z baz? danych SQL")
    return end
        local name getAccountName(account)
        if not name then return end
        local q dbQuery handler"SELECT * FROM gracze WHERE account = ?"name )
            local result dbPoll q, -)
            if #result == 1 then
            for _,v in pairs (result) do
                setPlayerMoney(source,v.money)
                setElementModel(source,v.skin)
                        setPlayerName(source,v.account)
                end
            elseif #result == 0 then
                        setElementModel(source,"0")
                   dbExec(handler"INSERT INTO gracze (account, money,skin) VALUES (?,?,?)",name,0,)
                       setPlayerName(source,name)
        end
end
)

addEventHandler("onPlayerQuit",root,
function ()
        if not handler then return end
        local name getPlayerName(source)
        if not name then return end
        local money getPlayerMoney(source)
        local skin getElementModel(source)
        dbExec(handler,"UPDATE `gracze` SET money = ?, skin = ? WHERE account = ?",money,skin,name)
end
)

addEventHandler("onPlayerCommand",root,
function (command)
        if command == "logout" then
                cancelEvent()
        end
end
)




Praca1:

GUIEditor = {
    memo = {},
    button = {},
    window = {},
}

addEventHandler("onClientResourceStart"resourceRoot,
    function()
        GUIEditor.window[1] = guiCreateWindow(0.290.240.420.49""true)
        guiWindowSetSizable(GUIEditor.window[1], false)
        guiSetVisible(GUIEditor.window[1], false)

        bAccept guiCreateMemo(0.080.200.410.67""trueGUIEditor.window[1])
        
        bAccept guiCreateButton(0.600.200.340.17"We? prac?"trueGUIEditor.window[1])
        guiSetFont(GUIEditor.button[1], "sa-header")
        guiSetProperty(GUIEditor.button[1], "NormalTextColour""FFAAAAAA")
        addEventHandler("onClientGUIClick"bAcceptshowGUIbffalse)
        addEventHandler("onClientGUIClick"bAcceptjoinTeamfalse)
        
        bClose guiCreateButton(0.670.610.200.16"Zamknij"trueGUIEditor.window[1])
        guiSetProperty(bClose"NormalTextColour""FFAAAAAA") 
        addEventHandler("onClientGUIClick"bCloseshowGUIbffalse)
        
        GUIEditor.memo[1] = guiCreateMemo(0.080.200.410.67"Zosta? taks?wkarzem i uzyskaj doskona?e wynagrodzenie a? 500$ za kurs. Praca polega na rozwo?eniu klient?w po ca?ym San Andreas. "trueGUIEditor.window[1])
        
    end
)

local joinBD createMarker(1777.05078125, -1887.85351562512.387156486511"cylinder"0.925500)


addEventHandler"onClientResourceStart"getRootElement( ),
    function ( startedRes )
        createBlipAttachedTojoinBD60);
    end
);

function showGUIbt(hitElement)
 if getElementType(hitElement) == "player" and (hitElement == localPlayerthen
 guiSetVisible(GUIEditor.window[1], true)
 showCursortrue )
 end
 end
 addEventHandler("onClientMarkerHit"joinBDshowGUIbt) 

function showGUIbf()
    guiSetVisible (GUIEditor.window[1], false )
    showCursor false )
end


function joinTeam()
    triggerServerEvent("sTeame"localPlayer"teamSet")
end



Praca2:


local pickups = {
[1]={ 2060.7685546875, -1941.118164062513.14103603363 },
[2]={ 2114.5068359375, -1611.30273437513.167269706726 },
[3]={ 1932.9521484375, -1776.125976562513.16081237793 },
[4]={ 1057.41796875, -1568.485351562513.166387557983 },
[5]={ 1133.2607421875, -1286.620117187513.245727539063 },
[6]={ 1197.380859375, -1576.922851562513.2406873703 },
[7]={ 1275.6181640625, -1717.508789062513.241578102112 },
[8]={ 1041.908203125, -1869.172851562513.15417766571 },
[9]={ 680.9248046875, -1763.655273437513.168544769287 },
[10]={ 597.5556640625, -1598.9023437516.215705871582 },
[11]={ 357.197265625, -1443.7226562534.185447692871 }
}

local dropoffss = {
[1]={ 1965.54296875 , -1883.01367187513.160305023193 },
[2]={ 1467.3916015625, -1736.41992187513.242918014526 },
[3]={ 2376.1064453125, -1728.409179687513.162055015564 },
[4]={ 1066.5029296875, -1200.8632812518.405519485474 },
[5]={ 584.8916015625, -1328.702148437513.25985622406 },
[6]={ 989.75, -1372.08398437513.244333267212 },
[7]={ 1116.333984375, -1410.766601562513.267498970032 },
[8]={ 1437.5244140625, -1039.821289062523.564819335938 },
[9]={ 2124.4521484375, -1116.493164062525.031726837158 },
[10]={ 2700.8857421875, -1091.89648437569.064071655273 },
[11]={ 2769.2744140625, -1494.051757812527.58003616333 }
}

 

local pedCus = {
[1]={ },
[2]={ 10 },
[3]={ 14 },
[4]={ 15 },
[5]={ 37 }
}

 

 

Teame createTeam("Taxi Driver"02550)

 

taxiTeams = { [Teame] = true }
taxiVehs = { [420] = true }
 
function teamSet ( )
    local team getTeamFromName "Taxi Driver" )
    if team then
        setPlayerTeam sourceteam )
        setPlayerNametagColor source0255)
            setElementModel(source57)
            createVehicle(4201777.3017578125, -1891.77929687513.157614707947)
            outputChatBox("Zatrudni?e? si? jako taks?wkarz"thePlayer)
        else
            local teamw getTeamFromName "Taxi Driver" )
            if teamw then
            cancelEvent()
            outputChatBox("You are already a Taxi driver!"source)
        end
    end
end
addEvent "sTeame"true)
addEventHandler "sTeame"rootteamSet )

 
function enterVehicle thePlayerseatjacked ) -- when a player enters a vehicle
    if getElementType thePlayer ) == "player" then
        if ( taxiVehs[getElementModel source )] ) and ( not taxiTeams[getPlayerTeamthePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin
            removePedFromVehiclethePlayer )-- force the player out of the vehicle
            outputChatBox("Tylko kierowcy taks?wek mog? prowadzi? ten pojazd!"thePlayer)
        end
    end
end
addEventHandler "onVehicleEnter"getRootElement(), enterVehicle )

 

markers = { }
blips = { }
peds = { }
mposi = { }
mposii = {}


 

function startJob thePlayer )
    local xyunpack pickups math.random #pickups ) ] )
    markers thePlayer ] = createMarker xyz"cylinder"5.025500)
    mposi = { getElementPositionmarkers thePlayer ] ) }
    local skins unpack pedCus math.random #pedCus ) ] )
    peds thePlayer ] = createPedskinsxy)  
    blips thePlayer ] = createBlipAttachedTo markers thePlayer ], 58 )
    addEventHandler "onMarkerHit"markers thePlayer ], warpit )
    end
 
function inVEH thePlayer )
    if ( getElementType thePlayer ) == "player" and isPedInVehicle thePlayer ) ) then
        if ( getElementModel source ) == 420 then
            startJob thePlayer )
        end
    end
end
addEventHandler "onVehicleEnter"getRootElement(), inVEH )
 
function warpit thePlayer )
    if ( getElementType thePlayer ) == "player" and isPedInVehicle thePlayer ) ) then
       local vehiclee getPedOccupiedVehicle thePlayer )
        if ( getElementModel vehiclee ) == 420 then
            setTimer warpPedIntoVehicle20001peds thePlayer ], vehiclee)
            destroyJob thePlayer )
            local xyunpack dropoffss math.random #dropoffss ) ] )
            markers thePlayer ] = createMarker xy1"cylinder"5.02550050 )
            mposii = { getElementPositionmarkers thePlayer ] ) }
            blips thePlayer ] = createBlipAttachedTo markers thePlayer ], 41 )
            addEventHandler "onMarkerHit"markers thePlayer ], pickmeup )
            end
            end
        end

 
function pickmeup thePlayer )
    if ( getElementType thePlayer ) == "player" and isPedInVehicle thePlayer ) ) then
        destroyJob thePlayer )
        local mxmymz unpack mposi )
        local mmxmmymmz unpack mposii )
        local money getDistanceBetweenPoints2D mxmymmxmmy )
        finalmoney math.floor money )
        if finalmoney then
        setTimergivePlayerMoney30001thePlayerfinalmoney )
        setTimeroutputChatBox30001thePlayer"Zarobi?e? ".. money .."!"01440)
        setTimer (
            function ( )
                if ( isElement peds thePlayer ] ) ) then
                    destroyElement peds thePlayer ] )
                end
                startJob thePlayer )
            end
            ,30001
        )
            end
        end
    end

function deleteOnExit thePlayer )
    if ( isElement markers thePlayer ] ) ) then
        destroyElement markers thePlayer ] )
    end
    if ( isElement blips thePlayer ] ) ) then
        destroyElement blips thePlayer ] )
    end
    if ( isElement peds thePlayer ] ) ) then
        destroyElement peds thePlayer ] )
    end
end
addEventHandler "onVehicleExit"getRootElement(), deleteOnExit )

 
function destroyJob thePlayer )
    if ( isElement markers thePlayer ] ) ) then
        destroyElement markers thePlayer ] )
    end
    if ( isElement blips thePlayer ] ) ) then
        destroyElementblips thePlayer ] )
    end
end

function consoleSetPlayerPosition sourcecommandNameposXposYposZ )
    setElementPosition sourceposXposYposZ )
end
addCommandHandler "setpos"consoleSetPlayerPosition  )


Z g?ry dzi?kuj? za wyja?nienie i ewentualn? pomoc :)

Ostatnio zmieniony przez Navro 2018-06-23, 10:25, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-06-22, 19:08


Mezo.

Mod-Team






Wiek: 24
Na forum: 3211 dni
Posty: 548
Nick w MP: Mezo

Piwa: 6070

Respekt: 517
Respekt: 517

We? to w <lua> </lua> bo ciezkosie patrza.

Ale spr?boj dopisa? przed funkcj? zaka?czaj?c? prace:

local skin=getElementData(el,"player:skin")
setElementModel(el, skin)

Podpis
- Na forum pomagam na miarę swoich możliwości, oraz bezpłatnie.
- Jeżeli potrzebujesz pomocy, pisz do mnie w prywatnej wiadomości, pomoc uzyskasz szybciej.
Współpraca - [email protected]


Użytkownik - 19.08.2017
GTAO MEMBER - 29.03.2019
Support-Team - 03.02.2019 - 07.05.2019
Moderator - 07.05.2019 - 02.08.2020
Mod-Team - 02.08.2020 - 25.03.2022

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 2 piw(a):
VaXo, Hades.
Wysłany: 2018-06-23, 21:57


Navro







Wiek: 26
Na forum: 2948 dni
Posty: 2
Nick w MP: Navro



Respekt: 50

"Magneticy" napisał/a:

We? to w <lua> </lua> bo ciezkosie patrza.

Ale spr?boj dopisa? przed funkcj? zaka?czaj?c? prace:

local skin=getElementData(el,"player:skin")
setElementModel(el, skin)



Dalej nie dzia?a. Teraz nawet gdy wysiadam z Taxi nie ko?czy pracy

Postaw piwo autorowi tego posta
 

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