Jump to content

[HELP] delivery


Hero192

Recommended Posts

Hello,i'am gonna release the resource of Drug delivery to the community and after testing it i found one bug,

What's it? If two players or more spawned the truck to deliver it to the marker, only one person who gonna take money and when the first person hit the marker the elements(marker/blip/vehicle) be destroyed only for who hited the marker and the guy who didn't hit it he keep with the vehicle only but other elements being invislbe and showing only for one person exept "Vehicle"

Here's the code have a look on it maybe you'll fix it easly than me,thanks

local ped = createPed(29, 1602.55, -1489.33, 13.59,180) 
  
  
function onDrugDeliveryPedClick(button, state, absX, absY, wx, wy, wz, element) 
    if element and getElementType(element) == "ped" and state=="down" and button=="left" then 
        local x, y, z = getElementPosition(element) 
        --if getTeamName(getPlayerTeam(element)) ~= "Criminal" then outputChatBox("Drug Delivery: You must be criminal.",255,0,0) return end 
        if getElementData(element,"Name") then 
        if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then 
        guiSetVisible(Window,true) 
               end 
         end 
    end 
end 
addEventHandler("onClientClick", rootElement, onDrugDeliveryPedClick) 
 addEventHandler("onClientPedDamage",root, 
function () 
    if getElementData(source,"Name") then 
        cancelEvent() 
    end 
end) 
  
function Location1() 
    markerlocation1 = createMarker (2661.95, -1429.37, 29.49, "cylinder", 4, 238, 44, 44, 255) 
    blipLS = createBlipAttachedTo (markerlocation1, 51) 
    addEventHandler( "onClientMarkerHit", markerlocation1, 
        function ( hitPlayer, d ) 
                if isElement(markerlocation1) then 
                    destroyElement(markerlocation1) 
                    destroyElement(blipLS) 
                end 
            triggerServerEvent("doPayClient", hitPlayer) 
        end 
    ) 
end 
  
  
function Location2() 
    markerlocation2 = createMarker (-2642.98, 1371.07, 7.16, "cylinder", 4,238, 44, 44, 255) 
    blipSF = createBlipAttachedTo (markerlocation2, 51) 
    addEventHandler( "onClientMarkerHit", markerlocation2, 
        function ( hitPlayer, d ) 
                if isElement(markerlocation2) then 
                    destroyElement(markerlocation2) 
                    destroyElement(blipSF) 
                end 
            triggerServerEvent("doPayClient2", hitPlayer) 
        end 
    ) 
end 
  
   
function Location3() 
    markerlocation3 = createMarker (1064.73, 2342.83, 9.82, "cylinder", 4, 238, 44, 44, 255) 
    blipLV = createBlipAttachedTo (markerlocation3, 51) 
    addEventHandler( "onClientMarkerHit", markerlocation3, 
        function ( hitPlayer, d ) 
                if isElement(markerlocation3) then 
                    destroyElement(markerlocation3) 
                    destroyElement(blipLV) 
                end 
            triggerServerEvent("doPayClient3", hitPlayer) 
        end 
    ) 
end 
  
  
function onRejectClick() 
    if (source == reject) then 
        setCameraTarget(localPlayer) 
        guiSetVisible(Window, false) 
        showCursor(false) 
end 
end 
  
addEventHandler("onClientGUIClick", guiRoot, onRejectClick) 
  
   function missionButton() 
      if (source == accept) then 
      setCameraTarget (localPlayer) 
     if (guiRadioButtonGetSelected(location1)) then 
            triggerServerEvent ("givePVehicle",getLocalPlayer()) 
            Location1() 
            guiSetVisible (Window,false) 
            showCursor (false) 
             
        elseif (guiRadioButtonGetSelected(location2)) then --assuming that locaion2 contains the location 2 radio button option 
            triggerServerEvent ("givePVehicle",getLocalPlayer()) 
            Location2() 
            guiSetVisible (Window,false) 
            showCursor (false) 
        end 
        end 
        end 
addEventHandler("onClientGUIClick", guiRoot, missionButton) 
   function missionButton2() 
      if (source == accept) then 
 if (guiRadioButtonGetSelected(location3)) then --assuming that locaion3 contains the location 3 radio button option 
            triggerServerEvent ("givePVehicle",getLocalPlayer()) 
            Location3() 
            guiSetVisible (Window,false) 
            showCursor (false) 
             
end 
end 
end 
addEventHandler("onClientGUIClick", guiRoot, missionButton2) 

--Server side:

local vehicles = {} 
  
addEvent("doPayClient", true) 
addEventHandler( "doPayClient", root, 
    function() 
        givePlayerMoney(source, 2000) 
        setPlayerWantedLevel(source, getPlayerWantedLevel(source)+1) 
        if isElement(vehicles[source]) then 
            destroyElement(vehicles[source]) 
        end 
    end 
) 
  
 addEvent("doPayClient2", true) 
addEventHandler( "doPayClient2", root, 
    function() 
        givePlayerMoney(source, 4000) 
        setPlayerWantedLevel(source, getPlayerWantedLevel(source)+2) 
        if isElement(vehicles[source]) then 
            destroyElement(vehicles[source]) 
        end 
    end 
) 
  
  addEvent("doPayClient3", true) 
addEventHandler( "doPayClient3", root, 
    function() 
        givePlayerMoney(source, 6000) 
        setPlayerWantedLevel(source, getPlayerWantedLevel(source)+3) 
        if isElement(vehicles[source]) then 
            destroyElement(vehicles[source]) 
        end 
    end 
) 
addEvent("givePVehicle", true) 
addEventHandler( "givePVehicle", root, 
    function() 
        local vehicle = createVehicle (482,1605.42, -1472.97, 13.58,0,0,0) 
        vehicles[source] = vehicle 
        warpPedIntoVehicle(source,vehicles[source]) 
    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...