Jump to content

Help upon here


Baseplate

Recommended Posts

Well, I took Will's bus job and edited it a bit but when I get in a veh, any veh the blip and the marker shows up, here's my script

server:

local rootElement = getRootElement() 
local busses = {[431] = true, [437] = true} 
  
local busTable = { 
[1]={1812.65198, -1889.86047, 13.41406}, 
[2]={1825.22791, -1635.03711, 13.38281}, 
[3]={1855.01685, -1430.47449, 13.39063}, 
[4]={1732.81580, -1296.87122, 13.44294}, 
[5]={1473.19226, -1295.77124, 13.48315}, 
[6]={1443.60376, -1498.26660, 13.37650}, 
[7]={1426.37280, -1716.12439, 13.38281}, 
[8]={1315.06909, -1656.43799, 13.38281}, 
[9]={1359.06250, -1432.39734, 13.38281}, 
[10]={1169.82983, -1392.34473, 13.41728}, 
[11]={930.76508, -1392.92627, 13.26561}, 
[12]={815.24756, -1317.91345, 13.44460}, 
[13]={585.04199, -1320.53748, 13.40609}, 
[14]={526.99365, -1624.20361, 16.63225}, 
} 
  
function joinMedic() 
     setPlayerTeam(source, getTeamFromName("Civilians")) 
     setElementModel(source,15) 
     setElementData(source, "Occupation", "Bus Driver", true) 
     outputChatBox("You are now Bus Driver.",source,0,255,0) 
end 
addEvent("setMedic", true) 
addEventHandler("setMedic",root,joinMedic) 
  
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 getElementData ( thePlayer, "Occupation" ) 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) 

Client:

local marker = createMarker(1764.77, -1896.61, 12.56, "Cylinder",2,255,255,0,255) 
  
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
GUIEditor_Label = {} 
  
local x,y = guiGetScreenSize() 
windowjob = guiCreateWindow(x/2-150,y/2-199,301,397,"Bus Job job",false) 
guiSetVisible(windowjob, false) 
GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) 
GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) 
GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) 
GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take Bus Job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) 
  
function Medicjob(hitElement) 
     if getElementType(hitElement) == "player" and hitElement == localPlayer then 
          if not guiGetVisible(windowjob) then 
               guiSetVisible(windowjob, true) 
               showCursor(true) 
          end 
     end 
end 
addEventHandler("onClientMarkerHit", marker, Medicjob) 
  
function Medicjobleave(leaveElement) 
     if getElementType(leaveElement) == "player" and leaveElement == localPlayer then 
          if guiGetVisible(windowjob) then 
               guiSetVisible(windowjob, false) 
               showCursor(false) 
          end 
     end 
end 
addEventHandler("onClientMarkerLeave", marker, Medicjobleave) 
  
function joinTeam() 
     triggerServerEvent("setMedic",localPlayer) 
     guiSetVisible(windowjob, false) 
     showCursor(false) 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) 
  
function removeMedicWindow() 
     guiSetVisible(windowjob, false) 
     showCursor(false) 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeMedicWindow, false) 
  
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) 

Link to comment
local rootElement = getRootElement() 
local busses = {[431] = true, [437] = true} 
  
local busTable = { 
[1]={1812.65198, -1889.86047, 13.41406}, 
[2]={1825.22791, -1635.03711, 13.38281}, 
[3]={1855.01685, -1430.47449, 13.39063}, 
[4]={1732.81580, -1296.87122, 13.44294}, 
[5]={1473.19226, -1295.77124, 13.48315}, 
[6]={1443.60376, -1498.26660, 13.37650}, 
[7]={1426.37280, -1716.12439, 13.38281}, 
[8]={1315.06909, -1656.43799, 13.38281}, 
[9]={1359.06250, -1432.39734, 13.38281}, 
[10]={1169.82983, -1392.34473, 13.41728}, 
[11]={930.76508, -1392.92627, 13.26561}, 
[12]={815.24756, -1317.91345, 13.44460}, 
[13]={585.04199, -1320.53748, 13.40609}, 
[14]={526.99365, -1624.20361, 16.63225}, 
} 
  
function joinMedic() 
     setPlayerTeam(source, getTeamFromName("Civilians")) 
     setElementModel(source,15) 
     setElementData(source, "Occupation", "Bus Driver", true) 
     outputChatBox("You are now Bus Driver.",source,0,255,0) 
end 
addEvent("setMedic", true) 
addEventHandler("setMedic",root,joinMedic) 
  
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 getElementData ( thePlayer, "Occupation" ) 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

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...