Jump to content

roaddog

Members
  • Posts

    346
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by roaddog

  1. how your table looks like?

     

    tkill = {{"aa", 10}, {"bb", 2}, {"cc", 5}}
    -- Sort the table from high to low
    table.sort(tkill, function (a, b) return a[2] > b[2] end)
    
    for i, v in pairs(tkill) do
        print(v[1], v[2])
    end
    -- This will result:
    -- aa, 10
    -- cc, 5
    -- bb, 2
    
    function getKeyFromVal(name)
        if (not name) then
            return false
        end
        for i, v in pairs(tkill) do
            if (v[1] == name) then
               return i
            end
        end
        return false
    end
    
    function addkill(name, num)
        if (not name or not num) then
            return false
        end
        local key = getKeyFromVal(name)
        tkill[key][2] = tkill[key][2] + num
    end
    -- we add 6 kill to the "bb"
    addkill("bb", 6)
    -- sort again
    table.sort(tkill, function (a, b) return a[2] > b[2] end)
    
    for i, v in pairs(tkill) do
        print(v[1], v[2])
    end
    --This will result
    -- aa, 10
    -- bb, 8
    -- cc, 5

     

  2. addEventHandler("onMarkerHit", meslekbitis_marker2, meslekbitis)

    move ^ line to

    function ikincimeslek(oyuncu)
        if oyuncu then
            if isElement(kargo_arac[oyuncu]) then
            destroyElement(meslekbitis_marker) 
            destroyElement(kargobitis_blips)
            outputChatBox("#9ACD32[Kargo Mesleği]: #FFFFFFKargoların indirililiyor, ücretiniz almak için kargo dağıtım merkezine geri dön.",oyuncu,255,255,255,true)
            meslekbitis_marker2 = createMarker(-62.74648, -1111.28027, 1.07812, "checkpoint", 2.5 , 255, 185, 15)
    	addEventHandler("onMarkerHit", meslekbitis_marker2, meslekbitis)
            end
        end 
    end

     

  3. Create your own panel with guiStaticImage or via guieditor

    --Client

    panel = guiCreateStaticImage( 20, 200, 100, 100, "imagename.png", false)
    button1 = guiCreateStaticImage( 10, 20, 20, 20, "imagename.png", false, panel)
    addEventHandler("onClientGUIClick", button1, transportToOne, false)
    
    function showTransportPanels()
        if (not guiGetVisible(panel)) then
            guiSetVisible(panel, true)
            showCursor(true)
        end
    end
    addEvent("showTransportPanel", true)
    addEventHandler("showTransportPanel", root, showTransportPanels)
    
    function transportToOne(btn, st)
        if (btn ~= "left" or st ~= "up") then
            if (guiGetVisible(panel)) then
                guiSetVisible(panel, false)
                showCursor(false)
            end
            triggerServerEvent("transportPlayerTo", resourceRoot, 1)
        end
    end

    --Server

    local playerMarker = createMarker(0, 0, 2, "cylinder", 5, 10, 244, 23, 200, root)
    
    function handlePlayerMarker(hitElement, matchingDim)
    	local elementType = getElementType(hitElement)
        if (elementType ~= "player" or not matchingDim or isPedInVehicle(hitElement)) then
            return false
        end
        triggerClientEvent(hitElement, "showTransportPanel", hitElement)
    end
    addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
    
    function transportPlayerTo(place)
        if (place == 1) then
            fadeCamera(client, false, 1)
            setElementPosition(client, x, y, z)
            setTimer(fadeCamera, 1000, 1, client, true)
        end
    end
    addEvent("transportPlayerTo", true)
    addEventHandler("transportPlayerTo", resourceRoot, transportPlayerTo)

    untested but you can figure it out by yourself

    • Like 1
  4. 6 hours ago, Sendy said:

    But how i Can detect if my ped is hit by water Can? 

    local cPed = createPed(0, x, y, z)
    
    function outputPlayerHitByWater(thePed)
    	local attacker = getVehicleOccupant(source)
    	if (thePed == cPed and getElementType(thePed) == "ped") then
    		killPed ( thePed, attacker, 56, 9, false)
    	end
    end
    addEventHandler("onClientPedHitByWaterCannon", getRootElement(), outputPlayerHitByWater)

     

  5. 7 hours ago, Firespider said:
    Why is playerMaker not detected?
     

     

     

    unknown.png

    unknown.png

    addEvent("car", true)
    addEventHandler("car", root,
        function()
            if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
            local x, y, z = getElementPosition(source)
            vehicle[source] = createVehicle(599, x, y, z) --599 is the vehicle's hands. Put any vehicle you want
            warpPedIntoVehicle(source, vehicle[source])
            playerMarker = createMarker(341.64114379883, -1351.6920166016, 14.5078125, "cylinder", 1, 10, 244, 23, 200)
            addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
    end)
    
    function handlePlayerMarker(hitElement)
        local elementType = getElementType(hitElement)
        outputChatBox(" Itt tudod fel venni a szolgálatott /dutyonR")
        outputChatBox("Itt tudod le tenni a szolgálatott /dutyoffR")
    end

     

     

  6. 7 hours ago, Firespider said:
    No, you know, the pads are included in the game and if you click on them, the panel will appear
     
     
     
     
     
     
     

    addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld)
        if (button == "right") and (state == "up") then
            IsCardShop = true--- 
        end
    end) 

    That's what I mean
     
     
     
    Is this also possible with the new code?
     
     
     
    So I don't mean that if a button is pressed, the panel opens, but if a player clicks on a Ped, the panel opens.
     
     
     
    Anyway, thanks for the code you sent, I'll try it later. and if everything is true, I have already solved the ped thing
     
     
     
    local thePed = createPed(0, x, y, z)
    
    addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld)
        if (button == "right") and (state == "up") then
            if isElement(clickedWorld) and clickedWorld == thePed then
                IsCardShop = not IsCardShop
                removeEventHandler("onClientRender", root, Panel)
                if IsCardShop then
                    addEventHandler("onClientRender", root, Panel)
                end
            end
        end
    end)

    here

×
×
  • Create New...