TAPL Posted November 18, 2013 Share Posted November 18, 2013 Nothing happends when i hit the marker, Also no errors. And only sweepers should see the marker(When they are in the sweeper vehicle) It's just you didn't notice it when the marker get destroyed and recreated because the position in the table are same. You may want to create the marker client side so each sweepers see only his own marker. Link to comment
AlphaMark Posted November 21, 2013 Author Share Posted November 21, 2013 So how whould the scipt look then? Could u make an example? Link to comment
TAPL Posted November 21, 2013 Share Posted November 21, 2013 At server side from line 39 till 67 move it to client side with some modification like changing the event to client side and adding some IF statement for the element data and/or the team and such thing. Link to comment
AlphaMark Posted November 22, 2013 Author Share Posted November 22, 2013 Im trying. I got this atm. local jobMarker = createMarker(10, 10, 3, 'cylinder', 1, 0, 255, 0, 255) local jobBlip = createBlipAttachedTo(jobMarker, 41) local sweeperTeam = createTeam("Sweeper", 255, 0, 0) local joblessTeam = createTeam("Unemployed", 123, 123, 123) function GetSweeperJob(hitElement) if getElementType(hitElement) == "player" then if getElementData(hitElement, "Occupation") ~= "Sweeper" then triggerClientEvent(hitElement, "SweepWindow", hitElement) else outputChatBox("You already are a sweeper!", hitElement, 255, 0, 0) end end end addEventHandler("onMarkerHit", jobMarker, GetSweeperJob) function GiveSweeperJob() setPlayerSkin(source, 264) setPlayerTeam(source, getTeamFromName("Sweeper")) setElementData(source, "Occupation", "Sweeper") setElementData(source, "hasSweepMarker", "no") outputChatBox("You are now a sweeper!", source, 255, 0, 0) end addEvent("GiveSweeperJob", true) addEventHandler("GiveSweeperJob", root, GiveSweeperJob) function resignSweeperJob(thePlayer) if (getElementData(thePlayer, "Occupation") == "Sweeper") then setElementModel(thePlayer, math.random(1,287)) setPlayerTeam(thePlayer, getTeamFromName("Unemployed")) setElementData(thePlayer, "Occupation", "Unemployed") outputChatBox("You resigned as sweeper!", thePlayer, 255, 0, 0) elseif getElementData(thePlayer, "Occupation") == "Unemployed" then outputChatBox("You are already Unemployed!", thePlayer, 255, 0, 0) end end addCommandHandler("resign", resignSweeperJob) function SweepEnter(theVehicle, seat, jacked) local id = getElementModel(theVehicle) if id == 574 then outputChatBox("You are now sweeping!", source, 255, 0, 0) triggerClientEvent("MakeMarker",getRootElement()) end end addEventHandler("onPlayerVehicleEnter", root, SweepEnter) function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end jobWdw = guiCreateWindow(638, 266, 597, 655, "SANGSweeper", false) guiWindowSetSizable(jobWdw, false) takejobBtn = guiCreateButton(378, 131, 190, 78, "Take Job", false, jobWdw) closeBtn = guiCreateButton(378, 524, 190, 78, "Close", false, jobWdw) guiSetVisible(jobWdw, false) function showJobWindow() if (jobWdw ~= nil) then guiSetVisible(jobWdw, true) guiSetInputEnabled(true) showCursor(true) centerWindow(jobWdw) end end addEvent("SweepWindow", true) addEventHandler("SweepWindow", root, showJobWindow) function clickJobWindow(button,state) if (source == takejobBtn) then triggerServerEvent("GiveSweeperJob", localPlayer) guiSetVisible(jobWdw, false) guiSetInputEnabled(false) showCursor(false) elseif (source == closeBtn) then guiSetVisible(jobWdw, false) guiSetInputEnabled(false) showCursor(false) end end addEventHandler("onClientGUIClick", guiRoot, clickJobWindow) local currentIndex = 1 local route = { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 0, 2 }, { 0, 0, 3 }, { 0, 0, 4 } } addEventHandler("onMarkerHit", root, function() if (source == marker) then destroyElement(marker) currentIndex = (currentIndex < #route) and (currentIndex + 1) or 1 marker = createMarker(unpack(route[currentIndex])) end end) function MakeMarker(thePlayer, marker) if (source == marker) then createMarker(unpack(route[currentIndex])) end end addEvent("MakeMarker", true) Link to comment
TAPL Posted November 22, 2013 Share Posted November 22, 2013 Client Side: function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end jobWdw = guiCreateWindow(638, 266, 597, 655, "SANGSweeper", false) guiWindowSetSizable(jobWdw, false) centerWindow(jobWdw) takejobBtn = guiCreateButton(378, 131, 190, 78, "Take Job", false, jobWdw) closeBtn = guiCreateButton(378, 524, 190, 78, "Close", false, jobWdw) guiSetVisible(jobWdw, false) local jobMarker = createMarker(10, 10, 3, "cylinder", 1, 0, 255, 0, 255) local jobBlip = createBlipAttachedTo(jobMarker, 41) function GetSweeperJob(hitElement) if hitElement == localPlayer then if getElementData(hitElement, "Occupation") ~= "Sweeper" then guiSetVisible(jobWdw, true) guiSetInputEnabled(true) showCursor(true) centerWindow(jobWdw) else outputChatBox("You already are a sweeper!", 255, 0, 0) end end end addEventHandler("onClientMarkerHit", jobMarker, GetSweeperJob) function clickJobWindow(button,state) if (source == takejobBtn) then triggerServerEvent("GiveSweeperJob", localPlayer) guiSetVisible(jobWdw, false) guiSetInputEnabled(false) showCursor(false) elseif (source == closeBtn) then guiSetVisible(jobWdw, false) guiSetInputEnabled(false) showCursor(false) end end addEventHandler("onClientGUIClick", guiRoot, clickJobWindow) local route = { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 0, 2 }, { 0, 0, 3 }, { 0, 0, 4 } } function SweepEnter(theVehicle, seat, jacked) local id = getElementModel(theVehicle) if id == 574 then if getElementData(source, "Occupation") == "Sweeper" then outputChatBox("You are now sweeping!", 255, 0, 0) if not marker then currentIndex = ((currentIndex or 0) < #route) and ((currentIndex or 0) + 1) or 1 marker = createMarker(unpack(route[currentIndex])) end else if marker then destroyElement(marker) end end end end addEventHandler("onClientPlayerVehicleEnter", root, SweepEnter) addEventHandler("onClientMarkerHit", root, function(player) if (source == marker) then if player == localPlayer and getElementData(player, "Occupation") == "Sweeper" then local vehicle = getPedOccupiedVehicle(player) if vehicle and getElementModel(vehicle) == 574 then outputChatBox("You hit the marker!", 255, 255, 0) destroyElement(marker) currentIndex = ((currentIndex or 0) < #route) and ((currentIndex or 0) + 1) or 1 marker = createMarker(unpack(route[currentIndex])) end end end end) addEvent("ResignSweeperJob", true) addEventHandler("ResignSweeperJob", root, function() if marker then destroyElement(marker) end end) Server Side: local sweeperTeam = createTeam("Sweeper", 255, 0, 0) local joblessTeam = createTeam("Unemployed", 123, 123, 123) function GiveSweeperJob() setElementModel(source, 264) setPlayerTeam(source, sweeperTeam) setElementData(source, "Occupation", "Sweeper") outputChatBox("You are now a sweeper!", source, 255, 0, 0) end addEvent("GiveSweeperJob", true) addEventHandler("GiveSweeperJob", root, GiveSweeperJob) function resignSweeperJob(player) if (getElementData(player, "Occupation") == "Sweeper") then setElementModel(player, math.random(1,287)) setPlayerTeam(player, joblessTeam) setElementData(player, "Occupation", "Unemployed") triggerClientEvent(player, "ResignSweeperJob",player) outputChatBox("You resigned as sweeper!", player, 255, 0, 0) elseif getElementData(player, "Occupation") == "Unemployed" then outputChatBox("You are already Unemployed!", player, 255, 0, 0) end end addCommandHandler("resign", resignSweeperJob) Link to comment
AlphaMark Posted November 22, 2013 Author Share Posted November 22, 2013 Okay. It wont create an new marker and i want it that the markers dissapear when you exit the vehicle Link to comment
TAPL Posted November 22, 2013 Share Posted November 22, 2013 Okay. It wont create an new marker Repeat again: It's just you didn't notice it when the marker get destroyed and recreated because the position in the table are same. and i want it that the markers dissapear when you exit the vehicle Use event onClientPlayerVehicleExit and destroy the marker. Link to comment
AlphaMark Posted November 22, 2013 Author Share Posted November 22, 2013 Okay so i added this: function SweepExit(theVehicle, seat, jacked) destroyElement(marker) currentIndex = ((currentIndex or 0) < #route) and ((currentIndex or 0) + 1) or 1 end addEventHandler("onClientPlayerVehicleExit", root, SweepExit) But when i enter the Sweeper again it wont create an marker Link to comment
TAPL Posted November 22, 2013 Share Posted November 22, 2013 function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end jobWdw = guiCreateWindow(638, 266, 597, 655, "SANGSweeper", false) guiWindowSetSizable(jobWdw, false) centerWindow(jobWdw) takejobBtn = guiCreateButton(378, 131, 190, 78, "Take Job", false, jobWdw) closeBtn = guiCreateButton(378, 524, 190, 78, "Close", false, jobWdw) guiSetVisible(jobWdw, false) local jobMarker = createMarker(10, 10, 3, "cylinder", 1, 0, 255, 0, 255) local jobBlip = createBlipAttachedTo(jobMarker, 41) function GetSweeperJob(hitElement) if hitElement == localPlayer then if getElementData(hitElement, "Occupation") ~= "Sweeper" then guiSetVisible(jobWdw, true) guiSetInputEnabled(true) showCursor(true) centerWindow(jobWdw) else outputChatBox("You already are a sweeper!", 255, 0, 0) end end end addEventHandler("onClientMarkerHit", jobMarker, GetSweeperJob) function clickJobWindow(button,state) if (source == takejobBtn) then triggerServerEvent("GiveSweeperJob", localPlayer) guiSetVisible(jobWdw, false) guiSetInputEnabled(false) showCursor(false) elseif (source == closeBtn) then guiSetVisible(jobWdw, false) guiSetInputEnabled(false) showCursor(false) end end addEventHandler("onClientGUIClick", guiRoot, clickJobWindow) local route = { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 0, 2 }, { 0, 0, 3 }, { 0, 0, 4 } } function SweepEnter(theVehicle, seat, jacked) local id = getElementModel(theVehicle) if id == 574 then if getElementData(source, "Occupation") == "Sweeper" then outputChatBox("You are now sweeping!", 255, 0, 0) if not isElement(marker) then currentIndex = ((currentIndex or 0) < #route) and ((currentIndex or 0) + 1) or 1 marker = createMarker(unpack(route[currentIndex])) end else if isElement(marker) then destroyElement(marker) end end end end addEventHandler("onClientPlayerVehicleEnter", localPlayer, SweepEnter) function SweepExit(theVehicle, seat, jacked) local id = getElementModel(theVehicle) if id == 574 and isElement(marker) then destroyElement(marker) end end addEventHandler("onClientPlayerVehicleExit", localPlayer, SweepExit) addEventHandler("onClientMarkerHit", root, function(player) if (source == marker) then if player == localPlayer and getElementData(player, "Occupation") == "Sweeper" then local vehicle = getPedOccupiedVehicle(player) if vehicle and getElementModel(vehicle) == 574 then outputChatBox("You hit the marker!", 255, 255, 0) destroyElement(marker) currentIndex = ((currentIndex or 0) < #route) and ((currentIndex or 0) + 1) or 1 marker = createMarker(unpack(route[currentIndex])) end end end end) addEvent("ResignSweeperJob", true) addEventHandler("ResignSweeperJob", root, function() if isElement(marker) then destroyElement(marker) end end) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now