MrXz Posted April 30, 2012 Share Posted April 30, 2012 Hi all I recently did this script and not which is the error Please Help D: i would greatly appreciate --------------------------------------- -------------- BUY - MAP -------------------- function mapsList() local resourceTable = getResources() for resourceKey, resourceValue in ipairs(resourceTable) do local name = getResourceInfo(resourceValue, 'name') local type = getResourceInfo(resourceValue, 'type') local game = getResourceInfo(resourceValue, 'gamemodes') local author = getResourceInfo(resourceValue, 'author') if type == 'map' and game == 'race' then triggerClientEvent('sendMaps', getRootElement(), name, author) else cancelEvent() end end end addEvent('getMaps', true) addEventHandler('getMaps', getRootElement(), mapsList) addEvent('buyMapFromPanel', true) function buyMFP(mapname) if g_ForcedNextMap then outputChatBox('#00FF90[shop]#f1f1f1Next map is '..getMapName(g_ForcedNextMap),source,255,255,0, true) return end local query = #{mapname}>0 and table.concat({mapname},' ') or nil if not query then if g_ForcedNextMap then outputChatBox('#00FF90[shop]#f1f1f1Next map is '..getMapName(g_ForcedNextMap),source,255,255,0, true) else outputChatBox('#00FF90[shop]#f1f1f1Next map is not set',source,255,255,0, true) end return end local map, errormsg = findMap(query) if not map then outputChatBox(errormsg, source) return end if lastmap_B == map then outputChatBox('#00FF90[shop]#ffffffThat map has been palyed too much recently !',source,255,255,0, true) else g_ForcedNextMap = map local nameAh = getPlayerName(source) local nameAhB = string.gsub(nameAh, "#%x%x%x%x%x%x", "") outputChatBox('#00FF90[shop]#c8c8c8'..nameAhB..' bought map '..getMapName(g_ForcedNextMap)..' for $3500.',getRootElement(),255,255,0, true) givePlayerMoney(source, -1750) setElementData(source, 'Money', getPlayerMoney(source)) lastmap_B = g_ForcedNextMap end end addEventHandler('buyMapFromPanel', getRootElement(), buyMFP) --Find a map which matches, or nil and a text message if there is not one match function findMap( query ) local maps = findMaps( query ) -- Make status string local status = "Found " .. #maps .. " match" .. ( #maps==1 and "" or "es" ) for i=1,math.min(5,#maps) do status = status .. ( i==1 and ": " or ", " ) .. "'" .. getMapName( maps[i] ) .. "'" end if #maps > 5 then status = status .. " (" .. #maps - 5 .. " more)" end if #maps == 0 then return nil, status .. " for '" .. query .. "'" end if #maps == 1 then return maps[1], status end if #maps > 1 then return nil, status end end -- Find all maps which match the query string function findMaps( query ) local results = {} --escape all meta chars query = string.gsub(query, "([%*%+%?%.%(%)%[%]%{%}%\%/%|%^%$%-])","%%%1") -- Loop through and find matching maps for i,resource in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource())) do local resName = getResourceName( resource ) local infoName = getMapName( resource ) -- Look for exact match first if query == resName or query == infoName then return {resource} end -- Find match for query within infoName if string.find( infoName:lower(), query:lower() ) then table.insert( results, resource ) end end return results end function getMapName( map ) return getResourceInfo( map, "name" ) or getResourceName( map ) or "unknown" end Link to comment
MrXz Posted May 1, 2012 Author Share Posted May 1, 2012 Is the panel buy map Line 3894 for i,resource in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource())) do 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