Jump to content

Radar Area trouble...


Recommended Posts

Hi all,

I didn't know whether to put this as Scripting or Server, but I think this is a server problem...

Anyways, I'm using radars.xml for my turf script/resource, and when I start it, I get errors like these: Image

Line number On/Off | Expand/Contract | Select all

2012-04-30 09:43:29] WARNING: [JWR]\turfs\server.lua:24: Bad argument @ 'createColPolygon'

I want to use createColRectangle, and it tells me to use createColPolygon, I don't know why...

Any reason why?

If you need anymore info, let me know.

Link to comment

oh, ok,

here:

addEventHandler("onResourceStart",resourceRoot,function() 
    local radarXML = xmlLoadFile("radars.xml") 
    if radarXML then 
        for index,child in pairs(xmlNodeGetChildren(radarXML))do 
            name = xmlNodeGetAttribute(child,"name") 
            px = xmlNodeGetAttribute(child,"posX") 
            py = xmlNodeGetAttribute(child,"posY") 
            sx = xmlNodeGetAttribute(child,"sizeX") 
            sy = xmlNodeGetAttribute(child,"sizeY") 
            clr = xmlNodeGetAttribute(child,"color") 
            dim = xmlNodeGetAttribute(child,"dimension") 
            team = xmlNodeGetAttribute(child,"team") 
            ra = createRadarArea(px,py,sx,sy,clr,100) 
            setElementData(ra,"team",team) 
            setElementData(ra,"turfName",name) 
             
            cX = xmlNodeGetAttribute(child,"colX") 
            cY = xmlNodeGetAttribute(child,"coY") 
            cW = xmlNodeGetAttribute(child,"colW") 
            cH = xmlNodeGetAttribute(child,"colH") 
            colR = createColRectangle(cX,cY,40,40) 
            col = createColPolygon(cX,cY,40,40) 
        end 
    end 
    addEventHandler("onColShapeHit",colR,turf) 
    xmlUnloadFile(radarXML) 
end) 

here's the radar.xml file

<radars> 
    <areas name="Grove Street" posX="-2183.5678710938" posY="705.67950439453" sizeX="40" sizeY="-40" color="#33CC00" dimension="0" col="Rec" colX="-2171.0678710938" colY="678.17950439453" colW="15" colH="15" team="Grove Street Famillies"/> 
</radars> 

Last log:

  
[2012-05-02 18:26:11] WARNING: [JWR]\turfs\server.lua:28: Bad argument @ 'createColPolygon' 
[2012-05-02 18:26:11] WARNING: [JWR]\turfs\server.lua:29: Bad argument @ 'createColRectangle' 
[2012-05-02 18:26:11] WARNING: [JWR]\turfs\server.lua:32: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] 

Link to comment
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        local radarXML = xmlLoadFile ( "radars.xml" ) 
        if ( radarXML ) then 
            for index, child in ipairs ( xmlNodeGetChildren ( radarXML ) )do 
                name = xmlNodeGetAttribute ( child, "name" ) 
                px = xmlNodeGetAttribute ( child, "posX" ) 
                py = xmlNodeGetAttribute ( child, "posY" ) 
                sx = xmlNodeGetAttribute ( child, "sizeX" ) 
                sy = xmlNodeGetAttribute ( child, "sizeY" ) 
                clr = xmlNodeGetAttribute ( child, "color" ) 
                dim = xmlNodeGetAttribute ( child, "dimension" ) 
                team = xmlNodeGetAttribute ( child, "team" ) 
                ra = createRadarArea ( px, py, sx, sy, clr, 100 ) 
                setElementData ( ra, "team", team ) 
                setElementData ( ra, "turfName", name ) 
  
                cX = tonumber ( xmlNodeGetAttribute ( child, "colX" ) ) 
                cY = tonumber ( xmlNodeGetAttribute ( child, "colY" ) ) -- You had "coY" instead of "colY". 
                cW = tonumber ( xmlNodeGetAttribute ( child, "colW" ) ) 
                cH = tonumber ( xmlNodeGetAttribute ( child, "colH" ) ) 
                colR = createColRectangle ( cX, cY, 40, 40 ) 
                addEventHandler ( "onColShapeHit", colR, turf ) -- You added the event after ending the loop. 
            end 
        end 
  
        xmlUnloadFile ( radarXML ) 
    end 
) 

Read the comments.

Link to comment

Thanks, I've been having problems with this for the paste couple of days

sorry, to bother you again, for some reason this event isn't cancelling:

addEventHandler("onVehicleStartExit",root,function(plr) 
    if(isVehicleLocked(source))then 
        cancelEvent() 
        outputChatBox("The vehicle is still locked, please unlock to get out.",plr,100,0,0) 
    end 
end) 

Link to comment

DAMN DAMN DAMN DAMN,

sorry, I'm mad, I thought about this and I thought it would be a great idea, but now :?:

Anyways, is there anyway around this?

I know I can't insert the radar areas and the colshapes in a table through a loop.

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