Jump to content

help


Karol

Recommended Posts

here is file ; and it got bugs like when 2 players got trailers in one time and one of them gets money when he reach final and another not ;

but mostly it says in server panel bad element pointer at line 28 ; maybe someone knows how to fix it or set that element id ( circle ) ? u can see taht line 30 at the end of this

function truckerJob ( theTruck )
 theTruckVehicle = theTruck
 theTruckTrailer = source
 theTruckTrailerID = getElementModel (source)
local theDriver = getVehicleOccupant ( theTruck, 0 )
if ( theDriver ) and ( theTruckTrailerID == 584 ) then
outputChatBox ("Bring the trailer to the flag.", theDriver, 0, 255, 111, false)
     theFinishMarker = createMarker ( -1605.90, -2713.98, 46.53, "cylinder", 16, 0, 255, 0, 90, theDriver )
     theFinishBlip = createBlip ( -1605.90, -2713.98, 46.53, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )
end
if ( theDriver ) and ( theTruckTrailerID == 435 ) then
outputChatBox ("Bring the trailer to the flag.", theDriver, 255, 0, 0, false)
     theFinishMarker = createMarker ( -480.59, -514.02, 23.51, "cylinder", 16, 0, 255, 0, 90, theDriver )
     theFinishBlip = createBlip ( -480.59, -514.02, 23.51, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )
end
if ( theDriver ) and ( theTruckTrailerID == 450 ) then
outputChatBox ("Bring the trailer to the flag.", theDriver, 255, 0, 0, false)
     theFinishMarker = createMarker ( -771.58, -119.03, 63.34, "cylinder", 16, 0, 255, 0, 90, theDriver )
     theFinishBlip = createBlip ( -771.58, -119.03, 63.34, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )
end
if ( theDriver ) and ( theTruckTrailerID == 591 ) then
outputChatBox ("Bring the trailer to the flag.", theDriver, 255, 0, 0, false)
     theFinishMarker = createMarker ( 344.08, 873.30, 18.40, "cylinder", 16, 0, 255, 0, 90, theDriver )
     theFinishBlip = createBlip ( 344.08, 873.30, 18.40, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )
end
function truckerJobMarkerHit ( hitPlayer, matchingDimension )
[b]theMarkerID = getElementID (theFinishMarker)[/b]
if (source == theFinishMarker) then
givePlayerMoney ( hitPlayer, 150 )
destroyElement ( theFinishMarker )
destroyElement ( theFinishBlip )
respawnVehicle ( theTruckTrailer )
outputChatBox ( "Mission Passed, you earn $150", hitPlayer, 255, 0, 0, false )
end
end
addEventHandler ("onMarkerHit", getRootElement(), truckerJobMarkerHit)
end
addEventHandler("onTrailerAttach", getRootElement(), truckerJob)
 
function truckerJobFailed ( theTruck )
removeEventHandler ("onMarkerHit", getRootElement(), truckerJobMarkerHit)
local theDriver = getVehicleOccupant ( theTruck, 0 )
respawnVehicle ( theTruckTrailer )
destroyElement ( theFinishMarker )
destroyElement ( theFinishBlip )
outputChatBox ( "Mission Failed!", theDriver, 255, 0, 0, false )
end
addEventHandler("onTrailerDetach", getRootElement(), truckerJobFailed)

Edited by Guest
Link to comment

you messed up with ending the functions. your first function has to end in line 27 not 36

then you use some global variables where local variables would be enough, for example theTruckVehicle which you don't use anywhere.

next i saved you some work by putting the event handler for the marker hit within your first function and i also attached the event to your finishing marker only to save you the "if source == theFinishMarker"

oh and you forgot to remove the BB code from the script when you put it into the [lua] tags

 

function truckerJob ( theTruck )
 theTruckVehicle = theTruck
 theTruckTrailer = source
 theTruckTrailerID = getElementModel (source)
local theDriver = getVehicleOccupant ( theTruck, 0 )
if ( theDriver ) and ( theTruckTrailerID == 584 ) then
outputChatBox ("Bring the trailer to the flag.", theDriver, 0, 255, 111, false)
     theFinishMarker = createMarker ( -1605.90, -2713.98, 46.53, "cylinder", 16, 0, 255, 0, 90, theDriver )
     theFinishBlip = createBlip ( -1605.90, -2713.98, 46.53, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )
end
if ( theDriver ) and ( theTruckTrailerID == 435 ) then
outputChatBox ("Bring the trailer to the flag.", theDriver, 255, 0, 0, false)
     theFinishMarker = createMarker ( -480.59, -514.02, 23.51, "cylinder", 16, 0, 255, 0, 90, theDriver )
     theFinishBlip = createBlip ( -480.59, -514.02, 23.51, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )
end
if ( theDriver ) and ( theTruckTrailerID == 450 ) then
outputChatBox ("Bring the trailer to the flag.", theDriver, 255, 0, 0, false)
     theFinishMarker = createMarker ( -771.58, -119.03, 63.34, "cylinder", 16, 0, 255, 0, 90, theDriver )
     theFinishBlip = createBlip ( -771.58, -119.03, 63.34, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )
end
if ( theDriver ) and ( theTruckTrailerID == 591 ) then
outputChatBox ("Bring the trailer to the flag.", theDriver, 255, 0, 0, false)
     theFinishMarker = createMarker ( 344.08, 873.30, 18.40, "cylinder", 16, 0, 255, 0, 90, theDriver )
     theFinishBlip = createBlip ( 344.08, 873.30, 18.40, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )
end
addEventHandler ("onMarkerHit", theFinishMarker, truckerJobMarkerHit) -- attaching the event to our finish marker only instead of all elements
end -- end the function here
 
function truckerJobMarkerHit ( hitPlayer, matchingDimension )
givePlayerMoney ( hitPlayer, 150 )
destroyElement ( theFinishMarker )
destroyElement ( theFinishBlip )
respawnVehicle ( theTruckTrailer )
outputChatBox ( "Mission Passed, you earn $150", hitPlayer, 255, 0, 0, false )
end
-- here is where you ended the first function, but that's probably not what you want
addEventHandler("onTrailerAttach", getRootElement(), truckerJob)
 
function truckerJobFailed ( theTruck )
removeEventHandler ("onMarkerHit", theFinishMarker, truckerJobMarkerHit)
local theDriver = getVehicleOccupant ( theTruck, 0 )
respawnVehicle ( theTruckTrailer )
destroyElement ( theFinishMarker )
destroyElement ( theFinishBlip )
outputChatBox ( "Mission Failed!", theDriver, 255, 0, 0, false )
end
addEventHandler("onTrailerDetach", getRootElement(), truckerJobFailed)

the rest looks good

Link to comment

this is what i made and now it says that it is bad element pointer on line 17 and 18 ? :roll:

function truckerJob ( theTruck )
       theTruckVehicle = theTruck
       theTruckTrailer = source
       theTruckTrailerID = getElementModel (source)
local theDriver = getVehicleOccupant ( theTruck, 0 )          
if ( theDriver ) and ( theTruckTrailerID == 450 ) then 
outputChatBox ("Bring the trailer to the flag.", theDriver, 255, 0, 0, false)  
           theFinishMarker = createMarker ( -771.58, -119.03, 63.34, "cylinder", 16, 0, 255, 0, 90, theDriver )
           theFinishBlip = createBlip ( -771.58, -119.03, 63.34, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )  
end           
addEventHandler ("onMarkerHit", theFinishMarker, truckerJobMarkerHit) 
end -- end the function her
 
 
function truckerJobMarkerHit ( hitPlayer, matchingDimension ) 
givePlayerMoney ( hitPlayer, 150 )  
destroyElement ( theFinishMarker )  
destroyElement ( theFinishBlip )  
respawnVehicle ( theTruckTrailer ) 
outputChatBox ( "Mission Passed, you earn $150", hitPlayer, 255, 0, 0, false )  
end       -- here is where you ended the first function, but that's probably not what you want
 
addEventHandler("onTrailerAttach", getRootElement(), truckerJob)
 
 
 
function truckerJobFailed ( theTruck ) 
removeEventHandler ("onMarkerHit", theFinishMarker, truckerJobMarkerHit)  
local theDriver = getVehicleOccupant ( theTruck, 0 )  
respawnVehicle ( theTruckTrailer )
destroyElement ( theFinishMarker ) 
destroyElement ( theFinishBlip )  
outputChatBox ( "Mission Failed!", theDriver, 255, 0, 0, false ) 
end  
addEventHandler("onTrailerDetach", getRootElement(), truckerJobFailed)

Link to comment

try this

local theFinishMarker
local theFinishBlip
local theTruckVehicle
local theTruckTrailer
 
function truckerJob ( theTruck )
       theTruckVehicle = theTruck
       theTruckTrailer = source
       theTruckTrailerID = getElementModel (source)
local theDriver = getVehicleOccupant ( theTruck, 0 )          
if ( theDriver ) and ( theTruckTrailerID == 450 ) then 
outputChatBox ("Bring the trailer to the flag.", theDriver, 255, 0, 0, false)  
           theFinishMarker = createMarker ( -771.58, -119.03, 63.34, "cylinder", 16, 0, 255, 0, 90, theDriver )
           theFinishBlip = createBlip ( -771.58, -119.03, 63.34, 53, 2, 255, 0, 0, 255, 0, 99999.0, theDriver )  
end           
addEventHandler ("onMarkerHit", theFinishMarker, truckerJobMarkerHit) 
end -- end the function her
 
 
function truckerJobMarkerHit ( hitPlayer, matchingDimension ) 
givePlayerMoney ( hitPlayer, 150 )  
destroyElement ( theFinishMarker )  
destroyElement ( theFinishBlip )  
respawnVehicle ( theTruckTrailer ) 
outputChatBox ( "Mission Passed, you earn $150", hitPlayer, 255, 0, 0, false )  
end       -- here is where you ended the first function, but that's probably not what you want
 
addEventHandler("onTrailerAttach", getRootElement(), truckerJob)
 
 
 
function truckerJobFailed ( theTruck ) 
removeEventHandler ("onMarkerHit", theFinishMarker, truckerJobMarkerHit)  
local theDriver = getVehicleOccupant ( theTruck, 0 )  
respawnVehicle ( theTruckTrailer )
destroyElement ( theFinishMarker ) 
destroyElement ( theFinishBlip )  
outputChatBox ( "Mission Failed!", theDriver, 255, 0, 0, false ) 
end  
addEventHandler("onTrailerDetach", getRootElement(), truckerJobFailed)

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