FSXTim Posted May 21, 2012 Share Posted May 21, 2012 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
X-SHADOW Posted May 21, 2012 Share Posted May 21, 2012 (edited) x Edited May 21, 2012 by Guest Link to comment
FSXTim Posted May 21, 2012 Author Share Posted May 21, 2012 Sorry, Sir, I posted the wrong script, please have a look again. Greets Link to comment
FSXTim Posted May 21, 2012 Author Share Posted May 21, 2012 Sure, it has! But renember, this is the error: attempt to index global 'g_MapInfo' (a nil value) And not that: attempt to index global 'g_MapInfo.author' (a nil value) Greets Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 Where's g_MapInfo defined? Is it in another resource? Link to comment
FSXTim Posted May 21, 2012 Author Share Posted May 21, 2012 Okay, I put the script into [race]/race/ And the maps are here: [race]/[maps] I didn't define 'g_MapInfo' Greets Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 Where did you get it from? I don't know any resource with this... Link to comment
FSXTim Posted May 21, 2012 Author Share Posted May 21, 2012 Ressource: Race 'g_MapInfo.author': The Author name of a map Greets Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 (edited) ok, I'll edit this again when I get more info from the race resource... BTW, What race script did you found it in? Edited May 21, 2012 by Guest Link to comment
FSXTim Posted May 21, 2012 Author Share Posted May 21, 2012 I don't know, Sir, what do you exactly want to know? Greets Link to comment
FSXTim Posted May 21, 2012 Author Share Posted May 21, 2012 I didn't found it, it's my own script, when a player enter the game, than the ChatBox says: ... map name ... and ... author of the map .. (actual map) Greets Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 so, How do you get the map author? if the g_MapInfo is not defined. Link to comment
FSXTim Posted May 21, 2012 Author Share Posted May 21, 2012 I think is the problem, how do I have to define it? Greets Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 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
Anderl Posted May 21, 2012 Share Posted May 21, 2012 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
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 oh, thanks for correcting me, I was in a rush, anyways, I'll brb Link to comment
FSXTim Posted May 21, 2012 Author Share Posted May 21, 2012 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
Anderl Posted May 21, 2012 Share Posted May 21, 2012 Stop copy + paste. That will never work. Link to comment
Cadu12 Posted May 21, 2012 Share Posted May 21, 2012 Jaysds1, at line 6 is wrong. FSXTim, your code is wrong. Link to comment
arezu Posted May 21, 2012 Share Posted May 21, 2012 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
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 np, @Cadu12, thanks for telling me that, I found my error 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