damien111 Posted September 26, 2012 Share Posted September 26, 2012 The route system doesnt work past the first marker. client local client = getLocalPlayer( ) local rootElement = getRootElement() local marker = nil local blip = nil addEvent("bus_set_location",true) addEventHandler("bus_set_location",rootElement, function (x, y, z) marker = createMarker(tostring(x), tostring(y), tostring(z)-1, "cylinder", 3.5, 255, 255, 0, 170) blip = createBlipAttachedTo( marker, 0, 2, 255, 255, 0, 255 ) addEventHandler("onClientMarkerHit",marker,onBusStopHit) end) function onBusStopHit(hitPlayer) if not hitPlayer == client then return end triggerServerEvent("bus_finish",client,client) if isElement(blip) then destroyElement(blip) end if isElement(marker) then removeEventHandler("onClientMarkerHit",marker,onBusStopHit) destroyElement(marker) end end addEventHandler("onClientVehicleExit",rootElement, function () if isElement(marker) then removeEventHandler("onClientMarkerHit",marker,onBusStopHit) destroyElement(marker) end if isElement(blip) then destroyElement(blip) end end) function resourceBootUp () ourPed = createPed ( 261, 1078.9228515625, 1411.5380859375, 5.8203125 ) ourBlip = createBlipAttachedTo ( ourPed, 41 ) setBlipVisibleDistance ( ourBlip, 300 ) setElementFrozen ( ourPed, true ) setElementRotation ( ourPed, 0, 0, 0 ) setElementInterior ( ourPed, 0 ) setElementDimension ( ourPed, 0 ) end addEventHandler ( "onClientResourceStart", resourceRoot, resourceBootUp ) local robberWindow = guiCreateWindow ( 0.314, 0.2513, 0.3809, 0.3893, "Bus Driver Job GUI", true ) local robberLabel = guiCreateLabel ( 0.0193, 0.0736, 0.9903, 0.1104, "Bus Driver Job.", true, robberWindow ) guiLabelSetColor ( robberLabel, 255, 0, 0 ) guiLabelSetHorizontalAlign ( robberLabel, "center", false ) guiSetFont ( robberLabel, "default-bold-small" ) local robberInfoLabel = guiCreateLabel ( 0.0309, 0.2441, 0.944, 0.3077, "Yu will have to drive marker to marker on the bus route to make money as this job.", true, robberWindow ) local robberAcceptButton = guiCreateButton ( 0.3533 ,0.7993, 0.1409, 0.1204, "Accept", true, robberWindow ) local robberCloseButton = guiCreateButton ( 0.5309, 0.7993, 0.1409, 0.1204, "Close", true, robberWindow ) guiSetVisible ( robberWindow, false ) function detectClickOnPed ( button, state, absX, absY, wx, wy, wz, element ) if ( element and element == ourPed and not isPedInVehicle ( localPlayer ) ) then local x, y, z = getElementPosition ( localPlayer ) if ( getDistanceBetweenPoints3D ( x, y, z, wx, wy, wz ) <= 3 ) then guiSetVisible ( robberWindow, true ) end end end function buttonClick ( button ) if ( button ~= "left" ) then return end if ( source == robberCloseButton ) then guiSetVisible ( robberWindow, false ) showCursor ( false ) elseif ( source == robberAcceptButton ) then triggerServerEvent ( "robberJobAccepted", localPlayer ) guiSetVisible ( robberWindow, false ) showCursor ( false ) outputChatBox ( "You are now employed as a Bus Driver!" ) end end addEventHandler ( "onClientGUIClick", resourceRoot, buttonClick ) addEventHandler ( "onClientClick", root, detectClickOnPed ) server local rootElement = getRootElement() local busses = {[431] = true } local busTable = { [1]={ 1042.3076171875, 1375.7373046875, 13.344779968262}, [2]={ 1084.0654296875, 1196.6591796875, 11.39603805542}, [3]={ 1324.9248046875, 1191.2177734375, 13.263603210449}, [4]={ 1604.5009765625, 1129.4189453125, 11.673355102539}, [5]={ 2012.2724609375, 955.734375, 10.785877227783}, [6]={ 2292.7021484375, 743.140625, 10.735727310181}, [7]={ 2665.10546875, 770.3203125, 12.419276237488}, [8]={ 2310.0361328125, 635.3916015625, 12.132932662964 }, [9]={ 2113.9609375, 675.4580078125, 12.021522521973}, [10]={ 1974.857421875, 631.505859375, 11.72947883606}, [11]={ 2112.8583984375, 753.2626953125, 15.1450128555}, [12]={ 2149.232421875, 957.4287109375, 12.598885536194}, [13]={ 2112.8583984375, 753.2626953125, 15.1450128555}, [14]={ 2607.4951171875, 1162.19921875, 14.605998039246}, [15]={ 2546.90234375, 970.396484375, 15.859393119812}, [16]={ 2429.2587890625, 1583.8203125, 14.359293937683}, [17]={ 2429.2587890625, 1583.8203125, 14.359293937683}, [18]={ 2510.798828125, 1848.0126953125, 12.436297416687}, [19]={ 2446.478515625, 2057.087890625, 1.638541221619}, [20]={ 2267.6416015625, 2416.685546875, 12.042870521545}, [21]={ 2363.0966796875, 2715.0849609375, 13.728246688843}, [22]={ 1926.2080078125, 2744.171875, 12.924875259399}, [23]={ 1447.4912109375, 2718.201171875, 12.831276893616}, [24]={ 1525.626953125, 2390.216796875, 13.046078681946}, [25]={ 1890.8935546875, 2176.982421875, 12.568361282349}, [26]={ 2150.294921875, 1993.9716796875, 13.992697715759}, [27]={ 2607.4951171875, 1162.19921875, 14.605998039246}, [28]={ 1727.5556640625, 1372.2890625, 14.906467437744}, [29]={ 1522.5419921875, 1876.37890625, 12.484322547913}, [30]={ 1336.0322265625, 2055.130859375, 12.992102622986}, [31]={ 1077.712890625, 2055.443359375, 16.641700744629}, [32]={ 1010.5498046875, 2307.3671875, 13.428218841553}, [33]={ 903.7802734375, 2350.5205078125, 15.844319343567}, [34]={ 903.83984375, 1980.5625, 12.889327049255}, [35]={ 1010.5498046875, 2307.3671875, 13.428218841553} } function createRobberTeam () robberTeam = createTeam ( "Bus Drivers", 250, 250, 0 ) end addEventHandler ( "onResourceStart", resourceRoot, createRobberTeam ) addEvent ( "robberJobAccepted", true ) function givePlayerJob ( ) setPlayerTeam ( source, robberTeam ) setElementModel ( source, 261 ) end addEventHandler ( "robberJobAccepted", root, givePlayerJob ) function getNewBusLocation(thePlayer, ID) local x, y, z = busTable[ID][1], busTable[ID][2], busTable[ID][3] triggerClientEvent(thePlayer,"bus_set_location",thePlayer,x,y,z) end function onVehicleEnter(thePlayer) if not busses[getElementModel(source)] then return end if not getPlayerTeam(thePlayer) then return end if getTeamName(getPlayerTeam(thePlayer)) == "Bus Drivers" then local x, y, z = getNewBusLocation(thePlayer, 1) setElementData(thePlayer,"busData",1) end end addEventHandler("onVehicleEnter",rootElement,onVehicleEnter) addEvent("bus_finish",true) addEventHandler("bus_finish",rootElement, function (client) if not isPedInVehicle(client) then return end if not busses[getElementModel(getPedOccupiedVehicle(client))] then return end givePlayerMoney(client, 100) if #busTable == tonumber(getElementData(client,"busData")) then setElementData(client,"busData",1) else setElementData(client,"busData",tonumber(getElementData(client,"busData"))+1) end getNewBusLocation(client, tonumber(getElementData(client,"busData"))) end) Link to comment
Castillo Posted September 26, 2012 Share Posted September 26, 2012 What you are saying is that it doesn't do anything when you hit the marker? Link to comment
Castillo Posted September 26, 2012 Share Posted September 26, 2012 I just tried the script, works fine, I hit the first marker, it created second, and so on. 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