Jump to content

ATC script error


Khtsjefen

Recommended Posts

Posted

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) 

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

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

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

Posted

First - Create a colshape and use getElementsWithinColShape. Then, do this.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

@Khtsjefen: What you're trying to achieve is to create blips on each Maverick and destroy them when you write /endduty ?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

ATC: Air Traffic Controller

Anyway, no big reason for it really.

Also: Will add more id's when I get the script to work.

Possibly I'll upload it on the mantis, along with some small chat scripts.

Posted

You haven't answered my question, or you already solved your problem?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

It's not solved.

And I'm currently working on a airport script, and that blip script is for the tower controllers. I will add the id's of the rest of the aircrafts later.

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted (edited)
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

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

Blips don't appear in Map Editor, just if you have Freeroam resource on.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

(Sorry for double post)

Should be a way to make the blips show outside map editor too...

Any ideas?

I have another resource making blips anyway, though that's not attaching it to anything, just spawning them.

any ideas?

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