Jump to content

[HELP]Bad Argument


NotAvailable

Recommended Posts

Hi, i have a little problem.

I made a teleport script when u enter the marker and u type: /leave u will be teleported.

But i get a error:

local myMarker = createMarker( -2284.4592285156, 1909.6333007813, 7.9688625335693, "Cylinder", 1, 255, 0, 0, 140) 
  
function openForMe(hitElement, matchingDimension) 
    if getElementType ( hitElement ) == "player" then 
    local vehicle = getPlayerOccupiedVehicle ( hitElement ) 
        if vehicle or not vehicle then 
            local wanted = getPlayerWantedLevel ( hitElement ) 
            if wanted == 0 then 
            addCommandHandler("leave", teleportMassive) 
            end 
            end 
            end 
            end 
            addEventHandler("onMarkerHit", myMarker,openForMe) 
                     
             
function teleportMassive(hitElement, matchingDimension) 
    if getElementType ( hitElement ) == "player" then 
    local vehicle = getPlayerOccupiedVehicle ( hitElement ) 
        if vehicle or not vehicle then 
        setElementPosition(player, -2279.3093261719, 1909.4665527344, 8.9688625335693) 
        setElementRotation(player, 270.36642456055) 
        removeCommandHandler("leave") 
    end 
  end 
end 

Whats wrong with it? Im not getting any errors in the script editor.

Regards,

Jesseunit

Link to comment

in your teleportMassive() function player who typed the command is put in «hitElement» variable, while you teleporting the «player» variable.

also getPlayerOccupiedVehicle() is deprecated, use getPedOccupiedVehicle()

and what is the point of «if vehicle or not vehicle then»?

Link to comment

Its still not working

i get this error:

[18:04:24] WARNING: editor_test\misc_S.lua:13: Bad argument @ 'addEventHandler' 

Heres the code:

function openForMe(hitElement, matchingDimension) 
    if getElementType ( hitElement ) == "player" then 
            local wanted = getPlayerWantedLevel ( hitElement ) 
            if wanted == 0 then 
            outputChatBox("Are you sure you want to leave Alcatraz?", hitElement, 0, 255, 0) 
            outputChatBox("Say: /leave if u want to leave", hitElement, 255, 200, 0) 
            addCommandHandler("leave", teleportMassive) 
            end 
            end 
                end 
                    addEventHandler("onMarkerHit", myMarker,openForMe) 
             
function teleportMassive(player, matchingDimension) 
        local player = getPlayerFromName(player);  
        setElementPosition(player, -2279.3093261719, 1909.4665527344, 8.9688625335693) 
        setElementRotation(player, 270.36642456055) 
        removeCommandHandler("leave") 
    end 

Edited by Guest
Link to comment

i still get the same error.

This is the full code:

local myMarker = createMarker( -2284.4592285156, 1909.6333007813, 7.9688625335693, "Cylinder", 1, 255, 0, 0, 140) 
  
function openForMe(hitElement, matchingDimension) 
    if getElementType ( hitElement ) == "player" then 
            local wanted = getPlayerWantedLevel ( hitElement ) 
            if wanted == 0 then 
            outputChatBox("Are you sure you want to leave Alcatraz?", hitElement, 0, 255, 0) 
            outputChatBox("Say: /leave if u want to leave", hitElement, 255, 200, 0) 
            addCommandHandler("leave", teleportMassive) 
            end 
            end 
                end 
                    addEventHandler("onMarkerHit", myMarker,openForMe) 
             
function teleportMassive(player, matchingDimension) 
        setElementPosition(player, -2279.3093261719, 1909.4665527344, 8.9688625335693) 
        setElementRotation(player, 270.36642456055) 
        removeCommandHandler("leave") 
    end 

Link to comment

uhm, the marker wasn't being created, how do i know? i simply added a small check and results not being created, anyway i've fixed the marker and here is the code:

local myMarker = createMarker ( -2284.4592285156, 1909.6333007813, 7.9688625335693, "cylinder", 1, 255, 0, 140, getRootElement()) 
if myMarker then 
outputChatBox("Marker created!") 
else 
outputChatBox("Marker couldn't be created!") 
end 
  
function openForMe(hitElement, matchingDimension) 
    if getElementType ( hitElement ) == "player" then 
        local wanted = getPlayerWantedLevel ( hitElement ) 
        if wanted == 0 then 
        outputChatBox("Are you sure you want to leave Alcatraz?", hitElement, 0, 255, 0) 
        outputChatBox("Say: /leave if u want to leave", hitElement, 255, 200, 0) 
        addCommandHandler("leave", teleportMassive) 
       end 
   end 
end 
addEventHandler("onMarkerHit", myMarker, openForMe) 
            
function teleportMassive(player, matchingDimension) 
   setElementPosition(player, -2279.3093261719, 1909.4665527344, 8.9688625335693) 
   setElementRotation(player, 270.36642456055) 
   removeCommandHandler("leave") 
end 

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