Jump to content

[HELP] i am new to scripting


Recommended Posts

i created tree cuting job in my server but it have probem. when i take job ,job panel going to all players in server . how can fix it

jobPed = createPed(230, 870.47406, -24.95437, 63.97986, 160)
setPedFrozen(jobPed, true)
jobMarker = createMarker(870.02686, -25.90853, 62.90933, "cylinder", 1.5)
createBlipAttachedTo(jobMarker, 22)
 
addEventHandler("onClientMarkerHit", jobMarker, function(player) 
 window = guiCreateWindow(500, 200, 250, 250, "*Tree JoB*", false)
 memo = guiCreateMemo(100, 20, 240, 100, "Unicos RP Tree Job You can make esy money with rhis one# happy happy happy", false, window)
 button = guiCreateButton(20, 150, 100, 100, "Accep", false, window)
 closebutton = guiCreateButton(150, 150, 100, 100, "Close", false, window)
showCursor(true)
end)

function clicks()

 if source == closebutton then 

    guiSetVisible(window, false)
    showCursor(false)
 elseif source == button then
     
     guiSetVisible(window, false)
     showCursor(false) 
     --outputChatBox("You Have a Job!", 0, 255, 0)
     triggerServerEvent("StartTreeJob", resourceRoot, localPlayer)
    end

end

addEventHandler("onClientGUIClick", root, clicks)

 

Link to comment

why onclientHitmarker does not working

jobPed = createPed(230, 870.47406, -24.95437, 63.97986, 160)
setPedFrozen(jobPed, true)
jobMarker = createMarker(870.02686, -25.90853, 62.90933, "cylinder", 1.5)
createBlipAttachedTo(jobMarker, 22)
  
function job(theplayer , matchingDimension)

 if theplayer and theplayer == localplayer and matchingDimension then
   window = guiCreateWindow(500, 200, 250, 250, "*Tree JoB*" ,false)
   memo = guiCreateMemo(100, 20, 240, 100, "Unicos RP Tree Job You can make esy money with rhis one# happy happy happy" ,false, window)
   button = guiCreateButton(20, 150, 100, 100, "Accep" ,false, window)
   closebutton = guiCreateButton(150, 150, 100, 100, "Close" ,false, window)
   showCursor(true)
 end

end

addEventHandler("onClientMarkerHit", jobMarker, job)

function clicks()

 if source == closebutton then 

    guiSetVisible(window, false)
    showCursor(false)
 elseif source == button then
     
     guiSetVisible(window, false)
     showCursor(false) 
     triggerServerEvent("StartTreeJob", resourceRoot, localPlayer)
    end

end

addEventHandler("onClientGUIClick", root, clicks)

 

Link to comment
49 minutes ago, Burak5312 said:

 

can you show the server side?

 
addEvent("StartTreeJob", true)
addEventHandler("StartTreeJob", root, function(player)
Cut = createMarker(866.58081, -37.67114, 62.91922, "cylinder", 1.0, 0, 255, 255)

addEventHandler("onMarkerHit", Cut, function ()
       
       setPedFrozen(player, true) 
       setTimer(function()
        setPedAnimation(player, "SWORD", "sword_4", 1, true)
       end, 200, 20)
       
       setTimer(function()
         setPedFrozen(player, false)
         givePlayerMoney(player, math.random(1000, 5000))       
        end, 4000, 1)
   end)
end) 

 

Just now, MaLiYaViBz said:
 
addEvent("StartTreeJob", true)
addEventHandler("StartTreeJob", root, function(player)
Cut = createMarker(866.58081, -37.67114, 62.91922, "cylinder", 1.0, 0, 255, 255)

addEventHandler("onMarkerHit", Cut, function ()
       
       setPedFrozen(player, true) 
       setTimer(function()
        setPedAnimation(player, "SWORD", "sword_4", 1, true)
       end, 200, 20)
       
       setTimer(function()
         setPedFrozen(player, false)
         givePlayerMoney(player, math.random(1000, 5000))       
        end, 4000, 1)
   end)
end) 

 

 

Link to comment
2 hours ago, FlorinSzasz said:

also replace the your last line with this

addEventHandler ( "onClientGUIClick", closebutton, clicks, false )
addEventHandler ( "onClientGUIClick", button, clicks, false )

 

 oh no its my mistake. when hit   player on marker. job panel goin all players

Link to comment
2 hours ago, MaLiYaViBz said:

why onclientHitmarker does not working

jobPed = createPed(230, 870.47406, -24.95437, 63.97986, 160)
setPedFrozen(jobPed, true)
jobMarker = createMarker(870.02686, -25.90853, 62.90933, "cylinder", 1.5)
createBlipAttachedTo(jobMarker, 22)
  
function job(theplayer , matchingDimension)

 if theplayer and theplayer == localplayer and matchingDimension then
   window = guiCreateWindow(500, 200, 250, 250, "*Tree JoB*" ,false)
   memo = guiCreateMemo(100, 20, 240, 100, "Unicos RP Tree Job You can make esy money with rhis one# happy happy happy" ,false, window)
   button = guiCreateButton(20, 150, 100, 100, "Accep" ,false, window)
   closebutton = guiCreateButton(150, 150, 100, 100, "Close" ,false, window)
   showCursor(true)
 end

end

addEventHandler("onClientMarkerHit", jobMarker, job)

function clicks()

 if source == closebutton then 

    guiSetVisible(window, false)
    showCursor(false)
 elseif source == button then
     
     guiSetVisible(window, false)
     showCursor(false) 
     triggerServerEvent("StartTreeJob", resourceRoot, localPlayer)
    end

end

addEventHandler("onClientGUIClick", root, clicks)

 

jobPed = createPed(230, 870.47406, -24.95437, 63.97986, 160)
setPedFrozen(jobPed, true)
jobMarker = createMarker(870.02686, -25.90853, 62.90933, "cylinder", 1.5)
createBlipAttachedTo(jobMarker, 22)

function job(thePlayer, matchingDimension)
    if thePlayer and thePlayer == localPlayer and matchingDimension then
        window = guiCreateWindow(500, 200, 250, 250, "*Tree JoB*", false)
        memo = guiCreateMemo(20, 20, 210, 140, "Unicos RP Tree Job. You can make easy money with this one. Happy happy happy.", false, window)
        button = guiCreateButton(30, 180, 80, 40, "Accept", false, window)
        closebutton = guiCreateButton(140, 180, 80, 40, "Close", false, window)
        showCursor(true)
    end
end

addEventHandler("onClientMarkerHit", jobMarker, job)

function clicks(button, state)
    if button == "left" and state == "up" then
        if source == closebutton then
            guiSetVisible(window, false)
            showCursor(false)
        elseif source == button then
            guiSetVisible(window, false)
            showCursor(false)
            triggerServerEvent("StartTreeJob", resourceRoot, localPlayer)
        end
    end
end

addEventHandler("onClientGUIClick", root, clicks)

 

I hope this helps!

  • Like 1
Link to comment
39 minutes ago, Shady1 said:
jobPed = createPed(230, 870.47406, -24.95437, 63.97986, 160)
setPedFrozen(jobPed, true)
jobMarker = createMarker(870.02686, -25.90853, 62.90933, "cylinder", 1.5)
createBlipAttachedTo(jobMarker, 22)

function job(thePlayer, matchingDimension)
    if thePlayer and thePlayer == localPlayer and matchingDimension then
        window = guiCreateWindow(500, 200, 250, 250, "*Tree JoB*", false)
        memo = guiCreateMemo(20, 20, 210, 140, "Unicos RP Tree Job. You can make easy money with this one. Happy happy happy.", false, window)
        button = guiCreateButton(30, 180, 80, 40, "Accept", false, window)
        closebutton = guiCreateButton(140, 180, 80, 40, "Close", false, window)
        showCursor(true)
    end
end

addEventHandler("onClientMarkerHit", jobMarker, job)

function clicks(button, state)
    if button == "left" and state == "up" then
        if source == closebutton then
            guiSetVisible(window, false)
            showCursor(false)
        elseif source == button then
            guiSetVisible(window, false)
            showCursor(false)
            triggerServerEvent("StartTreeJob", resourceRoot, localPlayer)
        end
    end
end

addEventHandler("onClientGUIClick", root, clicks)

 

I hope this helps!

accept button is not working corectly

Link to comment
16 minutes ago, MaLiYaViBz said:

accept button is not working corectly

function clicks(button, state, _, _)
    if button == "left" and state == "up" then
        if source == closebutton then
            guiSetVisible(window, false)
            showCursor(false)
        elseif source == button then
            guiSetVisible(window, false)
            showCursor(false)
            triggerServerEvent("StartTreeJob", resourceRoot, localPlayer)
        end
    end
end

 

Link to comment
1 hour ago, MaLiYaViBz said:

 oh no its my mistake. when hit   player on marker. job panel goin all players

yes because you call it for every player not the one who hits the marker

addEventHandler("onClientMarkerHit", jobMarker, function(player) 
   	if player == localPlayer then 
 window = guiCreateWindow(500, 200, 250, 250, "*Tree JoB*", false)
 memo = guiCreateMemo(100, 20, 240, 100, "Unicos RP Tree Job You can make esy money with rhis one# happy happy happy", false, window)
 button = guiCreateButton(20, 150, 100, 100, "Accep", false, window)
 closebutton = guiCreateButton(150, 150, 100, 100, "Close", false, window)
showCursor(true)
      end
end)

 

  • Like 1
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...