Jump to content

Client side scripts


tosfera

Recommended Posts

Hey,

Okee so I'll ask one more question. And that will be it!! ( I hope),

I wrote this script, it will give you a job, a truck + a trailer. it will create a marker and blip CLIENT SIDED. BUT! When I start the job, and a friend of me starts it to, only one of us can finish it. :\ I tought that client was only for 1 player, and not for everyone...

So, here's the script:

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) 
        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", root, 
    function (hitPlayer) 
        if source == finishTrucker then 
            local v = getPedOccupiedVehicle(hitPlayer) 
            if v then 
                local model = getElementModel(v) 
                local team = getPlayerTeam(hitPlayer) 
                if model == 515 and team then 
                    local teamName = getTeamName(team) 
                    if teamName == "Trucker" then 
                        destroyElement(finishTrucker) 
                        destroyElement(blipTrucker) 
                        triggerServerEvent("jobFinish_trucker", getLocalPlayer(), hitPlayer, v) 
                    end                  
                end 
            end 
        end 
    end 
) 

Link to comment

Let me get the parts that you need;

resource start (crap)

  
addEventHandler("onResourceStart", root, 
    function () 
        Trucker = createTeam ( "Trucker", 255, 234, 0 ) 
    end 
) 
  

]

okee, when he enters the marker, it all starts here:

  
addEventHandler("onMarkerHit", jobMarker_trucker1, 
    function ( source, hitPlayer ) 
        if getElementType( source ) == "player" then 
        local isTeam = getPlayerTeam( source ) 
        if isTeam then 
            local team = getTeamName( getPlayerTeam ( source ) )             
            if team and team == "Trucker" then   
                local job = getAccountData(getPlayerAccount(source), "player-job") 
                if job == false then 
                    triggerClientEvent(source, "startJob_trucker", root) 
                    startJob_trucker_marker1() 
                    setAccountData(getPlayerAccount(source), "player-job", true) 
                else 
                    triggerClientEvent(source, "errorMsg", root, "You are already on a job") 
                end 
            end 
        end 
        end 
    end 
) 
  

Link to comment

I don't really know what do but firt, try this out? There was an error in the 2nd script you sent.

  
addEventHandler("onMarkerHit", jobMarker_trucker1, 
    function ( source, hitPlayer ) 
        if getElementType( source ) == "player" then 
        local isTeam = getPlayerTeam( source ) 
        if isTeam then 
            local team = getTeamName( getPlayerTeam ( source ) )             
            if team and team == "Trucker" then   
                local job = getAccountData(getPlayerAccount(source), "player-job") 
                if job == false then 
                    triggerClientEvent(source, "startJob_trucker", root) 
                    startJob_trucker_marker1() 
                    setAccountData(getPlayerAccount(source), "player-job", true) 
                else 
                    triggerClientEvent(source, "errorMsg", root, "You are already on a job") 
                end 
            end 
        end 
    end 
end) 
  

Link to comment
I don't really know what do but firt, try this out? There was an error in the 2nd script you sent.
  
addEventHandler("onMarkerHit", jobMarker_trucker1, 
    function ( source, hitPlayer ) 
        if getElementType( source ) == "player" then 
        local isTeam = getPlayerTeam( source ) 
        if isTeam then 
            local team = getTeamName( getPlayerTeam ( source ) )             
            if team and team == "Trucker" then   
                local job = getAccountData(getPlayerAccount(source), "player-job") 
                if job == false then 
                    triggerClientEvent(source, "startJob_trucker", root) 
                    startJob_trucker_marker1() 
                    setAccountData(getPlayerAccount(source), "player-job", true) 
                else 
                    triggerClientEvent(source, "errorMsg", root, "You are already on a job") 
                end 
            end 
        end 
    end 
end) 
  

Nothing changed hahaha, you just replaced my if, and my last bracket. Its just a coding standart. Thats all. ;o

Link to comment

Try this:

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) 
        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", root, 
    function (hitPlayer) 
        if ( source == finishTrucker ) and ( hitPlayer == localPlayer ) then 
            local v = getPedOccupiedVehicle(hitPlayer) 
            if v then 
                local model = getElementModel(v) 
                local team = getPlayerTeam(hitPlayer) 
                if model == 515 and team then 
                    local teamName = getTeamName(team) 
                    if teamName == "Trucker" then 
                        destroyElement(finishTrucker) 
                        destroyElement(blipTrucker) 
                        triggerServerEvent("jobFinish_trucker", getLocalPlayer(), hitPlayer, v) 
                    end                 
                end 
            end 
        end 
    end 
) 

Link to comment
Try this:
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) 
        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", root, 
    function (hitPlayer) 
        if ( source == finishTrucker ) and ( hitPlayer == localPlayer ) then 
            local v = getPedOccupiedVehicle(hitPlayer) 
            if v then 
                local model = getElementModel(v) 
                local team = getPlayerTeam(hitPlayer) 
                if model == 515 and team then 
                    local teamName = getTeamName(team) 
                    if teamName == "Trucker" then 
                        destroyElement(finishTrucker) 
                        destroyElement(blipTrucker) 
                        triggerServerEvent("jobFinish_trucker", getLocalPlayer(), hitPlayer, v) 
                    end                 
                end 
            end 
        end 
    end 
) 

hmmm I see, this did the trick;

  
if ( source == finishTrucker ) and ( hitPlayer == localPlayer ) then 
  

Nothing else is changes, as I see. Thanks! Learned something again :D

Link to comment
Yes, that's what I added, since "onClientMarkerHit" is triggered by remote players as well.

You're welcome.

Hmm,, since you're still here. It doesn't destroy the element after 3 times. O_O, like, I'm becoming a trucker, doing 3 runs, and the third time, the markers doens't get destroyed. but I am getting an error, dont know if thats the problem.

Bad 'ped' pointer @ getPedOccupiedVehicle 

He's crying about this part;

(server scripts btw)

  
addEventHandler("onMarkerHit", jobMarker_trucker_newTrailer, 
    function ( hitPlayer, source ) 
        local v = getPedOccupiedVehicle( hitPlayer ) 
        if v then 
            local model = getElementModel(v) 
            if model == 515 then 
                if job then 
                    triggerClientEvent(hitPlayer, "errorMsg", root, "You still got a delivery to do!") 
                else 
                    triggerClientEvent(hitPlayer, "errorMsg", root, "Great work, keep it up!") 
                    triggerClientEvent(hitPlayer, "startJob_trucker", root) 
                end 
            end 
        end 
    end 
) 

Link to comment

Try this:

addEventHandler ( "onMarkerHit", jobMarker_trucker_newTrailer, 
    function ( hitPlayer ) 
        if ( getElementType ( hitPlayer ) == "player" ) then 
            local v = getPedOccupiedVehicle ( hitPlayer ) 
            if ( v ) then 
                local model = getElementModel ( v ) 
                if ( model == 515 ) then 
                    if ( job ) then 
                        triggerClientEvent ( hitPlayer, "errorMsg", root, "You still got a delivery to do!" ) 
                    else 
                        triggerClientEvent ( hitPlayer, "errorMsg", root, "Great work, keep it up!" ) 
                        triggerClientEvent ( hitPlayer, "startJob_trucker", root ) 
                    end 
                end 
            end 
        end 
    end 
) 

Link to comment
Try this:
addEventHandler ( "onMarkerHit", jobMarker_trucker_newTrailer, 
    function ( hitPlayer ) 
        if ( getElementType ( hitPlayer ) == "player" ) then 
            local v = getPedOccupiedVehicle ( hitPlayer ) 
            if ( v ) then 
                local model = getElementModel ( v ) 
                if ( model == 515 ) then 
                    if ( job ) then 
                        triggerClientEvent ( hitPlayer, "errorMsg", root, "You still got a delivery to do!" ) 
                    else 
                        triggerClientEvent ( hitPlayer, "errorMsg", root, "Great work, keep it up!" ) 
                        triggerClientEvent ( hitPlayer, "startJob_trucker", root ) 
                    end 
                end 
            end 
        end 
    end 
) 

Thanks! You're like,,, god or something. xD back in the days when we still talked, you were good. But now, FCK ITS INSANE! :lol:

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