Khtsjefen Posted April 15, 2012 Share Posted April 15, 2012 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
drk Posted April 15, 2012 Share Posted April 15, 2012 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
Khtsjefen Posted April 15, 2012 Author Share Posted April 15, 2012 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
drk Posted April 15, 2012 Share Posted April 15, 2012 First - Create a colshape and use getElementsWithinColShape. Then, do this. Link to comment
Khtsjefen Posted April 15, 2012 Author Share Posted April 15, 2012 And what is "This"? Link to comment
Khtsjefen Posted April 15, 2012 Author Share Posted April 15, 2012 Still not getting it to work. I will continue tomorrow I guess. Link to comment
Castillo Posted April 15, 2012 Share Posted April 15, 2012 @Khtsjefen: What you're trying to achieve is to create blips on each Maverick and destroy them when you write /endduty ? Link to comment
Khtsjefen Posted April 15, 2012 Author Share Posted April 15, 2012 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. Link to comment
Castillo Posted April 15, 2012 Share Posted April 15, 2012 You haven't answered my question, or you already solved your problem? Link to comment
Khtsjefen Posted April 15, 2012 Author Share Posted April 15, 2012 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. Link to comment
Castillo Posted April 15, 2012 Share Posted April 15, 2012 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
Khtsjefen Posted April 16, 2012 Author Share Posted April 16, 2012 But still not making any blips. Getting bad arguement error at getElementModel. Link to comment
drk Posted April 16, 2012 Share Posted April 16, 2012 (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 April 16, 2012 by Guest Link to comment
Khtsjefen Posted April 16, 2012 Author Share Posted April 16, 2012 Still no blips No outputs in the console or debugscript either. EDIT: I think I got the solutin - Hold on a moment! :D EDIT: But no Link to comment
Khtsjefen Posted April 16, 2012 Author Share Posted April 16, 2012 Still nop, no blips appear. (last tested in map editor.) Link to comment
drk Posted April 16, 2012 Share Posted April 16, 2012 Blips don't appear in Map Editor, just if you have Freeroam resource on. Link to comment
Khtsjefen Posted April 16, 2012 Author Share Posted April 16, 2012 Then I know why it dont work, I am not using freeroam when making it. THough, only one of the tests was in ME (map editor) Link to comment
Khtsjefen Posted April 19, 2012 Author Share Posted April 19, 2012 (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? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now