Jump to content

[HELP] Marker won't show on client


UTurn

Recommended Posts

I'm working on a police script, and I'm creating markers/blips on the client of the police officer to show him where to jail the player.

Heres the event handlers that create/destroy the markers and blips, and checks for the hit:

-- 
-- Creates all the jail markers/blips when a cop gets an arrest. 
-- 
addEventHandler("showJailMarkers", localPlayer, 
    function (jailPoints) 
        for k,jPoint in ipairs(jailPoints) do 
            local x = jPoint[1] 
            local y = jPoint[2] 
            local z = jPoint[3] 
             
            if x and y and z then 
                local jailMark = createMarker(x,y,z, "cylinder", 4.0, 50,130,200, 195) 
                setElementData(jailMark, "isJailMark", true) 
                setElementDimension(jailMark, 0) 
                table.insert(JAIL_MARKS, jailMark) 
                table.insert(JAIL_BLIPS, createBlip(x,y,0, 30, 2.0, 255,0,0,255, 0, 400.0)) 
            end 
        end 
    end 
) 
  
-- 
-- Destroys all the jail markers/blips when a cop no longer has prisoners. 
-- 
addEventHandler("hideJailMarkers", localPlayer, 
    function () 
        for key,jailMark in pairs(JAIL_MARKS) do 
            if isElement(jailMark) then destroyElement(jailMark) end 
        end 
         
        for key,jailBlip in pairs(JAIL_BLIPS) do 
            if isElement(jailBlip) then destroyElement(jailBlip) end 
        end 
    end 
) 
  
-- 
-- Jails all prisoners when the captor enters the jail marker. 
-- 
addEventHandler("onClientMarkerHit", root, 
    function (hitPlayer, dimensionMatch) 
        if (hitPlayer ~= localPlayer) then return end 
         
        if (getElementData(source, "isJailMark") == true) then 
            triggerServerEvent("policeJailPrisoners", resourceRoot) 
        end 
    end 
) 

I use data from the map file to get the locations to place blips and markers. Everything else works fine, i can arrest the player, walk into where the marker should be, and it sends him to jail. But when I arrest a player, the blip shows up on my client, but not the marker. I can't use `setElementVisibleTo` because I don't want to create the markers on the serverside. I've tried using `setElementDimension(jailMark, 0)` to ensure the marker is in the same dimension but it still is invisible.

If it makes any difference here's where the event to create the markers gets triggered on the server:

-- 
-- Forces a player arrested with the baton to follow is captor. 
-- 
addEventHandler("policePlayerArrested", resourceRoot, 
    function (captor) 
        local prisoner = client 
         
        exports.AC_message:outputTopBar("Damn son! You got arrested by "..getPlayerName(captor), prisoner, 255,0,0) 
        exports.AC_message:outputTopBar("You've placed "..getPlayerName(prisoner).." under police custody.", captor, 50,130,200) 
         
        -- Disable the prisoners GTA controls. 
        toggleAllControls(prisoner, false, true, false) 
        triggerClientEvent(prisoner, "onWindowOpen", prisoner, false) 
        setPedWeaponSlot(prisoner, 0) 
         
        -- Set the players arrest data and force him to follow his captor. 
        setElementData(prisoner, "isArrested", true) 
        setElementData(prisoner, "arrestedBy", captor) 
        forcePrisonerFollow(captor, prisoner) 
         
        -- If the new prisoner is a cop free all his prisoners. 
        if exports.gtc_jobsys:isAssignedJob(prisoner, "Police") then 
            freeAllPrisoners(prisoner) 
        end 
         
        -- If this is the cops first arrest, show the jail markers. 
        local prisonerCount = getPrisonerCount(captor) 
         
        if (prisonerCount == 1) then 
            triggerClientEvent(captor, "showJailMarkers", captor, exports.GTC:getJailmarkPoints()) 
        end 
    end 
) 

What could I be doing wrong? If the blips show I don't see why the markers wouldn't show.

Link to comment

Well I've solved it. I looked hard for the source of my problem, but in the wrong places. An error where the map data was loaded (which I failed to provide here, bad move to ommit when seeking help) was giving me an incorrect Z position. So I couldn't see the marker, but I could hit it's area.

Well, atleast posting this question caused me to look even harder xD

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...