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

Wysłany: 2020-11-03, 14:27


kazet12383







Wiek: 30
Na forum: 2199 dni
Posty: 14
Nick w MP: toja



Respekt: 50

Znalazlem fajny angielski skrypt na prace dorywcz? - kierowc? ci??ar?wki. I teraz mam pytanie. Pozmienialem polecenia na chacie na polskie i spolszczylem gui. Jak ustawi? w tym kodzie zarobki (zmieni? je, bo s? za niskie, serwer ma jaki? smieszny przelicznik i trzeba by dopisac z 2-3 zera) oraz jak naprawic gui, bo jak wejdziesz w nie, to nie wyjdziesz bez wybrania jednej z dwoch opcji.


client
cargoMarkers = {--Player hits cargoMarker and list is shown"Locations" table contains the locations on that list.
{2213.8576660156, -2226.154785156312"Ocean Docks"},
{2747.6467285156, -2410.574707031313.45193195343"Easter Basin"},
{1613.85986328132330.972900390610.8203125"Redsands West"},
{-1623.608886718877.3361968994143.5546875"Easter Basin"}
}

local shipmentMarkerVault = {}
local shipmentBlipVault = {}

Locations = {--Here is the table for the locations on cargo list, xyzlocation (cash is calculated in below function)
{-1351.5205078125, -503.6679687514.171875"SF Airport"},
{2838.658203125999.670898437510.75"Linden Side"},
{2262.894531252792.92773437510.8203125"Spinybed"},
{-576.53063964844, -550.3467407226625.529611587524"Fallen Tree"},
{1414.89416503911088.405395507810.8203125"LVA Freight Depot"},
{1696.52258300782329.031005859410.8203125"Redsands West"}
}--Above table is places the player will choose when they hit a "cargoMarker" from the first tableremember to read how the tables are structured.


local Name
local marker
local blip
local cash

function spawnTheTruck(md)
local screenWscreenH guiGetScreenSize()
    window guiCreateWindow((screenW 312) / 2, (screenH 104) / 2312104"Zespawnowac ci pojazd, czy masz juz wczesniejszy?"false)
    guiWindowSetSizable(windowfalse)
    showCursor(true)
    
    label1 guiCreateLabel(562720117"Tak - zespawnuj."falsewindow)
    label2 guiCreateLabel(564020117"Nie - Mam poprzedni."falsewindow)
    guiLabelSetHorizontalAlign label1"center")
    guiLabelSetHorizontalAlign label2"center")
    
    Yes_btn guiCreateButton(56648930"Yes"falsewindow)
    No_btn guiCreateButton(168658929"No"falsewindow) 

    marker_data md
        
    addEventHandler("onClientGUIClick"Yes_btnspawnYes)
    addEventHandler("onClientGUIClick"No_btnspawnNo)
end

addEvent("spawnTruck"true)
addEventHandler("spawnTruck"getRootElement(), spawnTheTruck)

function spawnYes(buttonstate)
    if source == Yes_btn and button == "left" and state == "up" then 
            triggerServerEvent("spawnTruckYes"rootlocalPlayermarker_data)
            destroyElement(window)
            showCursor(false)
    end
end

function spawnNo(buttonstate)
    if source == No_btn and button == "left" and state == "up" then 
        triggerServerEvent("spawnTruckNo"rootlocalPlayer)
        destroyElement(window)
        showCursor(false)
    end
end

function showGUI()
local screenWscreenH guiGetScreenSize()
    window guiCreateWindow((screenW 498) / 2, (screenH 266) / 2498266"Shipments"false)
    guiWindowSetSizable(windowfalse)
    gridlist guiCreateGridList(927479194falsewindow)
    colLocation guiGridListAddColumn(gridlist"Location"0.33)
    colDistance guiGridListAddColumn(gridlist"Distance"0.33)
    colCash guiGridListAddColumn(gridlist"Cash"0.33)
    for i=1,#Locations do --I know this is saying for each line in the table
        local x,y,z,text Locations[i][1],Locations[i][2],Locations[i][3],Locations[i][4]--key 1key 2key 3
        local px,py,pz getElementPosition(localPlayer)
        local distance getDistanceBetweenPoints3D(px,py,pz,x,y,z)
        cash math.floor(distance*3)
        local row guiGridListAddRow gridlist,textmath.floor(distance), cash )
    end
    btn_acc guiCreateButton(7223114025"Accept"falsewindow)
    guiSetFont(btn_acc"sa-header")
    btn_exit guiCreateButton(28423114025"Exit"falsewindow)
    guiSetFont(btn_exit"sa-header")    
    showCursor(true)
    
    --Disable Collisions
    local v getPedOccupiedVehicle(localPlayer) -- Get her's Vehicle ID
    for index,vehicle in ipairs(getElementsByType("vehicle")) do --LOOP through all Vehicles
        setElementCollidableWith(vehicle, v, false) -- Set the Collison off with the Other vehicles.
    end
    
    local playerVehicle = getPedOccupiedVehicle ( localPlayer )
    if (playerVehicle) then
        setElementFrozen ( playerVehicle, true )
    end
    
    addEventHandler("onClientGUIClick", btn_acc, Accept)
    addEventHandler("onClientGUIClick", btn_exit, Exit)
    addEventHandler("onClientDoubleClick", root, DoubleClick)
end

addEvent("TruckerStart", true)
addEventHandler("TruckerStart", getRootElement(), showGUI)


function DoubleClick (button)
    if button == "left" then 
        Name = guiGridListGetItemText(gridlist,guiGridListGetSelectedItem(gridlist),1) --Get the name (Location[4])
        local x, y, z
        for i=1,#Locations do
            if Name == Locations[i][4] then
                x, y, z = Locations[i][1], Locations[i][2], Locations[i][3]
            end
        end
        if isElement (marker) then
            removeEventHandler("onClientMarkerHit", marker, reward)
            destroyElement(marker)
            destroyElement(blip)
        end
        marker = createMarker( x,y,z-1,"cylinder", 3, 0, 100, 0, 100 )
        blip = createBlipAttachedTo(marker, 51 ) --Type, Size, R, G, B
        cash = guiGridListGetItemText(gridlist,guiGridListGetSelectedItem(gridlist),3)
        --outputChatBox(""..cash,255,0,0)
        addEventHandler("onClientMarkerHit", marker, reward)
        
        removeEventHandler("onClientDoubleClick", root, DoubleClick)
        removeEventHandler("onClientGUIClick", btn_acc, DoubleClick)
        destroyElement(window)
        showCursor(false)
        triggerServerEvent("createTrailer", localPlayer)
        
        if #shipmentMarkerVault ~= 0 then
            for index = 1, #shipmentMarkerVault do
                destroyElement(shipmentMarkerVault[index])
                shipmentMarkerVault[index] = nil
            end
        end
        
        if #shipmentBlipVault ~= 0 then
            for index = 1, #shipmentBlipVault do
                destroyElement(shipmentBlipVault[index])
                shipmentBlipVault[index] = nil
            end
        end
        
        local playerVehicle = getPedOccupiedVehicle ( localPlayer )
        if (playerVehicle) then
            setElementFrozen ( playerVehicle, false )
        end
    end
end


function Accept(button, state)
    if source == btn_acc and button == "left" and state == "up" then 
        Name = guiGridListGetItemText(gridlist,guiGridListGetSelectedItem(gridlist),1) --Get the name (Location[4])
        local x, y, z
        for i=1,#Locations do
            if Name == Locations[i][4] then
                x, y, z = Locations[i][1], Locations[i][2], Locations[i][3]
            end
        end
        if isElement (marker) then
            removeEventHandler("onClientMarkerHit", marker, reward)
            destroyElement(marker)
            destroyElement(blip)
        end
        marker = createMarker( x,y,z-1,"cylinder", 3, 0, 100, 0, 100 )
        blip = createBlipAttachedTo(marker, 51 ) --Type, Size, R, G, B
        cash = guiGridListGetItemText(gridlist,guiGridListGetSelectedItem(gridlist),3)
        addEventHandler("onClientMarkerHit", marker, reward)
        
        removeEventHandler("onClientDoubleClick", root, DoubleClick)
        removeEventHandler("onClientGUIClick", btn_acc, DoubleClick)
        destroyElement(window)
        showCursor(false)
        triggerServerEvent("createTrailer", localPlayer)
        
        --destroy markers and clear the table
        if #shipmentMarkerVault ~= 0 then
            for index = 1, #shipmentMarkerVault do
                destroyElement(shipmentMarkerVault[index])
                shipmentMarkerVault[index] = nil
            end
        end
        
        if #shipmentBlipVault ~= 0 then
            for index = 1, #shipmentBlipVault do
                destroyElement(shipmentBlipVault[index])
                shipmentBlipVault[index] = nil
            end
        end
        
        local playerVehicle = getPedOccupiedVehicle ( localPlayer )
        if (playerVehicle) then
            -- set the new freeze status
            setElementFrozen ( playerVehicle, false )
        end
    end
end

function Exit(button, state)
    if source == btn_exit and button == "left" and state == "up" then 
        removeEventHandler("onClientDoubleClick", root, DoubleClick)
        removeEventHandler("onClientGUIClick", btn_acc, DoubleClick)
        removeEventHandler("onClientGUIClick", btn_exit, Exit)
        destroyElement(window)
        showCursor(false)
        
        triggerEvent("shipmentMarker", localPlayer)
        
        local playerVehicle = getPedOccupiedVehicle ( localPlayer )
        if (playerVehicle) then
            setElementFrozen ( playerVehicle, false )
        end
    end
end

function reward()
    for i=1,#Locations do
        if Name == Locations[i][4] then
            destroyElement(marker)
            destroyElement(blip)
            triggerServerEvent("truckerReward", localPlayer, cash)
            triggerEvent ("TruckerStart", localPlayer)
        end
    end
end

function trailerSpawn(hitElement, matchingDimension)
    if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then 
    local checkTeam = getTeamFromName("Trucker") 
        if ( checkTeam ) then 
        local playerTeam = getPlayerTeam(hitElement) 
            if ( playerTeam == checkTeam ) then 
                if not isPedInVehicle ( hitElement ) then 
                    outputChatBox("You must be in a truck, get a new one from the job spawn! (yellow blip on map)", 255,0,0 )
                    return
                else
                    Vehicle = getPedOccupiedVehicle(hitElement)
                    if  getElementModel ( Vehicle ) == 403 or getElementModel ( Vehicle ) == 514 or getElementModel ( Vehicle ) == 515 then 
                    triggerEvent ("TruckerStart", hitElement)
                    end
                end
            end    
        end
    end
end

function destroyMarker()
    if isElement (marker) then
        removeEventHandler("onClientMarkerHit", marker, reward)
        destroyElement(marker)
        destroyElement(blip)
    end
end

addEvent("destroyMarker",true)
addEventHandler("destroyMarker",getRootElement(),destroyMarker)

function makeGoodsMarker()
    if #shipmentMarkerVault ~= 0 then
        for index = 1, #shipmentMarkerVault do
            destroyElement(shipmentMarkerVault[index])
            shipmentMarkerVault[index] = nil
        end
    end
    if #shipmentBlipVault ~= 0 then
        for index = 1, #shipmentBlipVault do
            destroyElement(shipmentBlipVault[index])
            shipmentBlipVault[index] = nil
        end
    end
    for i=1,#cargoMarkers do 
        local x,y,z = cargoMarkers[i][1],cargoMarkers[i][2],cargoMarkers[i][3]--x = key 1, y = key 2, z = key 3        
        GoodsMarker = createMarker( x,y,z-1,"cylinder", 5, 0, 200, 55, 255 )
        TruckerJobBlip = createBlipAttachedTo ( GoodsMarker, 36 )
        shipmentMarkerVault[i] = GoodsMarker
        shipmentBlipVault[i] = TruckerJobBlip
        addEventHandler("onClientMarkerHit", GoodsMarker, trailerSpawn)
    end
end
addEvent("shipmentMarker", true)
addEventHandler("shipmentMarker", getRootElement(), makeGoodsMarker)

function destroyAllMarkersAndBlips()
    if #shipmentMarkerVault ~= 0 then
        for index = 1, #shipmentMarkerVault do
            destroyElement(shipmentMarkerVault[index])
            shipmentMarkerVault[index] = nil
        end
    end
    
    if #shipmentBlipVault ~= 0 then
        for index = 1, #shipmentBlipVault do
            destroyElement(shipmentBlipVault[index])
            shipmentBlipVault[index] = nil
        end
    end
    
    if isElement (marker) then
        removeEventHandler("onClientMarkerHit", marker, reward)
        destroyElement(marker)
        destroyElement(blip)
    end
end
addEvent("destroyTruckerStuff", true)
addEventHandler("destroyTruckerStuff", getRootElement(), destroyAllMarkersAndBlips)



server
local TruckerTeam createTeam("Trucker"20100150)
    
    removeWorldModel (985 7.38025812497.24192774.274710.7167)
    removeWorldModel (9867.42807292497.21192768.424311.38819)
    RGate createObject (9862497.39992769.099111.530090)
    LGate createObject (9852497.39992777.070111.530090)
    ColGate createColCuboid (2487.152765.28102015.755)

function KACC_Open thePlayermatchingDimension )
    if getElementType thePlayer ) == "player" then --if the element that entered was player
        moveObject(RGate10002497.39992769.0991-511.53000)
        moveObject(LGate10002497.39992777.0701+511.53000)
    end
end

addEventHandler "onColShapeHit"ColGateKACC_Open )    

function KACC_Close thePlayermatchingDimension )
    if getElementType thePlayer ) == "player" then --if the element that entered was player
        if not isElementWithinColShape thePlayerColGate then
            moveObject (RGate10002497.39992769.099111.53000)
            moveObject (LGate10002497.39992777.070111.53000)    
        end
    end
end

addEventHandler "onColShapeLeave"ColGateKACC_Close )

--[[Remove gates in LV
    removeWorldModel (985 7.38025812497.24192774.274710.7167)
    removeWorldModel (9867.42807292497.21192768.424311.38819)
    --createObject (9862493.39992766.711.5300160)
    --createObject (9852493.39992779.611.530020)
    RGate createObject (9862497.39992769.099111.530090)
    LGate createObject (9852497.39992777.070111.530090)
    ColGate createColCuboid (2487.152765.28102015.755)

isGateOpen false
local OpenTimer
local CloseTimer

function KACC_Open thePlayermatchingDimension )
    if getElementType thePlayer ) == "player" then --if the element that entered was player
        if isTimer(OpenTimerthen
            outputChatBox("Znaleziono licznik czasu",thePlayer)
        end
        if isGateOpen == false then
            x,y,getElementRotation(LGate)
            if not z == 20 then
                return
            end
            moveObject(RGate15002493.39992766.711.530070)
            moveObject(LGate15002493.39992779.611.5300, -70)
            OpenTimer setTimer(function() isGateOpen true end,2000,1)
        end    
    end
end

addEventHandler "onColShapeHit"ColGateKACC_Open )    

function KACC_Close thePlayermatchingDimension )
    if getElementType thePlayer ) == "player" then --if the element that entered was player
        if isGateOpen == true then
            x,y,getElementRotation(LGate)
            if not z == 90 then
                return
            end
            moveObject (RGate15002497.39992769.099111.5300, -70)
            moveObject (LGate15002497.39992777.070111.530070)
            CloseTimer setTimer(function() isGateOpen false end,2000,1)
        end    
    end
end

addEventHandler "onColShapeLeave"ColGateKACC_Close )]]


TruckerMarker = {--marker [x,y,z]   truck spawn point: [x,y,z,rotationx,rotationy,rotationz], [location]
{2179.841796875, -2263.694091796913.82167.4401855469, -2273.936279296914 ,-00220"Ocean Docks"},
{-1737.962280273420.2857570648192.7, -171010400315"Easter Basin"},
{16432354101634236511, -0090"Redsands West"}
}--Above table is for the job markersplayer walks into onethey become trucker and a truck is spawnedread above comment for info on spawning trucks.

Handler false --DO NOT CHANGEWILL NOT WORK IF IT'S NOT SET TO FALSE
timer = true --If your server has a script to automatically destroy vehicles when they explode you should set this to true
local isTrailerDetached = false --DO NOT CHANGE, WILL NOT WORK IF IT'S NOT SET TO FALSE
local markerStore = {} --Stores markers

function TruckerStart hitElementmatchingDimension )
    if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then
        if not (isGuestAccount (getPlayerAccount (hitElement))) then --First we want to check if player has made any shipments, if soset there shipment data!
        local account getPlayerAccount (hitElement)
            if (accountthen
            local PlayerShipments getAccountDataaccount"Trucker.pres" )
                if (PlayerShipmentsthen
                    setElementData (hitElement"Trucker.pres"PlayerShipments)
                else
                    setElementData (hitElement"Trucker.pres"0)
                end
                local marker_data markerStore[source] --We get the marker data from an empty tableyou will see why we do this in below function
                if marker_data then
                    --outputDebugString("Marker data found: "..tostring(marker_data))
                    triggerClientEvent hitElement"spawnTruck"hitElementmarker_data)
                end
            end
        end
    end
end

function spawnNo(hitElement) --If player choses no in client side GUIthen they won't get a truck
    if isElement(hitElement) and getElementType(hitElement) == "player" then
        if ( TruckerTeam ) then --Then we want to check if the trucker team exists
            if isPedOnGround ( hitElement ) then --If so, check if player is on foot
                local playerTeam = getPlayerTeam ( hitElement ) --Get there team         
                if not ( playerTeam == TruckerTeam) then --If they are not on the trucker team
                    setPlayerTeam(hitElement, TruckerTeam) --Set there team
                end
                    triggerClientEvent ( hitElement, "destroyIron", hitElement) --Oherwise, we make the markers for them to get there goods    
                    triggerClientEvent ( hitElement, "shipmentMarker", hitElement) --Oherwise, we make the markers for them to get there goods    
            else 
                outputChatBox("Musisz isc pieszo!", hitElement, 255, 0, 0)
            end
        end 
    end
end

addEvent("spawnTruckNo", true)
addEventHandler("spawnTruckNo", getRootElement(), spawnNo)

addEvent("spawnTruckYes", true)
addEventHandler("spawnTruckYes", root, 
function (hitElement, marker_data)--If player choses yes in client side GUI, then they will get a truck
    if isElement(hitElement) and getElementType(hitElement) == "player" then
        if ( TruckerTeam ) then --Then we want to check if the trucker team exists
            if isPedOnGround ( hitElement ) then --If so, check if player is on foot
                local playerTeam = getPlayerTeam ( hitElement ) --Get there team         
                if not ( playerTeam == TruckerTeam) then --If they are not on the trucker team
                    setPlayerTeam(hitElement, TruckerTeam) --Set there team
                end
                        triggerClientEvent ( hitElement, "destroyIron", hitElement)
                        triggerClientEvent ( hitElement, "shipmentMarker", hitElement)
                        local x, y, z, rx, ry, rz, name
                        if marker_data then
                            x,y,z,rx,ry,rz,name = marker_data[4],marker_data[5],marker_data[6],marker_data[7],marker_data[8],marker_data[9],marker_data[10]
                        local spawnedTruck = getElementData( hitElement, "Trucker.truck" ) --Now we want to check if they have spawned a truck
                        if ( spawnedTruck ~= false ) then --(~= is not equal)
                            if isElement(spawnedTruck) then
                                destroyElement(spawnedTruck) --If they have, destroy the truck
                            end
                            setElementData(hitElement, "Trucker.truck", false) --And set there data to false
                        end
                        local spawnedTrailer = getElementData( hitElement, "Trucker.trailer" )    
                        if ( spawnedTrailer ~= false ) then 
                            if isElement(spawnedTrailer) then
                                destroyElement(spawnedTrailer)
                            end
                            setElementData(source, "Trucker.trailer", false) 
                        end
                            local Truck = createVehicle (515, x, y, z+1, rx, ry, rz)  
                            setElementData(hitElement, "Trucker.truck", Truck)
                            warpPedIntoVehicle (hitElement, Truck)
                            --[[This can give faster trucks, but not recommended.
                            setVehicleHandling( Truck, "engineAcceleration", "20" )
                            setVehicleHandling( Truck, "maxVelocity", "150" )
                            setVehicleHandling( Truck, "steeringLock", "40" )
                            setVehicleHandling( Truck, "brakeDeceleration", "10000" )
                            setVehicleHandling( Truck, "engineType", "petrol" )
                            setVehicleHandling( Truck, "driveType", "awd" )    
                            Truck = false]]
                        end  
            else 
                outputChatBox("Musisz isc pieszo!", hitElement, 255, 0, 0)
            end
        end 
    end
end)


function createMarkers()
    for i=1,#TruckerMarker do 
        local x,y,z = TruckerMarker[i][1],TruckerMarker[i][2],TruckerMarker[i][3]--x = key 1, y = key 2, z = key 3        
        local marker = createMarker( x,y,z,"cylinder", 1, 0, 200, 55, 255 )
        markerStore[marker] = TruckerMarker[i]
        TruckerJobBlip = createBlipAttachedTo ( marker, 42, 2, 0, 0, 0, 0, 0, 500 )
        addEventHandler("onMarkerHit", marker, TruckerStart)
    end
end

createMarkers()


function spawnTrailer()
    if getElementType(source) == "player" then 
        local spawnedTruck = getPedOccupiedVehicle( source )
        local spawnedTrailer = getElementData( source, "Trucker.trailer" )
        
        trx,try,trz = getElementRotation(spawnedTruck)
        
        if ( spawnedTrailer ~= false ) then 
            if isElement(spawnedTrailer) then
                destroyElement(spawnedTrailer)
            end
            setElementData(source, "Trucker.trailer", false) 
        end
        
        Trailer = createVehicle (584, 2759.53, -2393.11, 150000, 0, 0, trz) --435, 450, 584, 591 <<These are all acceptable trailer ID'for trucks
        setElementData(source"Trucker.trailer"Trailer) 
        local spawnedTrailer getElementDatasource"Trucker.trailer" )
        setTimer(function()attachTrailerToVehicle spawnedTruckspawnedTrailer )end1001)
        
        if isTrailerDetached == true then
            removeEventHandler("onTrailerAttach"getRootElement(), TrailerAttach)
            isTrailerDetached false
        end
        
        if Handler == false then
            setTimer(function()addEventHandler("onTrailerDetach"getRootElement(), TrailerDetach)end30001)
            Handler true
        else
            removeEventHandler("onTrailerDetach"rootTrailerDetach)
            setTimer(function()addEventHandler("onTrailerDetach"getRootElement(), TrailerDetach)end30001)
        end
        
        setElementData(source"Trucker.can-be-rewarded"true) 
    end
end
addEvent("createTrailer"true)
addEventHandler("createTrailer"getRootElement(), spawnTrailer)


function giveReward(cash)
    if getElementType(source) == "player" then 
        if not isPedInVehicle source then 
            outputChatBox("Kolego, gdzie pojazd?"source255,0,)
            return
        else
            if getElementData(source"Trucker.can-be-rewarded") == true then
                Vehicle getPedOccupiedVehicle(source)
                if getElementModel Vehicle ) == 403 or getElementModel Vehicle ) == 514 or getElementModel Vehicle ) == 515 then 
                    local spawnedTrailer getElementDatasource"Trucker.trailer" )
                    givePlayerMoney(sourcecash)
                    removeEventHandler("onTrailerDetach"getRootElement(), TrailerDetach)
                    removeEventHandler("onTrailerAttach"getRootElement(), TrailerAttach)
                    setElementData(source"Trucker.can-be-rewarded"false)
                    destroyElement(spawnedTrailer) 
                    spawnedTrailer nil 
                    setElementData(source"Trucker.trailer"false)
                    setElementData (source"Trucker.pres",(getElementData (source"Trucker.pres")or ) + 1)
                end
            else
                outputChatBox("Wyglada na to, ze zapomniales zabrac swoja przyczepe ... Coz! Wracaj po nia."source255,0,)
            end
        end
    end    
end
addEvent("truckerReward"true)
addEventHandler("truckerReward"getRootElement(), giveReward)


function TrailerDetach(theTruck)
    thePlayer getVehicleOccupant theTruck)  
    local spawnedTrailer getElementDatathePlayer"Trucker.trailer" )
    if source == spawnedTrailer then 
        setElementData(thePlayer"Trucker.can-be-rewarded"false)
        removeEventHandler("onTrailerDetach"getRootElement(), TrailerDetach)
        addEventHandler("onTrailerAttach"getRootElement(), TrailerAttach)
        isTrailerDetached true
        outputChatBox("Musisz zdobyc swoja przyczepe!"thePlayer100,100,50 )
        setElementData(thePlayer"Trucker.detached"true) 
    end
end


function TrailerAttach(theTruck)
    thePlayer getVehicleOccupant theTruck)  
    local spawnedTrailer getElementDatathePlayer"Trucker.trailer" )
    if source == spawnedTrailer then 
        setElementData(thePlayer"Trucker.can-be-rewarded"true)
        addEventHandler("onTrailerDetach"getRootElement(), TrailerDetach)
        removeEventHandler("onTrailerAttach"getRootElement(), TrailerAttach)
        setElementData(thePlayer"Trucker.detached"false)
    end
end

local TruckTimer
local TrailerTimer

function ExitVehicle(thePlayer)
    if getPlayerTeam(thePlayer) == (TruckerTeamthen
        local spawnedTruck getElementDatathePlayer"Trucker.truck" )
        local theTrailer getElementDatathePlayer"Trucker.trailer" ) --Name changed from spawnedTrailer to prevent conflict
        if source == spawnedTruck then
            outputChatBox("Masz 20 sekund na powrot do ciezarowki!"thePlayer)
        end
            TruckTimer setTimer(function()
                    if ( spawnedTruck ~= false ) and ( isElement(spawnedTruck) ) then --(~= is not equal) 
                        destroyElement(spawnedTruck)
                        setElementData(thePlayer"Trucker.truck"false)
                    end
                    if (theTrailer) ~= false and isElement(theTrailerthen
                        destroyElement(theTrailer)
                        setElementData(thePlayer"Trucker.trailer"false)
                    end
                    triggerClientEvent(thePlayer"destroyMarker"thePlayer)
                    triggerClientEvent(thePlayer"shipmentMarker"thePlayer)
                end,20000,1)
        if not (spawnedTruck) and (theTrailerthen
            outputChatBox("Masz 20 sekund na powrot do ciezarowki!"thePlayer)
            TrailerTimer setTimer(function()
                if not isElement(spawnedTruck) and isElement(theTrailerthen
                    destroyElement(theTrailer)
                    triggerClientEvent(thePlayer"destroyMarker"thePlayer)
                    setElementData(thePlayer"Trucker.trailer"false)
                    triggerClientEvent(thePlayer"shipmentMarker"thePlayer)
                end
            end,20000,1)
        end
    end
end

addEventHandler("onVehicleExit",getRootElement(),ExitVehicle)

function EnterVehicle(thePlayer)
    if getPlayerTeam(thePlayer) == (TruckerTeamthen
        local spawnedTruck getElementDatathePlayer"Trucker.truck" )
        if source == spawnedTruck then
            if isTimer(TruckTimerthen 
                killTimer(TruckTimer)
            end
        end
        if source == spawnedTruck or getElementModel source ) == 403 or getElementModel source ) == 514 or getElementModel source ) == 515 then
            if isTimer(TrailerTimerthen 
                killTimer(TrailerTimer)
            end
        end
    end
end

addEventHandler("onVehicleEnter",getRootElement(),EnterVehicle)

function SaveShipments(quitTypereasonresponsibleElement)
    if not (isGuestAccount (getPlayerAccount (source))) then
        local account getPlayerAccount (source)
        if (accountthen
            local PlayerShipments getElementDatasource"Trucker.pres" )
            if (PlayerShipmentsthen
                setAccountData (account"Trucker.pres"PlayerShipments)
            end
        end
    end
end

addEventHandler("onPlayerQuit"getRootElement(), SaveShipments)


function GetShipments(quitTypereasonresponsibleElement)
    if not (isGuestAccount (getPlayerAccount (source))) then
        local account getPlayerAccount (source)
        if (accountthen
            local PlayerShipments getAccountDataaccount"Trucker.pres" )
            if (PlayerShipmentsthen
            setElementData (source"Trucker.pres"PlayerShipments)
            end
        end
    end
end

addEventHandler("onPlayerLogin"getRootElement(), GetShipments)


--When vehicles explode the players data will be removed
function explodingTruck()
    if timer == true then
        for _,player in ipairs(getElementsByType("player")) do --LOOP through all Vehicles
            local spawnedTruck getElementDataplayer"Trucker.truck" )
            local theTrailer getElementDataplayer"Trucker.trailer" )
            if source == spawnedTruck then 
                setElementData(player"Trucker.truck"false)
            end
            if source == theTrailer then
                setElementData(player"Trucker.trailer"false)
                triggerClientEvent(player"destroyMarker"player)
                triggerClientEvent(player"shipmentMarker"player)
            end
        end
    end
end
addEventHandler("onVehicleExplode",getRootElement(),explodingTruck)


function tellShipments(thePlayer)
    PlayerShipments getElementDatathePlayer"Trucker.pres" )
    if (PlayerShipmentsthen
        outputChatBox("Wykonales juz kilka dostaw, gratulacje!"thePlayer2014050)
    end
end

addCommandHandler("shipments"tellShipments)


function bbTrucker(thePlayer)
    triggerClientEvent(thePlayer"destroyTruckerStuff"thePlayer)
end

addCommandHandler("byetwucker"bbTrucker)


Ostatnio zmieniony przez Wilq 2020-11-03, 14:28, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-03, 14:47


VVirmex

Sgrypter luja






Wiek: 21
Na forum: 3365 dni
Posty: 281
Nick w MP: AxyZ

Piwa: 234

Respekt: 110
Respekt: 110


triggerServerEvent("truckerReward"localPlayercash)

^
Tu masz linijk? po stronie clienta.


        local distance getDistanceBetweenPoints3D(px,py,pz,x,y,z)
        cash math.floor(distance*3)

^
Tu masz ustalanie kasy

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-03, 16:43


kazet12383







Wiek: 30
Na forum: 2199 dni
Posty: 14
Nick w MP: toja



Respekt: 50

"VVirmex" napisał/a:


triggerServerEvent("truckerReward"localPlayercash)

^
Tu masz linijk? po stronie clienta.


        local distance getDistanceBetweenPoints3D(px,py,pz,x,y,z)
        cash math.floor(distance*3)

^
Tu masz ustalanie kasy


local distance = getDistanceBetweenPoints3D(px,py,pz,x,y,z)
cash = math.floor(distance*3)
zmieniam ta 3jke przy distance i caly czas dostaje to samo wynagrodzenie, co mam zmienic zeby powiekszyc zarobki?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-03, 17:14


VVirmex

Sgrypter luja






Wiek: 21
Na forum: 3365 dni
Posty: 281
Nick w MP: AxyZ

Piwa: 234

Respekt: 110
Respekt: 110

Przede wszystkim ustalaj d?ugie trasy - pieni?dze nalicza na podstawie d?ugo?ci trasy.

Postaw piwo autorowi tego posta
 

 
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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