damien111 Posted September 27, 2012 Share Posted September 27, 2012 How can i make it so markers are changed for every player when a player enters marker, i also randomly get the error about not matching the boolean or something heres the code, D: Give me events to help with this though, thanks server policeVehicles = { [431]=true } policeSkins = { [261]=true } function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if ( policeVehicles[getElementModel ( source )] ) and ( not policeSkins[getElementModel ( thePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin removePedFromVehicle ( thePlayer ) -- force the player out of the vehicle end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) -- add an event handler for onVehicleEnter function createRobberTeam () busTeam = createTeam ( "Bus Drivers", 6, 183, 248 ) end addEventHandler ( "onResourceStart", resourceRoot, createRobberTeam ) addEvent ( "robberJobAccepted", true ) function givePlayerJob ( ) setPlayerTeam ( source, busTeam ) setElementModel ( source, 261 )x end addEventHandler ( "robberJobAccepted", root, givePlayerJob ) local rootElement = getRootElement() local busses = {[431] = true, [437] = 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 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 busJob(thePlayer) local theVehicle = getPedOccupiedVehicle (thePlayer) local id = getElementModel(theVehicle) if id == 431 or id == 437 then local x, y, z = getNewBusLocation(thePlayer, 1) setElementData(thePlayer,"buszp",0) setElementData(thePlayer,"busData",1) else end end addEventHandler("onVehicleEnter",rootElement,busJob) function busStart(thePlayer) local theVehicle = getPedOccupiedVehicle (thePlayer) local id = getElementModel(theVehicle) if id == 431 or id == 437 then outputChatBox("You start bus job!", thePlayer, 255, 255, 0) end end addEventHandler("onVehicleEnter",rootElement,busStart) 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 local zarp = getElementData(client, "buszp") local money = math.random(10,20) setElementData(client, "buszp", zarp + money) 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) function giveMoney(thePlayer) local theVehicle = getPedOccupiedVehicle (thePlayer) local id = getElementModel(theVehicle) if id == 431 or 437 then local gpm = getElementData(thePlayer, "buszp") if ((gpm) > 0 ) then givePlayerMoney(thePlayer, tonumber(gpm)) outputChatBox("You have earned " .. gpm .. "$", thePlayer, 0, 140, 240) setElementData(thePlayer, "buszp", 0) end end end addEventHandler("onVehicleExit", rootElement, giveMoney) addEventHandler("onPlayerQuit", rootElement, giveMoney) 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, "checkpoint", 4.0, 0, 0, 255, 255) blip = createBlipAttachedTo( marker, 60, 3, 0, 0, 255, 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, 6, 183, 248 ) guiLabelSetHorizontalAlign ( robberLabel, "center", false ) guiSetFont ( robberLabel, "default-bold-small" ) local robberInfoLabel = guiCreateLabel ( 0.0309, 0.2441, 0.944, 0.3077, "If you accept this job, you are able to go on a bus route to make money.", 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 addEventHandler ( "onClientClick", root, detectClickOnPed ) function buttonClick ( button ) if ( button ~= "left" ) then return end if ( source == robberCloseButton ) then guiSetVisible ( robberWindow, false ) showCursor ( false ) elseif ( source == robberAcceptButton ) then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) triggerServerEvent ( "robberJobAccepted", localPlayer ) guiSetVisible ( robberWindow, false ) showCursor ( false ) outputChatBox ( "You are now employed as a Bus Driver!" ) end end addEventHandler ( "onClientGUIClick", resourceRoot, buttonClick ) Link to comment
Castillo Posted September 28, 2012 Share Posted September 28, 2012 What do you mean by "markers changed for every player"? Link to comment
Vanlot Posted September 28, 2012 Share Posted September 28, 2012 What do you mean by "markers changed for every player"? I think that he meant to create new marker if the player hit the previous one. Link to comment
damien111 Posted September 28, 2012 Author Share Posted September 28, 2012 I mean, more than one player cant do the job. :c 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