Jump to content

bad argument line 96 addeventhandler


Monty

Recommended Posts

the console reports "bad arguments line 96 addEventHandler"

createBlip ( 1552.4996337891, -1677.3264160156, 15.1953125, 30 ) 
local jailBlip = createBlip ( 1799.9298095703, -1584.1966552734, 13.488187789917, 20 ) 
local jailMark = createMarker( 1799.9298095703, -1584.1966552734, 13.488187789917, "Cylinder" , 1.5, 0, 0, 255, 150) 
  
function createSAPDTeam () 
    SAPDteam = createTeam ("police", 100, 149, 237) 
end 
addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) 
  
function joinSAPD() 
     setPlayerTeam(source,SAPDteam) 
     setElementModel(source, 280) 
      giveWeapon ( source, 3 ) 
     setElementData( source, "Occupation", "Copteam", true ) 
     outputChatBox("You are now SAPD agent.",source,0,255,0) 
end 
addEvent("setSAPD", true) 
addEventHandler("setSAPD",root,joinSAPD) 
  
function policeJob ( attacker, attackerweapon, bodypart, loss ) 
if attacker and getElementType(attacker) == "player" then 
    theTeam = getPlayerTeam ( attacker )  
    theWL = getPlayerwantedLevel( source ) 
     attackerweapon = getPedWeapon(attacker) 
    if (attackerweapon == 3) and (loss > 2 ) then 
     if getTeamName(getPlayerTeam(attacker)) == "police" then 
     if ( theWL > 0 ) then  
triggerEvent ( "CriminalFollow", root, "test" ) 
        end 
         end 
        end 
  end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), policeJob) 
  
  
--FORCES A PRISONER TO FOLLOW THE COP 
function walktheprisoner(thecop, theprisoner) 
    if (getElementData ( theprisoner, "currentstatus" ) == "underarrest") and (getPedOccupiedVehicle ( theprisoner ) == false ) then 
        local copx, copy, copz = getElementPosition ( thecop ) 
        local prisonerx, prisonery, prisonerz = getElementPosition ( theprisoner ) 
        copangle = ( 360 - math.deg ( math.atan2 ( ( copx - prisonerx ), ( copy - prisonery ) ) ) ) % 360 
        setPedRotation ( theprisoner, copangle ) 
        setCameraTarget ( theprisoner, theprisoner ) 
        local dist = getDistanceBetweenPoints2D ( copx, copy, prisonerx, prisonery ) 
        if ( dist > 16 ) then 
            freetheguy ( theprisoner ) --FREES PRISONER IF HE GETS FAR AWAY 
        elseif ( dist > 12 ) then 
            setControlState ( theprisoner, "sprint", true ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist > 6 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist > 1.5 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", true ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist < 1.5 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", false ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        end 
    end 
end 
addEvent("CriminalFollow", true ) 
addEventHandler( "CriminalFollow", root, walktheprisoner ) 
  
  
--FREES A PLAYER (RESETS THEIR CONTROLS AND STATUS) 
function freetheguy (theprisoner) 
    local thecaptor = (getElementData ( theprisoner, "captor" )) 
    setElementData ( theprisoner, "currentstatus", "none" ) 
    setElementData ( theprisoner, "captor", "none" ) 
    showCursor ( theprisoner, false ) 
    setControlState ( theprisoner, "sprint", false ) 
    setControlState ( theprisoner, "walk", false ) 
    setControlState ( theprisoner, "forwards", false ) 
    toggleAllControls (theprisoner, true)    
    local prisonercheck = setTimer ( checkforprisoners, 1500, 1, thecaptor ) 
    TimoutTimer = (getElementData ( theprisoner, "arrestTimeout" )) 
    if isTimer(TimoutTimer) then 
         killTimer(TimoutTimer) 
         setElementData ( theprisoner, "arrestTimeout", nil) 
         TimeoutTimer = nil 
         setElementPosition( theprisoner, 4076.3999023438, -1788.5, 3.511967, true ) 
     setTimer ( setElementPosition, 10000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439)       
     setPlayerWantedLevel (source, 0) 
    end 
end 
addEventHandler( "onClientMarkerHit", jailMark , freetheguy ) 
  
function checkforprisoners(thecop) 
    if isElement(thecop) then 
        local prisoners = 0 
        local players = getElementsByType ( "player" ) 
        for theKey,thePlayer in ipairs(players) do 
            if (getElementData ( thePlayer, "captor" ) == thecop ) then 
                prisoners = prisoners+1 
            end 
        end 
        if prisoners == 0 then 
            setElementData ( thecop, "currentarrests", "none" ) 
            triggerClientEvent( thecop,"clearcopdirections",thecop) 
        elseif prisoners == 1 then 
            setElementData ( thecop, "currentarrests", "single" ) 
        elseif prisoners == 2 then 
            setElementData ( thecop, "currentarrests", "double" ) 
        end 
    end 
end 
  
  
  

Link to comment
Change 'jailmark' to 'jailMark'.

it's already jailMark in his script.

@Monty, You are using client side event (onClientMarkerHit) in server side script, change it to (onMarkerHit).

Also you have wrong argument, source in (lines 92 and 93) is the marker that got hit by the player, so it should be theprisoner not source.

Link to comment
i fixed but the console now repots "expected an element at argument 2"

What line?

Post your code after the fix.

EDIT:

you have "Cylinder" instead of "cylinder"

local jailMark = createMarker( 1799.9298095703, -1584.1966552734, 13.488187789917, "Cylinder" , 1.5, 0, 0, 255, 150 ) 

Should be

local jailMark = createMarker( 1799.9298095703, -1584.1966552734, 13.488187789917, "cylinder" , 1.5, 0, 0, 255, 150 ) 

Link to comment
  
function joinSAPD() 
     setPlayerTeam(source,SAPDteam) 
     setElementModel(source, 280) 
      giveWeapon ( source, 3 ) 
     setElementData( source, "Occupation", "Copteam", true ) 
     outputChatBox("You are now SAPD agent.",source,0,255,0) 
end 
addEvent("setSAPD", true) 
addEventHandler("setSAPD",root,joinSAPD) 
  
function policeJob ( attacker, attackerweapon, bodypart, loss ) 
if attacker and getElementType(attacker) == "player" then 
    theTeam = getPlayerTeam ( attacker )  
    theWL = getPlayerwantedLevel( source ) 
     attackerweapon = getPedWeapon(attacker) 
    if (attackerweapon == 3) and (loss > 2 ) then 
     if getTeamName(getPlayerTeam(attacker)) == "police" then 
     if ( theWL > 0 ) then  
triggerEvent ( "CriminalFollow", root, "test" ) 
        end 
         end 
        end 
  end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), policeJob) 
  
  
--FORCES A PRISONER TO FOLLOW THE COP 
function walktheprisoner(thecop, theprisoner) 
    if (getElementData ( theprisoner, "currentstatus" ) == "underarrest") and (getPedOccupiedVehicle ( theprisoner ) == false ) then 
        local copx, copy, copz = getElementPosition ( thecop ) 
        local prisonerx, prisonery, prisonerz = getElementPosition ( theprisoner ) 
        copangle = ( 360 - math.deg ( math.atan2 ( ( copx - prisonerx ), ( copy - prisonery ) ) ) ) % 360 
        setPedRotation ( theprisoner, copangle ) 
        setCameraTarget ( theprisoner, theprisoner ) 
        local dist = getDistanceBetweenPoints2D ( copx, copy, prisonerx, prisonery ) 
        if ( dist > 16 ) then 
            freetheguy ( theprisoner ) --FREES PRISONER IF HE GETS FAR AWAY 
        elseif ( dist > 12 ) then 
            setControlState ( theprisoner, "sprint", true ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist > 6 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist > 1.5 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", true ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist < 1.5 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", false ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        end 
    end 
end 
addEvent("CriminalFollow", true ) 
addEventHandler( "CriminalFollow", root, walktheprisoner ) 
  
  
--FREES A PLAYER (RESETS THEIR CONTROLS AND STATUS) 
function freetheguy (theprisoner) 
    local thecaptor = (getElementData ( theprisoner, "captor" )) 
    setElementData ( theprisoner, "currentstatus", "none" ) 
    setElementData ( theprisoner, "captor", "none" ) 
    showCursor ( theprisoner, false ) 
    setControlState ( theprisoner, "sprint", false ) 
    setControlState ( theprisoner, "walk", false ) 
    setControlState ( theprisoner, "forwards", false ) 
    toggleAllControls (theprisoner, true)    
    local prisonercheck = setTimer ( checkforprisoners, 1500, 1, thecaptor ) 
    TimoutTimer = (getElementData ( theprisoner, "arrestTimeout" )) 
    if isTimer(TimoutTimer) then 
         killTimer(TimoutTimer) 
         setElementData ( theprisoner, "arrestTimeout", nil) 
         TimeoutTimer = nil 
         setElementPosition( theprisoner, 4076.3999023438, -1788.5, 3.511967, true ) 
     setTimer ( setElementPosition, 10000, 1, theprisoner, 1544.4332275391, -1674.7698974609, 13.688399200439)       
     setPlayerWantedLevel (theprisoner, 0) 
    end 
end 
addEventHandler( "onMarkerHit", jailMark , freetheguy ) 
  
function checkforprisoners(thecop) 
    if isElement(thecop) then 
        local prisoners = 0 
        local players = getElementsByType ( "player" ) 
        for theKey,thePlayer in ipairs(players) do 
            if (getElementData ( thePlayer, "captor" ) == thecop ) then 
                prisoners = prisoners+1 
            end 
        end 
        if prisoners == 0 then 
            setElementData ( thecop, "currentarrests", "none" ) 
            triggerClientEvent( thecop,"clearcopdirections",thecop) 
        elseif prisoners == 1 then 
            setElementData ( thecop, "currentarrests", "single" ) 
        elseif prisoners == 2 then 
            setElementData ( thecop, "currentarrests", "double" ) 
        end 
    end 
end 

Link to comment
  
function joinSAPD() 
     setPlayerTeam(source,SAPDteam) 
     setElementModel(source, 280) 
      giveWeapon ( source, 3 ) 
     setElementData( source, "Occupation", "Copteam", true ) 
     outputChatBox("You are now SAPD agent.",source,0,255,0) 
end 
addEvent("setSAPD", true) 
addEventHandler("setSAPD",root,joinSAPD) 
  
function policeJob ( attacker, attackerweapon, bodypart, loss ) 
if attacker and getElementType(attacker) == "player" then 
    theTeam = getPlayerTeam ( attacker )  
    theWL = getPlayerwantedLevel( source ) 
     attackerweapon = getPedWeapon(attacker) 
    if (attackerweapon == 3) and (loss > 2 ) then 
     if getTeamName(getPlayerTeam(attacker)) == "police" then 
     if ( theWL > 0 ) then  
triggerEvent ( "CriminalFollow", root, "test" ) 
        end 
         end 
        end 
  end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), policeJob) 
  
  
--FORCES A PRISONER TO FOLLOW THE COP 
function walktheprisoner(thecop, theprisoner) 
    if (getElementData ( theprisoner, "currentstatus" ) == "underarrest") and (getPedOccupiedVehicle ( theprisoner ) == false ) then 
        local copx, copy, copz = getElementPosition ( thecop ) 
        local prisonerx, prisonery, prisonerz = getElementPosition ( theprisoner ) 
        copangle = ( 360 - math.deg ( math.atan2 ( ( copx - prisonerx ), ( copy - prisonery ) ) ) ) % 360 
        setPedRotation ( theprisoner, copangle ) 
        setCameraTarget ( theprisoner, theprisoner ) 
        local dist = getDistanceBetweenPoints2D ( copx, copy, prisonerx, prisonery ) 
        if ( dist > 16 ) then 
            freetheguy ( theprisoner ) --FREES PRISONER IF HE GETS FAR AWAY 
        elseif ( dist > 12 ) then 
            setControlState ( theprisoner, "sprint", true ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist > 6 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist > 1.5 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", true ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist < 1.5 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", false ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        end 
    end 
end 
addEvent("CriminalFollow", true ) 
addEventHandler( "CriminalFollow", root, walktheprisoner ) 
  
  
--FREES A PLAYER (RESETS THEIR CONTROLS AND STATUS) 
function freetheguy (theprisoner) 
    local thecaptor = (getElementData ( theprisoner, "captor" )) 
    setElementData ( theprisoner, "currentstatus", "none" ) 
    setElementData ( theprisoner, "captor", "none" ) 
    showCursor ( theprisoner, false ) 
    setControlState ( theprisoner, "sprint", false ) 
    setControlState ( theprisoner, "walk", false ) 
    setControlState ( theprisoner, "forwards", false ) 
    toggleAllControls (theprisoner, true)    
    local prisonercheck = setTimer ( checkforprisoners, 1500, 1, thecaptor ) 
    TimoutTimer = (getElementData ( theprisoner, "arrestTimeout" )) 
    if isTimer(TimoutTimer) then 
         killTimer(TimoutTimer) 
         setElementData ( theprisoner, "arrestTimeout", nil) 
         TimeoutTimer = nil 
         setElementPosition( theprisoner, 4076.3999023438, -1788.5, 3.511967, true ) 
     setTimer ( setElementPosition, 10000, 1, theprisoner, 1544.4332275391, -1674.7698974609, 13.688399200439)       
     setPlayerWantedLevel (theprisoner, 0) 
    end 
end 
addEventHandler( "onMarkerHit", jailMark , freetheguy ) 
  
function checkforprisoners(thecop) 
    if isElement(thecop) then 
        local prisoners = 0 
        local players = getElementsByType ( "player" ) 
        for theKey,thePlayer in ipairs(players) do 
            if (getElementData ( thePlayer, "captor" ) == thecop ) then 
                prisoners = prisoners+1 
            end 
        end 
        if prisoners == 0 then 
            setElementData ( thecop, "currentarrests", "none" ) 
            triggerClientEvent( thecop,"clearcopdirections",thecop) 
        elseif prisoners == 1 then 
            setElementData ( thecop, "currentarrests", "single" ) 
        elseif prisoners == 2 then 
            setElementData ( thecop, "currentarrests", "double" ) 
        end 
    end 
end 

You eat the marker and the blip? :o

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