Jump to content

'g_MapInfo' Problem


FSXTim

Recommended Posts

Hello,

I have a problem with my script. Please have a look.

outputChatBox ("#FFFFFF|INFO| #00CD00Aktuelle Map: < #FFFFFF"..getMapName().."#00CD00 > by <#FFFFFF"..g_MapInfo.author.." 00CD00>", player, 0, 205, 0, true) 

Error: attempt to index global 'g_MapInfo' (a nil value)

Greets

Link to comment

You could either put it as a function or local it, exmaple:

g_MapInfo("author") 
function g_MapInfo(string) 
    if(string=="author")then 
        for i,v in ipairs(getResources())do 
            if(getResourceState(v)=="running")then 
                if(getResourceInfo(v,"type")==map)then 
                    return getResourceInfo(v,"author") 
                    break; 
                end 
            end 
        end 
    end 
end 

Link to comment

That's wrong Jaysds1, this doesn't do what he wants.

I think you can do that:

function getAuthorFromMap ( pMap ) 
    if ( pMap ) then 
        return getResourceInfo ( pMap, 'author' ); 
    end 
end 
  
-- 
  
getAuthorFromMap ( getResourceFromName ( getMapName ( ) ) ); 
  
return: 
  
-- map author 

Link to comment
            g_MapInfo("author") 
            function g_MapInfo(string) 
                if(string=="author")then 
                    for i,v in ipairs(getResources())do 
                        if(getResourceState(v)=="running")then 
                            if(getResourceInfo(v,"type")==map)then 
                                return getResourceInfo(v,"author") 
                                outputChatBox ("#FFFFFF|INFO| #00CD00Aktuelle Map: < #FFFFFF"..getMapName().."#00CD00 > by <#FFFFFF"..g_MapInfo.author.." 00CD00>", player, 0, 205, 0, true)                                 
                                break; 
                            end 
                        end 
                    end 
                end 
            end 

I will test it! (added outputCHatBox())

Link to comment
function getRunningMapAuthor() 
    local runningMap = exports.mapmanager:getRunningGamemodeMap() 
    if not runningMap then return end 
    return getResourceInfo(runningMap, "author") 
end 
outputChatBox ("#FFFFFF|INFO| #00CD00Aktuelle Map: < #FFFFFF"..getMapName().."#00CD00 > by <#FFFFFF"..(getRunningMapAuthor() or "N/A").." 00CD00>", player, 0, 205, 0, true) 

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