Jump to content

[HELP]bad Argument AddEventHandler


HustraDev

Recommended Posts

Hi all

i'm working on new job script

i have problem in this code :

i made marker in a function and i want to add handler

for ("onMarkerHit")

but when i test it not working

the code :

  
addEvent("ib",true) 
addEventHandler("ib",root, 
function () 
marker1 = createmarker (...) 
end 
) 
addEventHandler( "onMarkerHit", marker1, 
function() 
         warpPedIntoVehicle ( client1, Vehicle) 
end 
) 
  
  

Link to comment
Hi all

i'm working on new job script

i have problem in this code :

i made marker in a function and i want to add handler

for ("onMarkerHit")

but when i test it not working

the code :

  
addEvent("ib",true) 
addEventHandler("ib",root, 
function () 
marker1 = createmarker (...) 
end 
) 
addEventHandler( "onMarkerHit", marker1, 
function() 
         warpPedIntoVehicle ( client1, Vehicle) 
end 
) 
  
  

](*,)

Link to comment
  
addEvent("ib",true) 
addEventHandler("ib",root, 
function () 
marker1 = createMarker(...) 
addEventHandler( "onMarkerHit", marker1,onHit) 
end 
) 
function onHit() 
 if getElementType(source) == "player" then  
         warpPedIntoVehicle ( source, Vehicle) 
 end 
end 
  
  
  

\not working\@_2

Link to comment
  
addEvent("ib", true) 
addEventHandler("ib", root, 
    function() 
        marker1 = createMarker(...) 
        addEventHandler("onMarkerHit", marker1, onHit, false) 
end 
) 
function onHit(hitElement) 
    if getElementType(hitElement) == "player" then 
        warpPedIntoVehicle(hitElement, Vehicle) 
    end 
end 
  

Link to comment
addEvent("ib",true) 
addEventHandler("ib",root, 
function () 
marker1 = createMarker(...) 
addEventHandler( "onMarkerHit", marker1,onHit) 
end 
) 
function onHit() 
 if getElementType(source) == "player" then  
         warpPedIntoVehicle ( source, Vehicle) 
 end 
end 

 

 

The source of this event is the marker that got hit by the element.
Link to comment

all code's not working

post all code :-

  
addEvent("ib",true) 
addEventHandler("ib",root, 
 function () 
                local x, y, z = getElementPosition ( source ) 
            Vehicle = createVehicle (443, x+2, y, z ) 
            warpPedIntoVehicle ( source, Vehicle) 
         setElementData ( source, "destroy", Vehicle ) 
                  local client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) 
         local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) 
         marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) 
         addEventHandler("onMarkerHit", marker1, onHit,false) 
end 
) 
  
function warpit ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
       local vehiclee = getPedOccupiedVehicle ( thePlayer ) 
        if ( getElementModel ( vehiclee ) == 420 ) then 
      warpPedIntoVehicle ( client1, Vehicle) 
            end 
            end 
            end 
  
  

Help Please

](*,)](*,)](*,)](*,)](*,)](*,)](*,)](*,)](*,)

Link to comment
  
  
addEvent("ib",true) 
addEventHandler("ib",root, 
 function () 
                local x, y, z = getElementPosition ( source ) 
            Vehicle = createVehicle (443, x+2, y, z ) 
            warpPedIntoVehicle ( source, Vehicle) 
         setElementData ( source, "destroy", Vehicle ) 
                  local client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) 
         local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) 
         marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) 
         addEventHandler("onMarkerHit", marker1, onHit,false) 
end 
) 
  
function warpit ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
       local vehiclee = getPedOccupiedVehicle ( thePlayer ) 
        if ( getElementModel ( vehiclee ) == 420 ) then 
      warpPedIntoVehicle ( thePlayer , Vehicle) 
            end 
            end 
            end 
  

Link to comment
  
  
addEvent("ib",true) 
addEventHandler("ib",root, 
 function () 
                local x, y, z = getElementPosition ( source ) 
            Vehicle = createVehicle (443, x+2, y, z ) 
            warpPedIntoVehicle ( source, Vehicle) 
         setElementData ( source, "destroy", Vehicle ) 
                  local client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) 
         local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) 
         marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) 
         addEventHandler("onMarkerHit", marker1, onHit,false) 
end 
) 
  
function warpit ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
       local vehiclee = getPedOccupiedVehicle ( thePlayer ) 
        if ( getElementModel ( vehiclee ) == 420 ) then 
      warpPedIntoVehicle ( thePlayer , Vehicle) 
            end 
            end 
            end 
  

i want the marker when i hit it warp the ped client1 into my vehicle

no warp me $>$

Link to comment
  
addEvent("ib", true) 
addEventHandler("ib", root, 
    function() 
        local x, y, z = getElementPosition ( source ) 
        Vehicle = createVehicle (443, x+2, y, z ) 
        warpPedIntoVehicle ( source, Vehicle) 
        setElementData ( source, "destroy", Vehicle ) 
        client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) 
        local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) 
        marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) 
        addEventHandler("onMarkerHit", marker1, onHit,false) 
    end 
) 
  
function warpit ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
       local vehiclee = getPedOccupiedVehicle ( thePlayer ) 
        if ( getElementModel ( vehiclee ) == 420 ) then 
            warpPedIntoVehicle ( client1, Vehicle) 
        end 
    end 
end 
  

Link to comment
  
addEvent("ib", true) 
addEventHandler("ib", root, 
    function() 
        local x, y, z = getElementPosition ( source ) 
        Vehicle = createVehicle (443, x+2, y, z ) 
        warpPedIntoVehicle ( source, Vehicle) 
        setElementData ( source, "destroy", Vehicle ) 
        client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) 
        local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) 
        marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) 
        addEventHandler("onMarkerHit", marker1, onHit,false) 
    end 
) 
  
function warpit ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
       local vehiclee = getPedOccupiedVehicle ( thePlayer ) 
        if ( getElementModel ( vehiclee ) == 420 ) then 
            warpPedIntoVehicle ( client1, Vehicle) 
        end 
    end 
end 
  

Not Working Man This Resource Drive Me Crezy :redhotevil:

Link to comment

Now 100%( not )working

it was when i use this

  
addEvent("ib", true) 
addEventHandler("ib", root, 
    function() 
        x, y, z = getElementPosition ( source ) 
        Vehicle = createVehicle (443, x+2, y, z ) 
        warpPedIntoVehicle ( source, Vehicle) 
        setElementData ( source, "destroy", Vehicle ) 
        client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) 
        arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) 
        marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) 
        addEventHandler("onMarkerHit", marker1, onHit) 
    end 
) 
function onHit(source) 
 if getElementType(source) == "player" then 
 warpPedIntoVehicle ( client1, Vehicle) 
 end 
  
end 
  

but the problem i need to get out of the car to warp the ped into vehicel

not warping the ped when i'm in the car !! @_@

Link to comment

i try isPedInVehicle and NotWorking *_*"

  
addEvent("ib", true) 
addEventHandler("ib", root, 
    function() 
        x, y, z = getElementPosition ( source ) 
        Vehicle = createVehicle (443, x+2, y, z ) 
        warpPedIntoVehicle ( source, Vehicle) 
        setElementData ( source, "destroy", Vehicle ) 
        client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) 
        arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) 
        marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) 
        addEventHandler("onMarkerHit", marker1, onHit) 
    end 
) 
function onHit(source) 
 if getElementType(source) == "player" and isPedInVehicle(source) then 
 warpPedIntoVehicle ( client1, Vehicle) 
 end 
  
end 
  

Link to comment
  • Moderators
but the problem i need to get out of the car to warp the ped into vehicel

Perhaps you should try to add "not", because you are doing the opposite of what you are saying.

Never use source as parameter or you will not be able to access the source element any more.(in this case the marker itself)

and not isPedInVehicle(source) then 

You never wondering why something isn't working, don't you? :roll:

Link to comment
  • Moderators

anyway, why are you use this variable for defining the ped that must be teleported in? Because now ped/peds will be shared with other taxi drives.

and why don't you check if client1 is an element? Always keep an eye on the unpredictable.

You should save everything with elementdata, tables or a database per player. Like you did on line 8.

and you should debug your code before you ask again why it doesn't work.

outputDebugString("It doesn't get triggered!!!! Please try again!") 

/debugscript 3

Here a nice example:

https://wiki.multitheftauto.com/wiki/Debugging

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