Jump to content

Small error on garage script :?:


Miika

Recommended Posts

Small error that need's a fix.

5: Bad Argument @'getPedOccupiedVehicle [expected ped at argument, got vehicle]' 

[server]

allowLeaveVehicle = true 
col = createColSphere(-1904.5953369141, 275.81134033203, 41.046875, 1.5 ) 
  
function openDoor(thePlayer) 
local veh = getPedOccupiedVehicle(thePlayer) 
    if not ( source ~= vehicle ) then 
        setGarageOpen(18, true) 
        allowLeaveVehicle = true 
    else 
    return end 
end 
addEventHandler("onColShapeHit", col, openDoor) 

Link to comment
  Solidsnake14 said:
You need to check if the element that hit the colshape is a player using getElementType.
allowLeaveVehicle = true 
col = createColSphere(-1904.5953369141, 275.81134033203, 41.046875, 1.5 ) 
  
function openDoor(thePlayer) 
if getElementModel ( thePlayer ) == Player then 
local veh = getPedOccupiedVehicle(thePlayer) 
    if not ( source ~= vehicle ) then 
        setGarageOpen(18, true) 
        allowLeaveVehicle = true 
    else 
    return end 
end 
end 
addEventHandler("onColShapeHit", col, openDoor) 

Doesn't work :?:

Link to comment
allowLeaveVehicle = true 
col = createColSphere(-1904.5953369141, 275.81134033203, 41.046875, 1.5 ) 
  
function openDoor(thePlayer) 
if getElementType ( thePlayer ) == "player" then 
local veh = getPedOccupiedVehicle(thePlayer) 
    if not ( source ~= vehicle ) then 
        setGarageOpen(18, true) 
        allowLeaveVehicle = true 
    else 
    return end 
end 
end 
addEventHandler("onColShapeHit", col, openDoor) 

Link to comment

Same problem.

6: Bad Argument @'getPedOccupiedVehicle' [expected ped at argument, got vehicle' 
  
 

allowLeaveVehicle = true 
col = createColSphere(-1904.5953369141, 275.81134033203, 41.046875, 1.5 ) 
  
function openDoor(thePlayer) 
if getElementType ( thePlayer ) == "player" or getElementType ( thePlayer ) == "vehicle" then 
local vehicle = getPedOccupiedVehicle(thePlayer) 
    if not ( source ~= vehicle ) then 
        setGarageOpen(18, true) 
        allowLeaveVehicle = true 
    else 
    return end 
else 
outputChatBox("Output if doesn't work") 
return end 
end 
addEventHandler("onColShapeHit", col, openDoor) 

Link to comment
  Solidsnake14 said:
Of course you'll have the same problem, you edited the code Xeon gave you.
  Quote
if getElementType ( thePlayer ) == "player" or getElementType ( thePlayer ) == "vehicle" then 

It has to be:

  Quote
if getElementType ( thePlayer ) == "player" then 

I tested it, but it output's else message: "Output if doesn't work"

Link to comment
allowLeaveVehicle = true 
col = createColSphere(-1904.5953369141, 275.81134033203, 41.046875, 1.5) 
  
function openDoor(player) 
    if getElementType(player) == "player" then 
        local veh = getPedOccupiedVehicle(player) 
        if veh then 
            setGarageOpen(18, true) 
            allowLeaveVehicle = true 
        end 
    end 
end 
addEventHandler("onColShapeHit", col, openDoor) 

Link to comment
  TAPL said:
allowLeaveVehicle = true 
col = createColSphere(-1904.5953369141, 275.81134033203, 41.046875, 1.5) 
  
function openDoor(player) 
    if getElementType(player) == "player" then 
        local veh = getPedOccupiedVehicle(player) 
        if veh then 
            setGarageOpen(18, true) 
            allowLeaveVehicle = true 
        end 
    end 
end 
addEventHandler("onColShapeHit", col, openDoor) 

Oh! I found the problem. Wrong garage id :D

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