Jump to content

ATC script error


Khtsjefen

Recommended Posts

SERVER

ebacol = createColSphere( -1276.9361572266, 54.15234375, 65.905364990234, 7 ) 
state = createColPolygon ( 0, 0, -4000, -4000, -4000, 4000, 4000, 4000, 4000, -4000 ) 
  
function atcDut(source,command) 
    isittrue = isElementWithinColShape ( source, ebacol ) 
    if (isittrue==true) then 
        local atcvehs = getElementsWithinColShape( state, "vehicle" ) 
        for v,source in ipairs(atcvehs) do 
            vehmod = getElementModel( atcvehs ) 
            if (vehmod==487) then 
                createBlipAttachedTo( atcvehs, 0, 2, 0, 200, 255, 255, 0, 99999, source ) 
            end 
        end 
        outputChatBox("You are now on ATC Duty", source) 
    end 
end 
addCommandHandler("atcduty", atcDut) 
  
function eatcDut(source,command) 
    isittrue = isElementWithinColShape ( source, ebacol ) 
    if (isittrue==true) then 
        local atcb = getElementsWithinColShape( state, "blips" ) 
        for v,source in ipairs(blips) do 
            destroyElement( atcb ) 
            stopResource ( getResourceFromName("blips") ) 
            startResource ( getResourceFromName("blips") ) 
        end 
        outputChatBox("You are now off ATC Duty", source) 
    end 
end 
addCommandHandler("endduty", eatcDut) 

I dunno what's wrong, but it wont create a blip at the vehicles I ser (maverick only so far in that script, adding more when it work).

at /atcduty I get the output at least, but in /endduty nothing happens at all.

Getting following:

[2012-04-15 17:31:32] WARNING: airport\atcmark.lua:9: Bad argument @ 'getElementModel' 
[2012-04-15 17:31:37] ERROR: airport\atcmark.lua:23: bad argument #1 to 'ipairs' (table expected, got nil) 

Link to comment
local ebacol    = createColSphere ( -1276.9361572266, 54.15234375, 65.905364990234, 7 ); 
local state     = createColPolygon ( 0, 0, -4000, -4000, -4000, 4000, 4000, 4000, 4000, -4000 ); 
  
addCommandHandler ( 'atcduty',  
    function ( uPlayer ) 
        if ( isElementWithinColShape ( uPlayer, ebacol ) ) then 
            for _, player in ipairs ( getElementsWithinColShape ( state, 'vehicle' ) ) do -- state must be colshape 
                if ( getElementModel ( getPedOccupiedVehicle ( player ) ) == 487 ) then 
                    createBlipAttachedTo ( player, 0 2, 0, 200, 255, 255, 0, 99999, uPlayer ); 
                end 
            end 
            outputChatBox ( 'You are now on ATC Duty!', uPlayer, 255, 255, 255, false ); 
        end 
    end 
) 
  
addCommandHandler ( 'endduty',  
    function ( uPlayer ) 
        if ( isElementWithinColShape ( uPlayer, ebacol ) ) then 
            for _, player in ipairs ( getElementsWithinColShape ( state, 'blips' ) ) do -- state must be colshape 
                restartResource ( getResourceFromName ( 'blips' ) ); 
            end 
            outputChatBox ( 'You are now off ATC Duty!', uPlayer, 255, 255, 255, false ); 
        end 
    end  
) 

See comments. Also, your code must have admin rights.

Link to comment
local ebacol    = createColSphere ( -1276.9361572266, 54.15234375, 65.905364990234, 7 ); 
local state     = createColPolygon ( 0, 0, -4000, -4000, -4000, 4000, 4000, 4000, 4000, -4000 ); 
  
addCommandHandler ( 'atcduty',  
    function ( uPlayer ) 
        if ( isElementWithinColShape ( uPlayer, ebacol ) ) then 
            for _, player in ipairs ( getElementsWithinColShape ( state, 'vehicle' ) ) do -- state must be colshape 
                if ( getElementModel ( getPedOccupiedVehicle ( player ) ) == 487 ) then 
                    createBlipAttachedTo ( player, 0 2, 0, 200, 255, 255, 0, 99999, uPlayer ); 
                end 
            end 
            outputChatBox ( 'You are now on ATC Duty!', uPlayer, 255, 255, 255, false ); 
        end 
    end 
) 
  
addCommandHandler ( 'endduty',  
    function ( uPlayer ) 
        if ( isElementWithinColShape ( uPlayer, ebacol ) ) then 
            for _, player in ipairs ( getElementsWithinColShape ( state, 'blips' ) ) do -- state must be colshape 
                restartResource ( getResourceFromName ( 'blips' ) ); 
            end 
            outputChatBox ( 'You are now off ATC Duty!', uPlayer, 255, 255, 255, false ); 
        end 
    end  
) 

See comments. Also, your code must have admin rights.

Nop, I want it to make a blip attached to all the aircrafts (I will add all id's when the script works) that is spawned, not just the aircraft I sit in, if that got the correct id. (Maverick in that one)

For info: The colshape named ebacol is in the top of the San Fierro Airport Tower, as I am using a mapping I have made there.

Link to comment
ebacol = createColSphere( -1276.9361572266, 54.15234375, 65.905364990234, 7 ) 
state = createColPolygon ( 0, 0, -4000, -4000, -4000, 4000, 4000, 4000, 4000, -4000 ) 
blips = { } 
  
function atcDut ( source ) 
    local isittrue = isElementWithinColShape ( source, ebacol ) 
    if ( isittrue == true ) then 
        local atcvehs = getElementsWithinColShape( state, "vehicle" ) 
        for index, vehicle in ipairs ( atcvehs ) do 
            local vehmod = getElementModel ( vehicle ) 
            if ( vehmod == 487 ) then 
                table.insert ( blips, createBlipAttachedTo ( atcvehs, 0, 2, 0, 200, 255, 255, 0, 99999, source ) ) 
            end 
        end 
        outputChatBox ( "You are now on ATC Duty", source ) 
    end 
end 
addCommandHandler ( "atcduty", atcDut ) 
  
function eatcDut ( source ) 
    local isittrue = isElementWithinColShape ( source, ebacol ) 
    if ( isittrue == true ) then 
        for index, blip in ipairs ( blips ) do 
            if ( isElement ( blip ) ) then 
                destroyElement ( blip ) 
            end 
        end 
        outputChatBox ( "You are now off ATC Duty", source ) 
    end 
end 
addCommandHandler ( "endduty", eatcDut ) 

Should store each blip on "blips" table then loop it and destroy the blips.

Link to comment
ebacol = createColSphere( -1276.9361572266, 54.15234375, 65.905364990234, 7 ) 
state = createColPolygon ( 0, 0, -4000, -4000, -4000, 4000, 4000, 4000, 4000, -4000 ) 
blips = { } 
  
function atcDut ( source ) 
    local isittrue = isElementWithinColShape ( source, ebacol ) 
    if ( isittrue == true ) then 
        local atcvehs = getElementsWithinColShape( state, "vehicle" ) 
        for index, vehicle in ipairs ( atcvehs ) do 
            local vehmod = getElementModel ( vehicle ) 
            if ( vehmod == 487 ) then 
                table.insert ( blips, createBlipAttachedTo ( vehicle, 0, 2, 0, 200, 255, 255, 0, 99999, source ) ) 
            end 
        end 
        outputChatBox ( "You are now on ATC Duty", source ) 
    end 
end 
addCommandHandler ( "atcduty", atcDut ) 
  
function eatcDut ( source ) 
    local isittrue = isElementWithinColShape ( source, ebacol ) 
    if ( isittrue == true ) then 
        for index, blip in ipairs ( blips ) do 
            if ( isElement ( blip ) ) then 
                destroyElement ( blip ) 
            end 
        end 
        outputChatBox ( "You are now off ATC Duty", source ) 
    end 
end 
addCommandHandler ( "endduty", eatcDut ) 

Edited by Guest
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...