K4stic Posted February 22, 2013 Share Posted February 22, 2013 (edited) The Problem is: Then i hit 'electritionPoleMarker' is nothing do i mean(no timer no froze just nothing) and no error's in debugscript 3 function createPoleMarkerAndBlip() if getElementData(source, "Occupation") == "Electrician" then local x, y, z = unpackPoles() electritionPoleMarker = createMarker(x, y, z, "cylinder", 3, 200, 200, 0, 85, localPlayer) setElementData(electritionPoleMarker, "Electrician", "poleMarker", true) electritonPoleBlip = createBlip(x, y, z, 19) end end addEvent("electrition:createPoles", true) addEventHandler("electrition:createPoles", root, createPoleMarkerAndBlip) addEventHandler("onClientPlayerJoin", root, createPoleMarkerAndBlip) addEventHandler("onClientResourceStart", root, createPoleMarkerAndBlip) addEventHandler("onClientMarkerHit", electritionPoleMarker, function(player) if isPlayerInVehicle ( player ) or ( doesPlayerHaveJetPack ( player ) ) then outputChatBox("Get out of the vehicle, to fix the pole.", 255, 0, 0) return end if source == electritionPoleMarker and player == localPlayer and getElementData(player, "Occupation") == "Electrician" then setElementFrozen(localPlayer, true) showCursor(true) guiSetVisible(jobs_electitian_label_timeLeft, true) triggerServerEvent("electrain:fixPole:animation", localPlayer) guiSetText(jobs_electitian_label_timeLeft, "Time Left: 6") setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 5") end, 1000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 4") end, 2000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 3") end, 3000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 2") end, 4000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 1") end, 5000, 1) startTimerWhenMarkerHit = setTimer(function() destroyElement(electritonPoleBlip) destroyElement(electritionPoleMarker) triggerEvent("electrition:createPoles", localPlayer) triggerServerEvent("electrition:fixPole", localPlayer) showCursor(false, false) setElementFrozen(localPlayer, false) guiSetVisible(jobs_electitian_label_timeLeft, false) end, 6000, 1) end end ) Edited March 2, 2013 by Guest Link to comment
Castillo Posted February 22, 2013 Share Posted February 22, 2013 Have you tried debugging your script to find out where the problem is? Link to comment
K4stic Posted February 23, 2013 Author Share Posted February 23, 2013 what you mean? i have 10 times tryed but no result so i post it here Link to comment
Castillo Posted February 23, 2013 Share Posted February 23, 2013 Do you know what debug is? Link to comment
K4stic Posted February 24, 2013 Author Share Posted February 24, 2013 i think is then player marker hit Link to comment
waqaarali Posted February 25, 2013 Share Posted February 25, 2013 in game do /debugscript 3 Link to comment
K4stic Posted February 25, 2013 Author Share Posted February 25, 2013 The Problem is: Then i hit 'electritionPoleMarker' is nothing do i mean(no timer no froze just nothing) and no error's in debugscript 3 Link to comment
albers14 Posted February 25, 2013 Share Posted February 25, 2013 With debug he means using outputChatBox at all if functions to check if they pass through the restriction. Link to comment
Jaysds1 Posted February 25, 2013 Share Posted February 25, 2013 try this: function createPoleMarkerAndBlip() if getElementData(source, "Occupation") != "Electrician" then return end local x, y, z = unpackPoles() electritionPoleMarker = createMarker(x, y, z, "cylinder", 3, 200, 200, 0, 85, localPlayer) setElementData(electritionPoleMarker, "Electrician", "poleMarker", true) electritonPoleBlip = createBlip(x, y, z, 19) end addEvent("electrition:createPoles", true) addEventHandler("electrition:createPoles", root, createPoleMarkerAndBlip) addEventHandler("onClientPlayerJoin", root, createPoleMarkerAndBlip) addEventHandler("onClientResourceStart", root, createPoleMarkerAndBlip) addEventHandler("onClientMarkerHit", electritionPoleMarker, function(player) if getElementType(player) != "player" or doesPedHaveJetPack( player ) ) then --check if the element is not a player or if the player has an jetpack (BTW, doesPlayerHaveJetPack is not used anymore!) outputChatBox("Get out of the vehicle, to fix the pole.", 255, 0, 0) return end if player == localPlayer and getElementData(player, "Occupation") == "Electrician" then setElementFrozen(player, true) showCursor(true) guiSetVisible(jobs_electitian_label_timeLeft, true) triggerServerEvent("electrain:fixPole:animation", localPlayer) guiSetText(jobs_electitian_label_timeLeft, "Time Left: 6") local timer = 5 setTimer(function() --shortened the code timer = timer - 1 if timer==5 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 5") end if timer==4 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 4") end if timer==3 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 3") end if timer==2 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 2") end if timer==1 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 1") end end, 1000, 5) startTimerWhenMarkerHit = setTimer(function() timer = null --unset the var timer destroyElement(electritonPoleBlip) destroyElement(electritionPoleMarker) triggerEvent("electrition:createPoles", player) triggerServerEvent("electrition:fixPole", player) showCursor(false, false) setElementFrozen(player, false) guiSetVisible(jobs_electitian_label_timeLeft, false) end, 6000, 1) end end) Link to comment
K4stic Posted February 26, 2013 Author Share Posted February 26, 2013 not work and i have remove the ! at lines 2 and 14 and i remove the ) at line 14 because is output me errors Link to comment
codeluaeveryday Posted February 26, 2013 Share Posted February 26, 2013 Errors: #1 ) unpackPoles() at Line 3 is undefined #2 ) In the createPoleMarkerAndBlip() function, you are using source, this will work for everything but the onClientResourceStart, since the source of the event is the started element... #3 ) localPlayer is being used at line 4 instead of using source, also this will cause a relevant problem with #2 if you don't fix problem #2. #4 ) The arguments you passed in onClientMarkerHit are wrong, you just have player, you need player and dimension. There will be a few more bugs after this for you to figure out. Try new code, make sure you define unpackPoles(): function createPoleMarkerAndBlip() if getElementData(source, "Occupation") == "Electrician" and getElementType(source) == 'player' then local x, y, z = unpackPoles() electritionPoleMarker = createMarker(x, y, z, "cylinder", 3, 200, 200, 0, 85, source) setElementData(electritionPoleMarker, "Electrician", "poleMarker", true) electritonPoleBlip = createBlip(x, y, z, 19) elseif getElementType(source) ~= 'player' then local x, y, z = unpackPoles() -- You need to DEFINE this... electritionPoleMarker = createMarker(x, y, z, "cylinder", 3, 200, 200, 0, 85, localPlayer) setElementData(electritionPoleMarker, "Electrician", "poleMarker", true) electritonPoleBlip = createBlip(x, y, z, 19) end end addEvent("electrition:createPoles", true) addEventHandler("electrition:createPoles", root, createPoleMarkerAndBlip) addEventHandler("onClientPlayerJoin", root, createPoleMarkerAndBlip) addEventHandler("onClientResourceStart", root, createPoleMarkerAndBlip) addEventHandler("onClientMarkerHit", electritionPoleMarker, function(player, dimension) if isPlayerInVehicle ( player ) or ( doesPlayerHaveJetPack ( player ) ) then outputChatBox("Get out of the vehicle, to fix the pole.", 255, 0, 0) return end if source == electritionPoleMarker and player == localPlayer and getElementData(player, "Occupation") == "Electrician" then setElementFrozen(localPlayer, true) showCursor(true) guiSetVisible(jobs_electitian_label_timeLeft, true) triggerServerEvent("electrain:fixPole:animation", localPlayer) guiSetText(jobs_electitian_label_timeLeft, "Time Left: 6") setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 5") end, 1000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 4") end, 2000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 3") end, 3000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 2") end, 4000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 1") end, 5000, 1) startTimerWhenMarkerHit = setTimer(function() destroyElement(electritonPoleBlip) destroyElement(electritionPoleMarker) triggerEvent("electrition:createPoles", localPlayer) triggerServerEvent("electrition:fixPole", localPlayer) showCursor(false, false) setElementFrozen(localPlayer, false) guiSetVisible(jobs_electitian_label_timeLeft, false) end, 6000, 1) end end ) Link to comment
K4stic Posted February 27, 2013 Author Share Posted February 27, 2013 NOT Work So take full code: polesToFix = { {1332.9365234375, -1411.30078125, 12}, {1470.1435546875, -1447.119140625, 12}, {1515.50390625, -1586.787109375, 12}, {1544.9814453125, -1726.63671875, 12}, {1460.6865234375, -1420.0810546875, 12}, {1863.583984375, -1255.1982421875, 12}, {2061.3095703125, -1289.392578125, 22.5}, {1862.3125, -1455.162109375, 12.2} } function unpackPoles() return unpack(polesToFix[math.random(#polesToFix)]) end local markerjob = createMarker( 733.13671875, -1347.9580078125, 13.510824203491, "Cylinder", 1.5, 0, 0, 255, 150) local skins = {"Electrician (skin: 16)"} windowjob = guiCreateWindow(0.700,0.28,0.2800,0.4500,"Electrician job",true) guiSetVisible(windowjob, false) infomemo = guiCreateMemo(0.0347,0.0600,0.9369,0.4100,"As an electrician, you will go around the city of Los Santos, to the red flag, and fix the poles.",true,windowjob) skinsgrid = guiCreateGridList(0.0347,0.5300,0.9369,0.350,true,windowjob) guiGridListSetSelectionMode(skinsgrid,2) _skins = guiGridListAddColumn(skinsgrid,"Skins",0.95) takebtn = guiCreateButton(0.1000,0.9000,0.3000,0.0700,"Accept",true,windowjob) closebtn = guiCreateButton(0.6000,0.9000,0.3000,0.0700,"Cancel",true,windowjob) infolbl = guiCreateLabel(0.2681,0.4800,0.4637,0.0538,"Choose your skin :",true,windowjob) guiLabelSetColor(infolbl,255,255,255) guiLabelSetVerticalAlign(infolbl,"center") guiLabelSetHorizontalAlign(infolbl,"center",false) guiSetFont(infolbl,"default-bold-small") local resX, resY = guiGetScreenSize() local width2, height2 = 1269, 75 local X2 = resX / 2 - width2 / 2 local Y2 = resY / 2 - height2 / 2 jobs_electitian_label_timeLeft = guiCreateLabel(X2, Y2, width2, height2, "Time until finished: ", false) guiSetPosition(jobs_electitian_label_timeLeft, 10, 10, false) guiSetVisible(jobs_electitian_label_timeLeft, false) guiSetFont(jobs_electitian_label_timeLeft, "sa-header") guiLabelSetColor(jobs_electitian_label_timeLeft, 5, 221, 35) guiLabelSetHorizontalAlign(jobs_electitian_label_timeLeft, "center", false) guiLabelSetVerticalAlign(jobs_electitian_label_timeLeft, "center") for index, skin in ipairs(skins) do local row = guiGridListAddRow (skinsgrid) guiGridListSetItemText(skinsgrid, row, _skins, tostring(skin), false, false) end addEventHandler("onClientGUIClick", root, function () if (source == takebtn) then local row,col = guiGridListGetSelectedItem(skinsgrid) if (row and col and row ~= -1 and col ~= -1) then local skinName = guiGridListGetItemText(skinsgrid, row, 1) if skinName == "Electrician (skin: 16)" then triggerServerEvent("electrition:takeJob",localPlayer, 16) end guiSetVisible ( windowjob, false ) showCursor ( false ) else outputChatBox("Please,select a skin of the list.",255,0,0) end elseif (source == closebtn) then guiSetVisible ( windowjob, false ) showCursor ( false ) end end) function Elecjob(hitElement) if (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", markerjob, Elecjob) function Elecjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", markerjob, Elecjobleave) function removeElecWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", closebtn , removeElecWindow, false) function createPoleMarkerAndBlip() if getElementData(source, "Occupation") == "Electrician" and getElementType(source) == 'player' then local x, y, z = unpackPoles() electritionPoleMarker = createMarker(x, y, z, "cylinder", 3, 200, 200, 0, 85, source) setElementData(electritionPoleMarker, "Electrician", "poleMarker", true) electritonPoleBlip = createBlip(x, y, z, 19) end end addEvent("electrition:createPoles", true) addEventHandler("electrition:createPoles", root, createPoleMarkerAndBlip) addEventHandler("onClientPlayerJoin", root, createPoleMarkerAndBlip) addEventHandler("onClientResourceStart", root, createPoleMarkerAndBlip) addEventHandler("onClientMarkerHit", electritionPoleMarker, function(player, dimension) if isPlayerInVehicle ( player ) or ( doesPlayerHaveJetPack ( player ) ) then outputChatBox("Get out of the vehicle, to fix the pole.", 255, 0, 0) return end if source == electritionPoleMarker and player == localPlayer and getElementData(player, "Occupation") == "Electrician" then setElementFrozen(localPlayer, true) showCursor(true) guiSetVisible(jobs_electitian_label_timeLeft, true) triggerServerEvent("electrain:fixPole:animation", localPlayer) guiSetText(jobs_electitian_label_timeLeft, "Time Left: 20") setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 19") end, 1000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 18") end, 2000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 17") end, 3000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 16") end, 4000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 15") end, 5000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 14") end, 6000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 13") end, 7000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 12") end, 8000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 11") end, 9000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 10") end, 10000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 9") end, 11000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 8") end, 12000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 7") end, 13000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 6") end, 14000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 5") end, 15000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 4") end, 16000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 3") end, 17000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 2") end, 18000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 1") end, 19000, 1) startTimerWhenMarkerHit = setTimer(function() destroyElement(electritonPoleBlip) destroyElement(electritionPoleMarker) triggerEvent("electrition:createPoles", localPlayer) triggerServerEvent("electrition:fixPole", localPlayer) showCursor(false, false) setElementFrozen(localPlayer, false) guiSetVisible(jobs_electitian_label_timeLeft, false) end, 20000, 1) end end ) Link to comment
codeluaeveryday Posted February 27, 2013 Share Posted February 27, 2013 Try this: polesToFix = { {1332.9365234375, -1411.30078125, 12}, {1470.1435546875, -1447.119140625, 12}, {1515.50390625, -1586.787109375, 12}, {1544.9814453125, -1726.63671875, 12}, {1460.6865234375, -1420.0810546875, 12}, {1863.583984375, -1255.1982421875, 12}, {2061.3095703125, -1289.392578125, 22.5}, {1862.3125, -1455.162109375, 12.2} } local markerjob = createMarker( 733.13671875, -1347.9580078125, 13.510824203491, "Cylinder", 1.5, 0, 0, 255, 150) local skins = {"Electrician (skin: 16)"} windowjob = guiCreateWindow(0.700,0.28,0.2800,0.4500,"Electrician job",true) guiSetVisible(windowjob, false) infomemo = guiCreateMemo(0.0347,0.0600,0.9369,0.4100,"As an electrician, you will go around the city of Los Santos, to the red flag, and fix the poles.",true,windowjob) skinsgrid = guiCreateGridList(0.0347,0.5300,0.9369,0.350,true,windowjob) guiGridListSetSelectionMode(skinsgrid,2) _skins = guiGridListAddColumn(skinsgrid,"Skins",0.95) takebtn = guiCreateButton(0.1000,0.9000,0.3000,0.0700,"Accept",true,windowjob) closebtn = guiCreateButton(0.6000,0.9000,0.3000,0.0700,"Cancel",true,windowjob) infolbl = guiCreateLabel(0.2681,0.4800,0.4637,0.0538,"Choose your skin :",true,windowjob) guiLabelSetColor(infolbl,255,255,255) guiLabelSetVerticalAlign(infolbl,"center") guiLabelSetHorizontalAlign(infolbl,"center",false) guiSetFont(infolbl,"default-bold-small") local resX, resY = guiGetScreenSize() local width2, height2 = 1269, 75 local X2 = resX / 2 - width2 / 2 local Y2 = resY / 2 - height2 / 2 jobs_electitian_label_timeLeft = guiCreateLabel(X2, Y2, width2, height2, "Time until finished: ", false) guiSetPosition(jobs_electitian_label_timeLeft, 10, 10, false) guiSetVisible(jobs_electitian_label_timeLeft, false) guiSetFont(jobs_electitian_label_timeLeft, "sa-header") guiLabelSetColor(jobs_electitian_label_timeLeft, 5, 221, 35) guiLabelSetHorizontalAlign(jobs_electitian_label_timeLeft, "center", false) guiLabelSetVerticalAlign(jobs_electitian_label_timeLeft, "center") for index, skin in ipairs(skins) do local row = guiGridListAddRow (skinsgrid) guiGridListSetItemText(skinsgrid, row, _skins, tostring(skin), false, false) end addEventHandler("onClientGUIClick", root, function () if (source == takebtn) then local row,col = guiGridListGetSelectedItem(skinsgrid) if (row and col and row ~= -1 and col ~= -1) then local skinName = guiGridListGetItemText(skinsgrid, row, 1) if skinName == "Electrician (skin: 16)" then triggerServerEvent("electrition:takeJob",localPlayer, 16) end guiSetVisible ( windowjob, false ) showCursor ( false ) else outputChatBox("Please,select a skin of the list.",255,0,0) end elseif (source == closebtn) then guiSetVisible ( windowjob, false ) showCursor ( false ) end end) function Elecjob(hitElement, dimension) if (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", markerjob, Elecjob) function Elecjobleave(leaveElement, dimension) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", markerjob, Elecjobleave) function removeElecWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", closebtn , removeElecWindow, false) function createPoleMarkerAndBlip() if getElementType(source) ~= 'player' then if getElementData(localPlayer, "Occupation") == "Electrician" and getElementType(localPlayer) == 'player' then part = math.random(1, #polesToFix) x = polesToFix[part] y = polesToFix[part] z = polesToFix[part] electritionPoleMarker = createMarker(x, y, z, "cylinder", 3, 200, 200, 0, 85, localPlayer) setElementData(electritionPoleMarker, "Electrician", "poleMarker", true) electritonPoleBlip = createBlip(x, y, z, 19) end end if getElementData(source, "Occupation") == "Electrician" and getElementType(source) == 'player' then part = math.random(1, #polesToFix) x = polesToFix[part] y = polesToFix[part] z = polesToFix[part] electritionPoleMarker = createMarker(x, y, z, "cylinder", 3, 200, 200, 0, 85, source) setElementData(electritionPoleMarker, "Electrician", "poleMarker", true) electritonPoleBlip = createBlip(x, y, z, 19) end end addEvent("electrition:createPoles", true) addEventHandler("electrition:createPoles", root, createPoleMarkerAndBlip) addEventHandler("onClientPlayerJoin", root, createPoleMarkerAndBlip) addEventHandler("onClientResourceStart", root, createPoleMarkerAndBlip) addEventHandler("onClientMarkerHit", electritionPoleMarker, function(player, dimension) if isPlayerInVehicle ( player ) or ( doesPlayerHaveJetPack ( player ) ) then outputChatBox("Get out of the vehicle, to fix the pole.", 255, 0, 0) return end if source == electritionPoleMarker and player == localPlayer and getElementData(player, "Occupation") == "Electrician" then setElementFrozen(localPlayer, true) showCursor(true) guiSetVisible(jobs_electitian_label_timeLeft, true) triggerServerEvent("electrain:fixPole:animation", localPlayer) guiSetText(jobs_electitian_label_timeLeft, "Time Left: 20") setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 19") end, 1000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 18") end, 2000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 17") end, 3000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 16") end, 4000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 15") end, 5000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 14") end, 6000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 13") end, 7000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 12") end, 8000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 11") end, 9000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 10") end, 10000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 9") end, 11000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 8") end, 12000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 7") end, 13000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 6") end, 14000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 5") end, 15000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 4") end, 16000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 3") end, 17000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 2") end, 18000, 1) setTimer(function() guiSetText(jobs_electitian_label_timeLeft, "Time Left: 1") end, 19000, 1) startTimerWhenMarkerHit = setTimer(function() destroyElement(electritonPoleBlip) destroyElement(electritionPoleMarker) triggerEvent("electrition:createPoles", localPlayer) triggerServerEvent("electrition:fixPole", localPlayer) showCursor(false, false) setElementFrozen(localPlayer, false) guiSetVisible(jobs_electitian_label_timeLeft, false) end, 20000, 1) end end ) Let me know if there are errors. Link to comment
K4stic Posted February 27, 2013 Author Share Posted February 27, 2013 Not Create blips and no error's in debugscript Link to comment
Jaysds1 Posted February 27, 2013 Share Posted February 27, 2013 I really think you don't need 'onClientResourceStart' in it. Anyway, try this: polesToFix = { {1332.9365234375, -1411.30078125, 12}, {1470.1435546875, -1447.119140625, 12}, {1515.50390625, -1586.787109375, 12}, {1544.9814453125, -1726.63671875, 12}, {1460.6865234375, -1420.0810546875, 12}, {1863.583984375, -1255.1982421875, 12}, {2061.3095703125, -1289.392578125, 22.5}, {1862.3125, -1455.162109375, 12.2} } local markerjob = createMarker( 733.13671875, -1347.9580078125, 13.510824203491, "Cylinder", 1.5, 0, 0, 255, 150) local skins = {"Electrician (skin: 16)"} windowjob = guiCreateWindow(0.700,0.28,0.2800,0.4500,"Electrician job",true) guiSetVisible(windowjob, false) infomemo = guiCreateMemo(0.0347,0.0600,0.9369,0.4100,"As an electrician, you will go around the city of Los Santos, to the red flag, and fix the poles.",true,windowjob) skinsgrid = guiCreateGridList(0.0347,0.5300,0.9369,0.350,true,windowjob) guiGridListSetSelectionMode(skinsgrid,2) _skins = guiGridListAddColumn(skinsgrid,"Skins",0.95) takebtn = guiCreateButton(0.1000,0.9000,0.3000,0.0700,"Accept",true,windowjob) closebtn = guiCreateButton(0.6000,0.9000,0.3000,0.0700,"Cancel",true,windowjob) infolbl = guiCreateLabel(0.2681,0.4800,0.4637,0.0538,"Choose your skin :",true,windowjob) guiLabelSetColor(infolbl,255,255,255) guiLabelSetVerticalAlign(infolbl,"center") guiLabelSetHorizontalAlign(infolbl,"center",false) guiSetFont(infolbl,"default-bold-small") local resX, resY = guiGetScreenSize() local width2, height2 = 1269, 75 local X2 = resX / 2 - width2 / 2 local Y2 = resY / 2 - height2 / 2 jobs_electitian_label_timeLeft = guiCreateLabel(X2, Y2, width2, height2, "Time until finished: ", false) guiSetPosition(jobs_electitian_label_timeLeft, 10, 10, false) guiSetVisible(jobs_electitian_label_timeLeft, false) guiSetFont(jobs_electitian_label_timeLeft, "sa-header") guiLabelSetColor(jobs_electitian_label_timeLeft, 5, 221, 35) guiLabelSetHorizontalAlign(jobs_electitian_label_timeLeft, "center", false) guiLabelSetVerticalAlign(jobs_electitian_label_timeLeft, "center") for index, skin in ipairs(skins) do local row = guiGridListAddRow (skinsgrid) guiGridListSetItemText(skinsgrid, row, _skins, tostring(skin), false, false) end addEventHandler("onClientGUIClick", root, function () if (source == takebtn) then local row,col = guiGridListGetSelectedItem(skinsgrid) if (row and col and row ~= -1 and col ~= -1) then local skinName = guiGridListGetItemText(skinsgrid, row, 1) if skinName == "Electrician (skin: 16)" then triggerServerEvent("electrition:takeJob",localPlayer, 16) end guiSetVisible ( windowjob, false ) showCursor ( false ) else outputChatBox("Please,select a skin of the list.",255,0,0) end elseif (source == closebtn) then guiSetVisible ( windowjob, false ) showCursor ( false ) end end) function Elecjob(hitElement, dimension) if (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", markerjob, Elecjob) function Elecjobleave(leaveElement, dimension) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", markerjob, Elecjobleave) function removeElecWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", closebtn , removeElecWindow, false) function createPoleMarkerAndBlip() if eventName == "onClientResourceStart" then source = localPlayer end --this will change source to localPlayer if it's the onClientResourceStart event if getElementData(source, "Occupation") == "Electrician" and getElementType(source) == 'player' then part = math.random(1, #polesToFix) x = polesToFix[part] y = polesToFix[part] z = polesToFix[part] electritionPoleMarker = createMarker(x, y, z, "cylinder", 3, 200, 200, 0, 85, source) setElementData(electritionPoleMarker, "Electrician", "poleMarker", true) electritonPoleBlip = createBlip(x, y, z, 19) end end addEvent("electrition:createPoles", true) addEventHandler("electrition:createPoles", root, createPoleMarkerAndBlip) addEventHandler("onClientPlayerJoin", root, createPoleMarkerAndBlip) addEventHandler("onClientResourceStart", resourceRoot, createPoleMarkerAndBlip) addEventHandler("onClientMarkerHit", electritionPoleMarker, function(player) if getElementType(player) ~= "player" or doesPedHaveJetPack( player ) then --check if the element is not a player or if the player has an jetpack (BTW, doesPlayerHaveJetPack is not used anymore!) outputChatBox("Get out of the vehicle, to fix the pole.", 255, 0, 0) return end if player == localPlayer and getElementData(player, "Occupation") == "Electrician" then setElementFrozen(player, true) showCursor(true) guiSetVisible(jobs_electitian_label_timeLeft, true) triggerServerEvent("electrain:fixPole:animation", player) guiSetText(jobs_electitian_label_timeLeft, "Time Left: 6") local timer = 5 setTimer(function() --shortened the code timer = timer - 1 if timer==5 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 5") end if timer==4 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 4") end if timer==3 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 3") end if timer==2 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 2") end if timer==1 then guiSetText(jobs_electitian_label_timeLeft, "Time Left: 1") end end, 1000, 5) startTimerWhenMarkerHit = setTimer(function() timer = null --unset the var timer destroyElement(electritonPoleBlip) destroyElement(electritionPoleMarker) triggerEvent("electrition:createPoles", player) triggerServerEvent("electrition:fixPole", player) showCursor(false, false) setElementFrozen(player, false) guiSetVisible(jobs_electitian_label_timeLeft, false) end, 6000, 1,player,timer) end end) Link to comment
K4stic Posted February 27, 2013 Author Share Posted February 27, 2013 not work not visible blips or markers to hit Link to comment
Jaysds1 Posted February 27, 2013 Share Posted February 27, 2013 ok, You wanna know why it doesn't work? It's because your trying to get element data's that are destroyed when you leave the server, I would recommend you to use accounts instead. Link to comment
K4stic Posted February 27, 2013 Author Share Posted February 27, 2013 then player take that job it must set element's so must work but then i hit the marker nothing 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