FSXTim Posted May 21, 2012 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
X-SHADOW Posted May 21, 2012 Posted May 21, 2012 (edited) x Edited May 21, 2012 by Guest My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
FSXTim Posted May 21, 2012 Author Posted May 21, 2012 Sorry, Sir, I posted the wrong script, please have a look again. Greets
Jaysds1 Posted May 21, 2012 Posted May 21, 2012 Does the map have an author? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
FSXTim Posted May 21, 2012 Author 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
Jaysds1 Posted May 21, 2012 Posted May 21, 2012 Where's g_MapInfo defined? Is it in another resource? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
FSXTim Posted May 21, 2012 Author 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
Jaysds1 Posted May 21, 2012 Posted May 21, 2012 Where did you get it from? I don't know any resource with this... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
FSXTim Posted May 21, 2012 Author Posted May 21, 2012 Ressource: Race 'g_MapInfo.author': The Author name of a map Greets
Jaysds1 Posted May 21, 2012 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 My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
FSXTim Posted May 21, 2012 Author Posted May 21, 2012 I don't know, Sir, what do you exactly want to know? Greets
FSXTim Posted May 21, 2012 Author 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
Jaysds1 Posted May 21, 2012 Posted May 21, 2012 so, How do you get the map author? if the g_MapInfo is not defined. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
FSXTim Posted May 21, 2012 Author Posted May 21, 2012 I think is the problem, how do I have to define it? Greets
Jaysds1 Posted May 21, 2012 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 My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Anderl Posted May 21, 2012 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 "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Jaysds1 Posted May 21, 2012 Posted May 21, 2012 oh, thanks for correcting me, I was in a rush, anyways, I'll brb My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
FSXTim Posted May 21, 2012 Author 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())
Anderl Posted May 21, 2012 Posted May 21, 2012 Stop copy + paste. That will never work. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Cadu12 Posted May 21, 2012 Posted May 21, 2012 Jaysds1, at line 6 is wrong. FSXTim, your code is wrong. Ingame nick: Cadu12
arezu Posted May 21, 2012 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)
Jaysds1 Posted May 21, 2012 Posted May 21, 2012 np, @Cadu12, thanks for telling me that, I found my error My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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