Jump to content

Helpe me


UnG//Macaus

Recommended Posts

Can anyone help me solve this error? everything works, but I got errors in debugscript

Debugscript:

WARNING: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got vehicle] 

Server side

  
Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) 
function Funcion (source) 
    if isElementWithinMarker(source, Zona) then 
    playerTeam = getPlayerTeam ( source ) 
    Clann = getTeamFromName ( "Police" ) 
        if ( playerTeam ) == Clann then 
        veh = getPedOccupiedVehicle(source) 
            if (veh) then 
                moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
            else 
                moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
            end 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", Zona, Funcion ) 

Link to comment
Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) 
function Funcion (player) 
    if isElementWithinMarker(player, Zona) then 
    playerTeam = getPlayerTeam ( player) 
    Clann = getTeamFromName ( "Police" ) 
        if ( playerTeam ) == Clann then 
        veh = getPedOccupiedVehicle(player) 
            if (veh) then 
                moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
            else 
                moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
            end 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", Zona, Funcion ) 

Link to comment
Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) 
function Funcion (player) 
    if isElementWithinMarker(player, Zona) then 
    playerTeam = getPlayerTeam ( player) 
    Clann = getTeamFromName ( "Police" ) 
        if ( playerTeam ) == Clann then 
        veh = getPedOccupiedVehicle(player) 
            if (veh) then 
                moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
            else 
                moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
            end 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", Zona, Funcion ) 

Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got vehicle]

Bad argument @'getPedOccupiedVehicle'[Expected ped at argument 1, got vehicle]

Link to comment

You must handle the case when a vehicle hit's the marker, your first script would only work for player elements. This should solve your problem.

Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) 
  
function Funcion (source) 
    if isElementWithinMarker(source, Zona) then 
        local playerTeam = nil 
        if getElementType(source) == "Player" then 
            playerTeam = getPlayerTeam ( source ) 
        elseif getElementType(source) == "Vehicle" then 
            local occupant = getVehicleOccupants(source)[0] 
            playerTeam = getPlayerTeam ( occupant ) 
        end 
        Clann = getTeamFromName ( "Police" ) 
        if ( playerTeam ) == Clann then 
            veh = getPedOccupiedVehicle(source) 
            if (veh) then 
                moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
            else 
                moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
            end 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", Zona, Funcion ) 

Link to comment
Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) 
function Funcion (hitElement) 
    playerTeam = getPlayerTeam (hitElement) 
    Clann = getTeamFromName ( "Police" ) 
        if ( playerTeam ) == Clann then 
        veh = getPedOccupiedVehicle(hitElement) 
            if (veh) then 
            moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
        else 
            moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", Zona, Funcion ) 

Link to comment
Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) 
function Funcion (hitElement) 
    playerTeam = getPlayerTeam (hitElement) 
    Clann = getTeamFromName ( "Police" ) 
        if ( playerTeam ) == Clann then 
        veh = getPedOccupiedVehicle(hitElement) 
            if (veh) then 
            moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
        else 
            moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", Zona, Funcion ) 

Now besides having the same errors, the gate apre for others who are not in the Police team

Link to comment
moving = false 
closed = true 
movetime = 968 
  
function openGate(player) 
    if getElementType(player) == "player" then 
    if getPlayerTeam(player) ~= getTeamFromName("Police") then return end 
    if not moving and closed then 
        moveObject(objecto,3000, 1541.0999755859, -1627.6999511719, 9.4) 
        moving = true 
        closed = false 
        setTimer(function() moving = false end, movetime, 1) 
    end 
    end 
end 
addEventHandler("onMarkerHit", Zona, openGate) 
  
function closeGate(player) 
    if getElementType(player) == "player" then 
    if getPlayerTeam(player) ~= getTeamFromName("Police") then return end 
    if not moving and not closed then 
        moveObject(objecto,1540.8887939453, -1630.9000244141, 12,) 
        moving = true 
        closed = true 
        setTimer(function() moving = false end, movetime, 1) 
    end 
    end 
end 
addEventHandler("onMarkerLeave", Zona, closeGate) 

Link to comment
moving = false 
closed = true 
movetime = 968 
  
function openGate(player) 
    if getElementType(player) == "player" then 
    if getPlayerTeam(player) ~= getTeamFromName("Police") then return end 
    if not moving and closed then 
        moveObject(objecto,3000, 1541.0999755859, -1627.6999511719, 9.4) 
        moving = true 
        closed = false 
        setTimer(function() moving = false end, movetime, 1) 
    end 
    end 
end 
addEventHandler("onMarkerHit", Zona, openGate) 
  
function closeGate(player) 
    if getElementType(player) == "player" then 
    if getPlayerTeam(player) ~= getTeamFromName("Police") then return end 
    if not moving and not closed then 
        moveObject(objecto,1540.8887939453, -1630.9000244141, 12,) 
        moving = true 
        closed = true 
        setTimer(function() moving = false end, movetime, 1) 
    end 
    end 
end 
addEventHandler("onMarkerLeave", Zona, closeGate) 

moving = false 
closed = true 
movetime = 968 
  
function openGate(player) 
    if getElementType(player) == "player" then 
    if getPlayerTeam(player) ~= getTeamFromName("Police") then return end 
    if not moving and closed then 
        moveObject(objeto,3000, 1541.0999755859, -1627.6999511719, 9.4) 
        moving = true 
        closed = false 
        setTimer(function() moving = false end, movetime, 1) 
    end 
    end 
end 
addEventHandler("onMarkerHit", Zona, openGate) 
  
function closeGate(player) 
    if getElementType(player) == "player" then 
    if getPlayerTeam(player) ~= getTeamFromName("Police") then return end 
    if not moving and not closed then 
        moveObject(objeto, 3000, 1541.0999755859, -1627.6999511719, 15.199999809265) 
        moving = true 
        closed = true 
        setTimer(function() moving = false end, movetime, 1) 
    end 
    end 
end 
addEventHandler("onMarkerLeave", Zona, closeGate) 

Works fine, thank XeoN-

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