This is a modification of rrtrucker, i am trying to change it so when you get to the ped, it spawns a trailer, and when trailer is attached to you, it gives you a destination, but i am having problems at function givePoint(), it gives an error saying no ponts specified, can somebody help?
serverside:
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() truckSkins = { [206]=true, [133]=true } trucks = { [515]=true, [514]=true, [403]=true } playerClients = { } playerCols = { } playerBlips = { } jobClients = { } playerJobLocation = { }; local XMLTruckerLocations = xmlLoadFile ( "XML\\trucker_locations.xml" ) if ( not XMLTruckerLocations ) then local XMLTruckerLocations = xmlCreateFile ( "XML\\trucker_locations.xml", "trucker_locations" ) xmlSaveFile ( XMLTruckerLocations ) end local trucker_locations = xmlNodeGetChildren(XMLTruckerLocations) truckerLocations = {} for i,node in ipairs(trucker_locations) do truckerLocations[i] = {} truckerLocations[i]["x"] = xmlNodeGetAttribute ( node, "posX" ) truckerLocations[i]["y"] = xmlNodeGetAttribute ( node, "posY" ) truckerLocations[i]["z"] = xmlNodeGetAttribute ( node, "posZ" ) truckerLocations[i]["r"] = xmlNodeGetAttribute ( node, "rot" ) end xmlUnloadFile ( XMLTruckerLocations ) end ) function enterVehicle ( thePlayer, seat, jacked ) if ( trucks[getElementModel ( source )] ) and ( not truckSkins[getElementModel ( thePlayer )] ) and (seat == 0) then cancelEvent() outputChatBox ( "Only truckers drivers can drive Transports!", thePlayer ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) function startJob ( playerSource ) local x, y, z = getElementPosition ( playerSource ) if not playerClients[ playerSource ] then local numLocations = #truckerLocations if ( numLocations > 0 ) then repeatCount = 0; repeat local pickupPoint = math.random(numLocations) pickupx = truckerLocations[pickupPoint]["x"] pickupy = truckerLocations[pickupPoint]["y"] pickupz = truckerLocations[pickupPoint]["z"] pickupr = truckerLocations[pickupPoint]["r"] local jobDistance = getDistanceBetweenPoints3D ( x, y, z, pickupx, pickupy, pickupz ); repeatCount = repeatCount+1 until jobDistance > 100 and jobDistance < 800 + repeatCount*100 repeat local id = math.random( 10, 270 ) ped = createPed( tonumber( id ), pickupx, pickupy, pickupz ) setPedRotation ( ped, pickupr ) until ped playerClients[ playerSource ] = { }; table.insert( playerClients[ playerSource ], ped ); table.insert( jobClients, ped ); local pedBlip = createBlipAttachedTo ( ped, 41, 2, 255, 0, 0, 255, 1, 99999.0, playerSource) playerBlips[ playerSource ] = { }; table.insert( playerBlips[ playerSource ], pedBlip ); pedMarker = createMarker ( pickupx, pickupy, 0, cylinder, 6.5, 255, 255, 0, 150, playerSource) playerCols[ playerSource ] = { }; table.insert( playerCols[ playerSource ], pedMarker ); addEventHandler( "onMarkerHit", pedMarker, arrivePickup ) outputChatBox ( "Pickup the passenger with delivery located at the marker.", playerSource ); else outputChatBox ( "No passenger pickup points specified, contact an admin!", playerSource ); end else outputChatBox ( "You already have an assignment!", source ); end end addCommandHandler ("startjob", startJob); function arrivePickup ( playerSource ) if playerClients[ playerSource ] then for k, ped in pairs( playerClients[ playerSource ] ) do if ped then local x,y,z = getElementPosition(ped); local tx,ty,tz = getElementPosition(playerSource); setPedRotation(ped, findRotation(x,y,tx,ty) ); local numLocations = #truckerLocations if ( numLocations > 0 ) then local playerVehicle = getPedOccupiedVehicle ( playerSource ); if playerVehicle and trucks[getElementModel ( playerVehicle )] then local speedx, speedy, speedz = getElementVelocity ( playerSource ); local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5); if actualspeed < 0.25 then local occupants = getVehicleOccupants(playerVehicle); local seats = getVehicleMaxPassengers(playerVehicle); local freeSeats = 0; for seat = 0, seats do local occupant = occupants[seat]; if not occupant and tonumber(freeSeats) == 0 then freeSeats = freeSeats + 1; warpPedIntoVehicle ( ped, playerVehicle, seat ); if playerBlips[ playerSource ] then for k, blip in pairs( playerBlips[ playerSource ] ) do if blip then destroyElement( blip ); playerBlips[ playerSource ] = nil; end end end if playerCols[ playerSource ] then for k, col in pairs( playerCols[ playerSource ] ) do if col then destroyElement( col ); playerCols[ playerSource ] = nil; end end end trailer = createVehicle ( 435, x-2 ,y-2 ,z+1) triggerEvent("givePoint") end end if tonumber(freeSeats) == 0 then outputChatBox ( "You don't have an empty seat for the passenger!", playerSource ); end else outputChatBox ( "Slow down to pick up the passenger!", playerSource ); end else outputChatBox ( "You do not have a driver vehicle!", playerSource ); end else outputChatBox ( "No passenger pickup points specified, contact an admin!", playerSource ); end end end end end addEvent("givePoint", true) function givePoint( playerSource ) local x,y,z = getElementPosition(ped); playerJobLocation[ playerSource ] = { }; playerJobLocation[ playerSource ] = { ["x"]=x, ["y"]=y, ["z"]=z }; repeat local dropOffPoint = math.random(numLocations) dropOffx = truckerLocations[dropOffPoint]["x"] dropOffy = truckerLocations[dropOffPoint]["y"] dropOffz = truckerLocations[dropOffPoint]["z"] local jobDistance = getDistanceBetweenPoints3D ( x, y, z, dropOffx, dropOffy, dropOffz ); until jobDistance > 1000 and jobDistance < 35000 local dropOffBlip = createBlip ( dropOffx, dropOffy, dropOffz, 41, 2, 255, 0, 0, 255, 1, 99999.0, playerSource) playerBlips[ playerSource ] = { }; table.insert( playerBlips[ playerSource ], dropOffBlip ); pedMarker = createMarker ( dropOffx, dropOffy, 0, cylinder, 6.5, 255, 255, 0, 150, playerSource) playerCols[ playerSource ] = { }; table.insert( playerCols[ playerSource ], pedMarker ); addEventHandler( "onMarkerHit", pedMarker, arriveDropOff ) outputChatBox ( "Drive your products to the destination marker.", playerSource ); end addEventHandler("givePoint", getRootElement(), givePoint) function arriveDropOff ( playerSource ) if playerClients[ playerSource ] then for k, ped in pairs( playerClients[ playerSource ] ) do if ped then local pedVehicle = getPedOccupiedVehicle ( ped ); local playerVehicle = getPedOccupiedVehicle ( playerSource ); if playerVehicle and trucks[getElementModel ( playerVehicle )] then if pedVehicle == playerVehicle then local speedx, speedy, speedz = getElementVelocity ( playerSource ); local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5); if actualspeed < 0.22 then removePedFromVehicle ( ped ); if playerClients[ playerSource ] then for k, ped in pairs( playerClients[ playerSource ] ) do if ped then destroyElement( ped ); playerClients[ playerSource ] = nil; end end for k, blip in pairs( playerBlips[ playerSource ] ) do if blip then destroyElement( blip ); playerBlips[ playerSource ] = nil; end end for k, col in pairs( playerCols[ playerSource ] ) do if col then destroyElement( col ); playerCols[ playerSource ] = nil; end end dx = tonumber(playerJobLocation[ playerSource ]["x"]); dy = tonumber(playerJobLocation[ playerSource ]["y"]); dz = tonumber(playerJobLocation[ playerSource ]["z"]); local tx,ty,tz = getElementPosition(playerSource); local jobDistance = getDistanceBetweenPoints3D ( dx, dy, dz, tx, ty, tz ); local jobDistanceKM = round(jobDistance/1000,2); local jobReward = round(10+(jobDistanceKM^0.75)*3000); givePlayerMoney ( playerSource, jobReward ); for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do if jobLocation then playerJobLocation[ playerSource ] = nil; end end outputChatBox ( "Job succesful, you earned "..jobReward.." dollar.", playerSource ); end else outputChatBox ( "Slow down to drop off the passenger!", playerSource ); end else outputChatBox ( "You have lost your passenger!", playerSource ); end else outputChatBox ( "You do not have a driver vehicle!", playerSource ); end end end end end function quitJob ( playerSource ) if playerClients[ playerSource ] then for k, ped in pairs( playerClients[ playerSource ] ) do if ped then destroyElement( ped ); playerClients[ playerSource ] = nil; end end for k, blip in pairs( playerBlips[ playerSource ] ) do if blip then destroyElement( blip ); playerBlips[ playerSource ] = nil; end end for k, col in pairs( playerCols[ playerSource ] ) do if col then destroyElement( col ); playerCols[ playerSource ] = nil; end end if playerJobLocation[ playerSource ] then for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do if jobLocation then destroyElement( jobLocation ); playerJobLocation[ playerSource ] =