Jump to content

Drugs transport


Recommended Posts

hallo allemaal,

Ik heb laatst een drugs transport job gedownload van de MTA Community.

Maar er is een probleem met de job die ik zelf (na meerdere malen geprobeerd te hebben) niet opgelost krijg.

Het probleem is dat wanneer ik alleen naar de marker van Los Santos rij hoor ik $3000 te ontvangen.

Maar ik plaats van dat ontvang ik $19000 en dit is het bedrag bij elkaar opgeteld dat ik zou ontvangen wanneer ik naar LS, SF en LV zal rijden.

Ik zal hier onder de scripts plaatsen en hoop dat iemand mij zou kunnen helpen.

Cliend:

  
local jobmarker = createMarker ( 1615.36, -1490.20, 13.23, "cylinder", 2, 255, 0, 0, 0 ) 
local ped = createPed  (0, 1615.36, -1490.20, 14.23, 180) 
local maxDistance = 12 
myFont = dxCreateFont( "font/SF Automaton Bold.ttf", 20 ) 
setElementFrozen(ped, true) 
  
GUIEditor_Label = {} 
  
local teamName = "Criminal" 
transWindow = guiCreateWindow(0.0, 0.8, 1.00, 0.20,"Transport the drugs",true) 
guiSetVisible(transWindow, false) 
destiLabel = guiCreateLabel(0.04,0.1,0.2,0.2,"Choose your destination:",true,transWindow) 
guiSetFont(destiLabel, guiCreateFont("font/1.ttf", 15)) 
lsButtonRadio = guiCreateRadioButton(0.01,0.4,0.25,0.07,"Los Santos, +2 Wanted Stars and 3000 if you made it",true,transWindow) 
lvButtonRadio = guiCreateRadioButton(0.01,0.5,0.25,0.07,"Las Venturas, +4 Wanted Stars and 6000 if you made it",true,transWindow) 
sfButtonRadio = guiCreateRadioButton(0.01,0.6,0.25,0.07,"San Fierro, +6 Wanted Stars and 10000 if you made it",true,transWindow) 
infoMemo = guiCreateMemo(0.30, 0.15, 0.40, 0.80,"Transport the drugs\n\nWhen you take the job you will get a free van with drugs.\nYou need to transport the drugs to the location that you have chosen.\nHow further the location how more money you will get paid.\nBut also you will get wanted level at the end of the ride!\n\nWhen you exit the vehicle then the vehicle will be destroyed.\nSo don't exit the vehicle our you must join the job again!",true,transWindow) 
guiMemoSetReadOnly(infoMemo,true) 
acceptButton = guiCreateButton(0.90, 0.15, 0.50, 0.90,"Accept job",true,transWindow) 
closeButton = guiCreateButton(0.80, 0.15, 0.10, 0.80,"Quit job",true,transWindow) 
  
addEventHandler("onClientMarkerHit", jobmarker, 
        function ( hitPlayer, matchingDimension ) 
                if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, jobmarker) ) then 
                        if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then 
                                if getElementType(hitPlayer) == "player" then 
                                        guiSetVisible ( transWindow, true ) 
                                        showCursor(true) 
                                        showChat(false) 
                                        showPlayerHudComponent ( 'all', false ) 
                                end 
                        else 
                        exports["AC_message"]:outputTopBar ( "Only criminals can transport drugs!", player, 255, 255, 0, 170 ,true ) 
                        end 
                end 
        end 
) 
  
function closeChangeJobWindow() 
    if (source == closeButton) then 
        guiSetVisible(transWindow, false) 
        showCursor(false) 
        showChat(true) 
        showPlayerHudComponent ( 'all', true ) 
        triggerServerEvent ( "sum", lp) 
    end 
end 
addEventHandler("onClientGUIClick", getResourceRootElement(getThisResource()), closeChangeJobWindow) 
  
  
         
addEventHandler ( "onClientPedDamage", resourceRoot, 
    function () 
        cancelEvent () 
        setElementFrozen(player, true) 
    end 
) 
  
function lsjobcli() 
   if (source == acceptButton) then 
            if (guiRadioButtonGetSelected(lsButtonRadio)) then 
        triggerServerEvent ("givePlayerJobLS",getLocalPlayer()) 
        guiSetVisible(transWindow, false) 
        showCursor(false) 
        showChat(true) 
        showPlayerHudComponent ( 'all', true ) 
    end 
end 
end 
addEventHandler("onClientGUIClick", acceptButton, lsjobcli, false ) 
  
function lvjobcli() 
   if (source == acceptButton) then  
            if (guiRadioButtonGetSelected(lvButtonRadio)) then  
        triggerServerEvent ("givePlayerJobLV",getLocalPlayer()) 
        guiSetVisible(transWindow, false) 
      showCursor(false) 
        showCursor(false) 
        showChat(true) 
        showPlayerHudComponent ( 'all', true ) 
    end 
end 
end 
addEventHandler("onClientGUIClick", acceptButton, lvjobcli, false ) 
  
function sfjobcli() 
   if (source == acceptButton) then  
            if (guiRadioButtonGetSelected(sfButtonRadio)) then  
        triggerServerEvent ("givePlayerJobSF",getLocalPlayer()) 
        guiSetVisible(transWindow, false) 
      showCursor(false) 
        showCursor(false) 
        showChat(true) 
        showPlayerHudComponent ( 'all', true ) 
    end 
end 
end 
addEventHandler("onClientGUIClick", acceptButton, sfjobcli, false ) 
         
            addEventHandler ( "onClientRender", root, 
        function ( ) 
     local pX, pY, pZ = getElementPosition ( localPlayer ) 
            local pedX, pedY, pedZ = getElementPosition ( ped ) 
            local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
            
            if ( distance <= 12 ) then 
                local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) 
                if ( x and y ) then 
                dxDrawText( "Drugs transport", x, y+1.5, _, _, tocolor( 255, 0, 0, 255 ), 1.2, myFont, "center", "center" ) 
                end 
            end 
        end 
    ) 
  

Server:

  
function lsjobser () 
     carLS = createVehicle (440, 2460.52, -2004.38, 13.54) 
     warpPedIntoVehicle(source, carLS) 
     markerLS = createMarker (1784.78, -1702.06, 12.50, "cylinder", 2, 255, 0, 0, 255) 
     blipLS = createBlipAttachedTo (markerLS, 40) 
end 
addEvent ("givePlayerJobLS", true) 
addEventHandler ("givePlayerJobLS", root, lsjobser) 
  
function moneyLS (attacker) 
     if (attackerLS) and (attackerLS ~= source) then 
     givePlayerMoney(attackerLS, 3000) 
     setPlayerWantedLevel(attackerLS, getPlayerWantedLevel(attackerLS)+2) 
     destroyElement(markerLS) 
     destroyElement(blipLS) 
     destroyElement(carLS) 
end 
end 
addEventHandler( "onMarkerHit", root, moneyLS ) 
  
function lvjobser () 
     carlv = createVehicle (440, 2460.52, -2004.38, 13.54) 
     warpPedIntoVehicle(source, carlv) 
     markerLV = createMarker (1074.43, 1292.71, 9.82, "cylinder", 2, 255, 0, 0, 255) 
     blipLV = createBlipAttachedTo (markerLV, 40) 
end 
addEvent ("givePlayerJobLV", true) 
addEventHandler ("givePlayerJobLV", root, lvjobser) 
  
function moneyLV (attackerLV) 
    if (attackerLV) and (attackerLV ~= source) then 
     givePlayerMoney(attackerLV, 6000) 
     setPlayerWantedLevel(attackerLV, getPlayerWantedLevel(attackerLV)+4) 
     destroyElement(markerLV) 
     destroyElement(blipLV) 
     destroyElement(carlv) 
end 
end 
addEventHandler( "onMarkerHit", root, moneyLV ) 
  
  
function sfjobser () 
     carSF = createVehicle (440, 2460.52, -2004.38, 13.54) 
     warpPedIntoVehicle(source, carSF) 
     markerSF = createMarker (-2052.80, 144.87, 27.83, "cylinder", 2, 255, 0, 0, 255) 
     blipSF = createBlipAttachedTo (markerSF, 40) 
end 
addEvent ("givePlayerJobSF", true) 
addEventHandler ("givePlayerJobSF", root, sfjobser) 
  
function moneySF (attackerSF) 
    if (attackerSF) and (attackerSF ~= source) then 
     givePlayerMoney(attackerSF, 10000) 
     setPlayerWantedLevel(attackerSF, getPlayerWantedLevel(attackerSF)+6) 
     destroyElement(markerSF) 
     destroyElement(blipSF) 
     destroyElement(carSF) 
end 
end 
addEventHandler( "onMarkerHit", root, moneySF ) 
  

Link to comment
  • Moderators

Try something like this:

  
local markerLS = createMarker (1784.78, -1702.06, 12.50, "cylinder", 2, 255, 0, 0, 255) 
local blipLS = createBlipAttachedTo (markerLS, 40) 
  
local markerLV = createMarker (1074.43, 1292.71, 9.82, "cylinder", 2, 255, 0, 0, 255) 
local blipLV = createBlipAttachedTo (markerLV, 40) 
  
local markerSF = createMarker (-2052.80, 144.87, 27.83, "cylinder", 2, 255, 0, 0, 255) 
local blipSF = createBlipAttachedTo (markerSF, 40) 
  
local visibilityTable = { 
    ["LS"]={markerLS,blipLS}, 
    ["LV"]={markerLV,blipLV}, 
    ["SF"]={markerSF,blipSF} 
}  
  
local vehicleJobSave = {}  
  
local changeVisibleJobElements = function (player,job,status) 
    local jobTable = visibilityTable[job] 
    if jobTable and type(status)== "boolean" then 
        for j=1,#jobTable do 
            local element = jobTable[j] 
            if isElement(element) then 
                setElementVisibleTo(element,player,status) 
            end 
        end 
    end 
end 
  
local lsjobser = function () 
    local carLS = createVehicle (440, 2460.52, -2004.38, 13.54) 
    warpPedIntoVehicle(source, carLS) 
    local lastCar = vehicleJobSave[source] 
    if lastCar and isElement(lastCar) then 
        destroyElement(lastCar) 
    end 
    vehicleJobSave[source] = carLS 
     
    changeVisibleJobElements(source,"LS",true) 
end 
addEvent ("givePlayerJobLS", true) 
addEventHandler ("givePlayerJobLS", root, lsjobser) 
  
local moneyLS = function (attackerLS) 
    if (attackerLS) and (attackerLS ~= source) then 
        givePlayerMoney(attackerLS, 3000) 
        setPlayerWantedLevel(attackerLS, getPlayerWantedLevel(attackerLS)+2) 
         
        local lastCar = vehicleJobSave[attackerLS] 
        if lastCar and isElement(lastCar) then 
            destroyElement(lastCar) 
        end 
        vehicleJobSave[attackerLS] = nil 
         
        changeVisibleJobElements(attackerLS,"LS",false) 
    end 
end 
addEventHandler( "onMarkerHit", markerLS, moneyLS ) 
  
local lvjobser = function () 
    local carlv = createVehicle (440, 2460.52, -2004.38, 13.54) 
    warpPedIntoVehicle(source, carlv) 
     
    local lastCar = vehicleJobSave[source] 
    if lastCar and isElement(lastCar) then 
        destroyElement(lastCar) 
    end 
    vehicleJobSave[source] = carlv 
     
    changeVisibleJobElements(source,"LV",true) 
end 
addEvent ("givePlayerJobLV", true) 
addEventHandler ("givePlayerJobLV", root, lvjobser) 
  
local moneyLV = function (attackerLV) 
    if attackerLV and attackerLV ~= source then 
        givePlayerMoney(attackerLV, 6000) 
        setPlayerWantedLevel(attackerLV, getPlayerWantedLevel(attackerLV)+4) 
         
        local lastCar = vehicleJobSave[attackerLV] 
        if lastCar and isElement(lastCar) then 
            destroyElement(lastCar) 
        end 
        vehicleJobSave[attackerLV] = nil 
         
        changeVisibleJobElements(attackerLV,"LV",false) 
    end 
end 
addEventHandler( "onMarkerHit", root, moneyLV ) 
  
  
local sfjobser = function () 
    local carSF = createVehicle (440, 2460.52, -2004.38, 13.54) 
    warpPedIntoVehicle(source, carSF) 
     
    local lastCar = vehicleJobSave[source] 
    if lastCar and isElement(lastCar) then 
        destroyElement(lastCar) 
    end 
    vehicleJobSave[source] = carSF 
     
    changeVisibleJobElements(source,"SF",true) 
end 
addEvent ("givePlayerJobSF", true) 
addEventHandler ("givePlayerJobSF", root, sfjobser) 
  
local moneySF = function (attackerSF) 
    if attackerSF and attackerSF ~= source then 
        givePlayerMoney(attackerSF, 10000) 
        setPlayerWantedLevel(attackerSF, getPlayerWantedLevel(attackerSF)+6) 
         
        local lastCar = vehicleJobSave[attackerSF] 
        if lastCar and isElement(lastCar) then 
            destroyElement(lastCar) 
        end 
        vehicleJobSave[attackerSF]= nil 
     
        changeVisibleJobElements(attackerSF,"SF",false) 
    end 
end 
addEventHandler( "onMarkerHit", root, moneySF ) 
  
------------------------------------------------------------------------------------- 
------------------------------------------------------------------------------------- 
------------------------------------------------------------------------------------- 
  
  
  
  
addEventHandler("onResourceStart",resourceRoot, 
function() 
    local players = getElementsByType("player") 
    for i=1,#players do 
        local player = players[i] 
        for kind,jobTable in pairs(visibilityTable) do 
            for j=1,#jobTable do 
                local element = jobTable[j] 
                if isElement(element) then 
                    setElementVisibleTo(element,player,false) 
                end 
            end 
        end 
    end 
end) 
  
addEventHandler("onPlayerJoin",root, 
function () 
    local player = source  
    for kind,jobTable in pairs(visibilityTable) do 
        for j=1,#jobTable do 
            local element = jobTable[j] 
            if isElement(element) then 
                setElementVisibleTo(element,player,false) 
            end 
        end 
    end 
end) 
  
addEventHandler("onPlayerQuit",root, 
function () 
    local lastCar = vehicleJobSave[source] 
    if lastCar and isElement(lastCar) then 
        destroyElement(lastCar) 
    end 
    vehicleJobSave[source] = nil 
end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...