Jump to content

[help]script


Castillo

Recommended Posts

hi, i have problems with this script for a mission i was wondering if can someone give me a hand on it thanks

errors are this on debugscript

Warning: server.lua Bad argument @ "addEventHandler" - Line: 4

ser-side

function createMissionVehicle ( playerSource, commandName, car, x, y, z )
local missionvehicle = createVehicle ( 411, -1974.7426757813, 266.41040039063, 35.171875 )
warpPedIntoVehicle ( playerSource, missionvehicle )
marker = createMarker ( -1987.1921386719, 950.17266845703, 44.963710784912, "cylinder", 3, 254, 1, 2, 00 )
addEventHandler ( "onClientMarkerHit", marker, carJob )   
addEventHandler ("onVehicleEnter", missionvehicle, carJob)
end
 
function carJob ( thePlayer, seat )
if ( thePlayer ) and ( seat == 0 ) and ( source == missionvehicle ) then
outputChatBox ("Deliver the car to the place.", thePlayer, 255, 0, 0, false)
     theEndMarker = createMarker ( -1985.2788085938, 949.21502685547, 45.4602394104, "cylinder", 16, 0, 255, 0, 90, thePlayer )
     theEndBlip = createBlip ( -1985.2788085938, 949.21502685547, 45.4602394104, 53, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer )
setVehicleLocked ( missionvehicle, true )
addEventHandler ("onMarkerHit", theEndMarker, carJobMarkerHit)
end
 
function carJobMarkerHit ( hitPlayer, matchingDimension )
 theMarkerID = getElementID (theEndMarker)
if (source == theEndMarker) then
givePlayerMoney ( hitPlayer, 20 )
destroyElement ( theEndMarker )
destroyElement ( theEndBlip )
outputChatBox ( "Your car delivered successfull", hitPlayer, 255, 0, 0, false )
end
end
end
addEvent( "sendcardata", true )
addEventHandler ( "sendcardata", getRootElement(), createMissionVehicle)

Edited by Guest
Link to comment

hi, i have problems with this script for a mission i was wondering if can someone give me a hand on it thanks

errors are this on debugscript

Warning: server.lua Bad argument @ "addEventHandler" - Line: 4

ser-side

function createMissionVehicle ( playerSource, commandName, car, x, y, z )
local missionvehicle = createVehicle ( 411, -1974.7426757813, 266.41040039063, 35.171875 )
warpPedIntoVehicle ( playerSource, missionvehicle )
marker = createMarker ( -1987.1921386719, 950.17266845703, 44.963710784912, "cylinder", 3, 254, 1, 2, 00 )
addEventHandler ( "onClientMarkerHit", marker, carJob )   
addEventHandler ("onVehicleEnter", missionvehicle, carJob)
end
 
function carJob ( thePlayer, seat )
if ( thePlayer ) and ( seat == 0 ) and ( source == missionvehicle ) then
outputChatBox ("Deliver the car to the place.", thePlayer, 255, 0, 0, false)
     theEndMarker = createMarker ( -1985.2788085938, 949.21502685547, 45.4602394104, "cylinder", 16, 0, 255, 0, 90, thePlayer )
     theEndBlip = createBlip ( -1985.2788085938, 949.21502685547, 45.4602394104, 53, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer )
setVehicleLocked ( missionvehicle, true )
addEventHandler ("onMarkerHit", theEndMarker, carJobMarkerHit)
end
 
function carJobMarkerHit ( hitPlayer, matchingDimension )
 theMarkerID = getElementID (theEndMarker)
if (source == theEndMarker) then
givePlayerMoney ( hitPlayer, 20 )
destroyElement ( theEndMarker )
destroyElement ( theEndBlip )
outputChatBox ( "Your car delivered successfull", hitPlayer, 255, 0, 0, false )
end
end
end
addEvent( "sendcardata", true )
addEventHandler ( "sendcardata", getRootElement(), createMissionVehicle)

Edited by Guest
Link to comment

You are trying to attach an event handler to an element you haven't created yet.

In fact, I'm seeing massive problems here. Line 4 is using the wrong event as the function you attach it to is expecting arguments similar to what onVehicleEnter would provide, and in that case it should be attached to the "missionvehicle" element.

missionvehicle is set local to the createMissionVehicle function but you want to compare to it in your carJob function - it will return nil.

On line 8, you also check for an element that doesn't exist later on, "missionvehicleboat".

Your "createMissionVehicle" function has arguments set up for a command handler but it is called via an event.

Link to comment

You are trying to attach an event handler to an element you haven't created yet.

In fact, I'm seeing massive problems here. Line 4 is using the wrong event as the function you attach it to is expecting arguments similar to what onVehicleEnter would provide, and in that case it should be attached to the "missionvehicle" element.

missionvehicle is set local to the createMissionVehicle function but you want to compare to it in your carJob function - it will return nil.

On line 8, you also check for an element that doesn't exist later on, "missionvehicleboat".

Your "createMissionVehicle" function has arguments set up for a command handler but it is called via an event.

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