Jump to content

OnClientMarkerHit


tosfera

Recommended Posts

Hey guys,

I keep havling the same issues. Im trying to avoid them but, there has to be a time that I'm going to learn it.... Client scripting. So I started yesterday with client-sided coding, and its not that bad tbh... just one function I really hate... 'onClientMarkerHit'.

So, here's the problem: I'm creating a marker in a function. I can NOT avoid this, and I dont want to. But, when I'm making the onClientMarkerHit it doesn't realy work. and I'm thinking its because I created it in another function, but its still the same file. can't be the problem if you ask me. So here's the code I got so far:

addEvent("startJob_trucker", true) 
addEventHandler("startJob_trucker", root, 
    function (source) 
        --local places = { {"2754", "-2455", "13"}, {"364", "-2026", "7"} } 
        local places = { {"2405","-2093","13"} } 
        local randJob = math.random(1, 1) 
        local finishTrucker = createMarker(places[randJob][1], places[randJob][2], places[randJob][3], "cylinder", 2, 255, 0, 0, 150) 
        local blipTrucker = createBlip(places[randJob][1], places[randJob][2], places[randJob][3], 41) 
        outputChatBox(places[randJob][1]) 
        if finish then 
            errorMsg("Deliver this delivery quick!") 
        end 
    end 
) 
  
addEventHandler("onClientMarkerHit", finishTrucker, 
    function () 
        outputChatBox("KOEKJES") 
    end 
) 

Link to comment
addEvent("startJob_trucker", true) 
addEventHandler("startJob_trucker", root, 
    function (source) 
        --local places = { {"2754", "-2455", "13"}, {"364", "-2026", "7"} } 
      local places = { {"2405","-2093","13"} } 
       local randJob = math.random(1, 1) 
        finishTrucker = createMarker(places[randJob][1], places[randJob][2], places[randJob][3], "cylinder", 2, 255, 0, 0, 150) 
        local blipTrucker = createBlip(places[randJob][1], places[randJob][2], places[randJob][3], 41) 
        outputChatBox(places[randJob][1]) 
        if finish then 
            errorMsg("Deliver this delivery quick!") 
        end 
    end 
) 
  
addEventHandler("onClientMarkerHit", finishTrucker, 
    function () 
        outputChatBox("KOEKJES") 
    end 
) 

Link to comment
addEvent("startJob_trucker", true) 
addEventHandler("startJob_trucker", root, 
    function (source) 
        --local places = { {"2754", "-2455", "13"}, {"364", "-2026", "7"} } 
      local places = { {"2405","-2093","13"} } 
       local randJob = math.random(1, 1) 
        finishTrucker = createMarker(places[randJob][1], places[randJob][2], places[randJob][3], "cylinder", 2, 255, 0, 0, 150) 
        local blipTrucker = createBlip(places[randJob][1], places[randJob][2], places[randJob][3], 41) 
        outputChatBox(places[randJob][1]) 
        if finish then 
            errorMsg("Deliver this delivery quick!") 
        end 
    end 
) 
  
addEventHandler("onClientMarkerHit", finishTrucker, 
    function () 
        outputChatBox("KOEKJES") 
    end 
) 

Doesn't work either. n_n"

Link to comment
You want this marker to give a truck and a trucker job to how ever touches it ?

Well not rly, I already got that part. I'm just having a war with the marker and the onClientMarkerHit. It has to finish the job, like; check the team, vehicle, trailer etc etc. but I can do that myself. I guess, I just have no idea why he isn't say: "KOEKJES!" when I hit the marker. :\ has it something to do with the first line?

addEventHandler("onClientMarkerHit", , 

EDIT:

Got it working like this;

addEventHandler("onClientMarkerHit", root, 
    function (hitPlayer) 
        if source == finishTrucker then 
            outputChatBox("asd") 
        end 
    end 
) 

It was the first line. I placed the marker name, wich is server side... :x

Thanks everyone.

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